This PowerPoint helps students to consider the concept of infinity.
Add digits of number in c
1. Add digits of number in c
#include<stdio.h>
//#include<conio.h>
int main()
{
int n, t, sum = 0, remainder;
printf("Enter an integern");
scanf("%d", &n);
t = n;
while (t != 0)
{
remainder = t % 10;
sum = sum + remainder;
t = t / 10;
}
printf("Sum of digits of %d = %dn", n, sum);
return 0;
}
Output of program: