C_Programs_Sample_codes in c languaveut.pptx

vivekkumarsimra2042 0 views 2 slides Sep 01, 2025
Slide 1
Slide 1 of 2
Slide 1
1
Slide 2
2

About This Presentation

C language codes


Slide Content

Program 11: Sum of Digits 🔢 🔢 Aim: Write a program to find the sum of digits of a number. #include <stdio.h> int main() { int n, sum=0; scanf("%d",&n); while(n>0){ sum += n%10; n /= 10; } printf("Sum = %d", sum); return 0; } Input: 1234 Output: Sum = 10

Program 12: Palindrome Number 🔄 🔄 Aim: Write a program to check whether a number is palindrome or not. #include <stdio.h> int main() { int n, r=0, t; scanf("%d",&n); t=n; while(n>0){ r=r*10+n%10; n/=10; } if(t==r) printf("Palindrome"); else printf("Not Palindrome"); return 0; } Input: 121 Output: Palindrome
Tags