Write a program using do while loop to find sum of given number
Answers
Answered by
1
PROGRAM CODE :-
#include<iostream.h>
#include <stdio.h>
void main()
{
int num,sum; /* given numbers */
clrscr();
printf("Enter integer numbers: ");
scanf ("%d", &num);
sum = 0;
do
{
sum += num % 10; /* add LS digit to digit sum */
num /= 10; /* remove LS digit from num */
} while (num > 0);
printf ("The Sum is = %d \n",sum);
getch();
}
OUTPUT :-
Enter integer numbers: 12345
The Sum is = 15
Answered by
0
Answer:
Explanation:
JsjakeokZm
Similar questions