Program of sum of all digits of a number in C, C Plus Plus (CPP, C++) with flow chart
Program of the sum of all digits of a number in C, C Plus Plus (CPP, C++) with the flow chart
In this tutorial, we will learn about the followings;
- Flowchart of the program of the sum of all digits of a number
- Program of the sum of all digits of a number in C Plus Plus (CPP, C++)
- Program of the sum of all digits of a number in C
Flowchart of the program of the sum of all digits of a number
Program of the sum of all digits of a number in C Plus Plus (CPP, C++)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<iostream> #include<conio.h> using namespace std; int main() { int z; int number; int add=0; cout<<"enter number of ur choice"; cin>>number; while(number>0) { z=number%10; number=number/10; add=add+z; } cout<<"add of digits :"<<add; return 0; } |
Output
Program of the sum of all digits of a number in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> #include<conio.h> int main() { int z; int number; int add=0; int temp; printf("enter number of ur choice \n"); scanf("%ld", &number); temp=number; while(number>0) { z=number%10; number=number/10; add=add+z; } printf("number= %ld\n", temp); printf("sum of digit %ld= %ld\n",temp ,add); } |
Output