If 4 digits number is input through the keyboard, Write a
program to calculate sum of its 1st & 4th digit.
Answer Posted / abhilash
/*Hey
guys check dis out, It will work for upto 4 digit number*/
void main()
{
int num,sum=0,rem;
printf("Enter a number");
scanf(" %d",&num);
rem=num%10;
sum=sum+rem;
while(n>10)
{
num=num/10;
}
rem=num%10;
sum=sum+rem;
printf("sum of 2 digits is: %d",sum);
getch();
}
| Is This Answer Correct ? | 9 Yes | 8 No |
Post New Answer View All Answers
What is static and auto variables in c?
Are enumerations really portable?
Who developed c language and when?
Is it better to use a macro or a function?
What is meant by type specifiers?
How can I do graphics in c?
Explain what is output redirection?
What's a good way to check for "close enough" floating-point equality?
How to create struct variables?
Write a program to print factorial of given number using recursion?
Write a program to reverse a string.
formula to convert 2500mmh2o into m3/hr
Difference between exit() and _exit() function?
If the size of int data type is two bytes, what is the range of signed int data type?
what are the facialities provided by you after the selection of the student.