write a C program for sum of digits.
Answers
Answered by
1
#include <stdio.h>
int main()
{
int t, sum = 0, remainder,n;
printf("Enter an integer :");
scanf("%d", &n);
t = n;
while (t != 0)
{
remainder = t % 10;
sum= sum + remainder;
t = t / 10;
}
printf("Sum of digits of %d = %d\n", n, sum);
return 0;
}
Hope this will help u
Has007:
Thanks bro
Answered by
0
Answer:
#include<iostream.h>
#include<conio.h>
voud main()
{
clrscr();
int a, b,sum;
cout<<"\nEnter first number";
cin>>a;
cout<<"\nEnter second number";
cin>>b;
sum=a+b;
cout<<"\nSum of digits is "<<sum;
getch();
}
Similar questions
Science,
7 months ago
Computer Science,
7 months ago
Accountancy,
7 months ago
Math,
1 year ago
English,
1 year ago