Tuesday, 8 May 2018

How to calculate the addition of a multidigit number in c language

/* addition of multidigit number */
# include <stdio.h>
void main ()
{
int a,b,sum=o ;     /* variable declaration and initialization*/
clrscr () ;
printf ("\n enter a multidigit number :") ;   /* input of variables*/
scanf ("%d", & a) ;
while (a!=0)           /* conditional statement */
{
b = a%10 ;               / * calculation statement */
sum = sum+b ;
a = a/10 ;
}
printf ("%d", sum ) ;      /* print on output screen * /
getch () ;
}

No comments:

Post a Comment

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...