If 4 digits number is input through the keyboard, Write a
program to calculate sum of its 1st & 4th digit.

Answers were Sorted based on User's Feedback



If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st &..

Answer / anvesh

#include<stdio.h>
main()
{
int n,n1,n4;
printf("Enter 4 digit number:");
scanf("%d",&n);
n4=n%10;
n1=n/100;
printf("\nResult=",(n1+n4));
getch();
}

Is This Answer Correct ?    52 Yes 55 No

If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st &..

Answer / kadher masthan ,...sit

thiz z how 2 find the sum of first and last digit of any
number

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
long int n,nf,nl,temp;
int count=-1;
printf("Enter a number:");
scanf("%ld",&n);
temp =n;
while(temp<0)
{
temp=temp/10;
c++;
}
nl=n%10;
nf=n/(pow(10,c));
printf("\n%ldResult=",(nf+nl));
getch();
}

Is This Answer Correct ?    9 Yes 23 No

Post New Answer

More C Interview Questions

we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?

2 Answers  


how can i include my own .h file EX:- alex.h like #include<alex.h>, rather than #include"alex.h"

1 Answers  


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

0 Answers  


how can you print&scan anything using just one character? :) HINT: printf,scanf similer

2 Answers  


write a program to find the frequency of a number

4 Answers   Infosys,






Write a program to find factorial of a number using recursive function.

0 Answers   Global Logic, TCS,


what is a non volatile key word in c language?

1 Answers  


how to find out the union of two character arrays?

2 Answers  


how can f be used for both float and double arguments in printf? Are not they different types?

0 Answers  


How to write in a function declaration and in function call in which the function has 'n' number of varible or arguments?

2 Answers  


Is there a way to switch on strings?

0 Answers  


What is a newline escape sequence?

0 Answers  


Categories