C program that Accept a num
12345678
Find sum of digits at even places and check whether the sum is prime or not
7+5+3+1=16
Answers
Answered by
0
Answer:
/**
* C program to find sum of its digits of a number
*/
#include <stdio.h>
int main()
{
int num, sum=0;
/* Input a number from user */
printf("Enter any number to find sum of its digit: ");
scanf("%d", &num);
/* Repeat till num becomes 0 */
while(num!=0)
{
/* Find last digit of num and add to sum */
sum += num % 10;
/* Remove last digit from num */
num = num / 10;
}
printf("Sum of digits = %d", sum);
return 0;
}
Similar questions