Completely Solved C, C++ Programs Assignment.




C Program to accept a three digit number and print the sum of individual digits.

Filed Under:

Problem 8: C Program to accept a three digit number and print the sum of individual digits.
#include<stdio.h>
#include<conio.h>
main( )
{
int a,b,c,n, sum;
clrscr( );
printf (“ Enter a Three Digit Number:“);
scanf (“%d”,&n);
a=n/100;
b=( (n%100)/10);
c=n%10;
sum=a+b+c;
printf (“ Sum of Individual Digits of Given Numbers is %d”, Sum);
getch( );
}
C compiler: gcc 4.1.2

Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments