Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



" ; " after loop



Iterative statement



Working with switch case



Comment




Function_ summation of each digits of an integer




// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h> #include<math.h> #define pf printf //function declaration int reveres(int n); void main() { int x,rev; printf("Enter any number: "); scanf("%d",&x); //function call rev=reveres(x); printf("\nThe summation of each digits of the given number is: %d",rev); return 0; } //function definition int reveres(int n) //function header //function body { int temp,r=0; while(n!=0) { temp=n%10; //separating each digit of the integer r=r+temp; //adding each separated digits n/=10; //update loop } return r; }
OUTPUT:


© 2018 - All rights reserved