Full width home advertisement

HTML

Tech News

Ad

Write a c program to find the sum of digits of accepted number 



#include<stdio.h>
#include<conio.h>
void main()
{
	int r,no,sum=0;
	clrscr();
	printf("Enter the value of no");
	scanf("%d",&no);
	while(no>0)
	{
	r=no%10;
	sum=sum+r;
	no=no/10;
	}
	printf("Sum of digit: %d",sum);
	getch();
}

Thank you for your time seeya again

No comments:

Post a Comment

Bottom Ad [Post Page]