Program to input two digit number and print Sum of its digits.
In this program input two digit number and print the sum of its digits. For this we find 1st digit by number/10 and 2nd digit by n%10.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,d1,d2,s=0;
clrscr();
printf("Enter two digit number=");
scanf("%d",&n);
d1=n/10;
d2=n%10;
s=d1+d2;
printf("\nSum of digits=%d",s);
getch();
}
OUTPUT
Comments
Post a Comment