if a five digit number is input through the keyboard, write
a program to calculate the sum of its digits.
(hint:-use the modulus operator.'%')
Answer Posted / saurabh vyas
main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",&num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Post New Answer View All Answers
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
Can the curly brackets { } be used to enclose a single line of code?
Is that possible to add pointers to each other?
Where are some collections of useful code fragments and examples?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
Explain why C language is procedural?
What are the different types of control structures?
How is = symbol different from == symbol in c programming?
What are types of preprocessor in c?
What is the difference between int main and void main in c?
What is wrong with this statement? Myname = 'robin';
Tell us two differences between new () and malloc ()?
Why do we need volatile in c?
Why clrscr is used after variable declaration?