Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,d,m1,s=0,s1;
printf("enter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s=s+m1;
}
s1=s+m+d;
printf("\nThe sum of digits is ");
printf("%d",s1);
getch();
}
Is This Answer Correct ? | 7 Yes | 11 No |
Post New Answer View All Answers
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
What are types of functions?
What is a loop?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
How to write c functions that modify head pointer of a linked list?
Why c is called free form language?
What is calloc()?
Why main is not a keyword in c?
What is variables in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
What is #include in c?
Explain what is #line used for?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What are the different types of constants?