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 Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...