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


Please Help Members By Posting Answers For Below Questions

Write a program on swapping (100, 50)

640


What is function and its example?

630


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

1584


What is the difference between malloc() and calloc() function in c language?

608


What are the types of data structures in c?

606






Explain what are the standard predefined macros?

655


What are formal parameters?

664


I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

1500


How can I run c program?

692


How do you use a 'Local Block'?

728


Can a pointer be static?

629


How do you declare a variable that will hold string values?

672


shorting algorithmS

1805


What is c standard library?

694


Tell us bitwise shift operators?

601