Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



Iterative statement



Working with switch case



Test expression



Specifer




Enter a number and print summation each digits




// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int n,temp,sum=0; //taking the value to continue the loop pf("\nEnter any integer number: "); scanf("%d",&n); pf("\nThe summation of each digits of %d is: ",n); while(n!=0) //ending condition of the loop { temp=n%10; sum+=temp; //adding all the digits of the integer n/=10; //update loop } pf("%d",sum); //printing result return 0; }
OUTPUT:


© 2018 - All rights reserved