j

Tuesday, 3 November 2015

Write a program that take a number from user consisting of 4 digit and print the sum of all digit



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,a,b,c,d;
printf("Enter 4-digit number:");
scanf("%d",&n);
b=n/1000;
n=n%1000;
c=n/100;
n=n%100;
d=n/10;
n=n%10;
printf("Sum of all digit is %d ",d+c+b+n);
getch();
}

Subscribe to this Blog via Email :