Write a c-programe that input one number of four digits and find digits sum?
Answers were Sorted based on User's Feedback
Answer / erdem
{
int num, sum ;
printf("Enter digit 1\n");
scanf("%d",num);
sum=sum+num;
for(i=1;i<4;i++)
{
printf("Enter digit %d\n",i);
scanf("%d",num);
sum=sum+num;
}
printf("the sum of digits is %d",sum);
getche();
| Is This Answer Correct ? | 6 Yes | 1 No |
{
int sum,digit1,digit2,digit3,digit4;
printf("enter the four digit number\n");
scanf("%d",digit1,digit2,digit3,digit4);
digit1=(digit1%1000)/10;
digit2=(digit2%1000)/10;
digit3=(digit3%1000)/10;
digit4=(digit4%1000)/10;
sum=digit1+digit2+digit3+digit4;
printf("the sum of digits is %d",sum);
return(0);
}
| Is This Answer Correct ? | 1 Yes | 7 No |
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
How to reverse a linked list without using array & -1? Thank you.
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
What are the different types of errors in C and when they occur?
what is the large sustained error signal that eventually cause the controller output to drive to its limit
How to develop a program using C language to convert 8-bit binary values to decimals. TQ
Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.
Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?
I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00