Computer Science, asked by salim, 1 year ago

write a c program to find the individual digits of an positive intiger

Answers

Answered by Anonymous
0
#include<stdio.h>

#include<conio.h>

void main()

{

int num, k=1, sum=0;

clrscr();

printf(“Enter the number whose digits are to be added:”);

scanf(“%d”,&num);

while(num!=0)

{

k=num%10;

sum=sum+k;

k=num/10;

num=k;

}

printf(“Sum of the digits:%d”,sum);

getch();
Answered by kopal
0
#include<stdio.h>

#include<conio.h>

void main()

{

int num, s=1, sum=0;

clrscr();

printf(“Enter the number whose digits are to be added:”);

scanf(“%d”,&num);

while(num!=0)

{

s=num%10;

sum=sum+s;

s=num/10;

num=s;

}

printf(“Sum of the digits:%d”,sum);

getch();
hope this helps u !!!!!!!!!
Similar questions