input any 4 digit number and find the difference of all the
digits?
Answers were Sorted based on User's Feedback
char num[10];
printf ("Enter the number: ");
gets(num);
printf("Entered number = %s\n", num);
if (strlen(num) != 4) // check for 4 digit including NULL
{
printf("Error: number not 4 digit");
}
else
{
printf("\ndifference = %d", (num[0]&0x0F) - (num[1]&0x0F) - (num[2]&0x0F) - (num[3]&0x0F));
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / nitin garg
int j,num,rem,diff=0;
printf("
Enter Digit
");
scanf("%d",&num);
while(num!=0)
{
rem=num%10;
j=rem+rem;
diff=diff-rem;
num=num/10;
}
diff=diff+j;
printf("
Difference of Digit is : %d",diff);
| Is This Answer Correct ? | 0 Yes | 0 No |
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.
Write a program in c using only loops to print * * * * * *******
In C language what is a 'dangling pointer'?
Predict the output or error(s) for the following: 25. main() { printf("%p",main); }
for example user gives input as " 20 or 20.0 or rs 20.0 or 20.00 or rs20 and so .. on " and the output should be stored as " rs.20.00 " in a variable
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;
I need a sort of an approximate strcmp routine?
what do you mean by enumeration constant?
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)
Do you know null pointer?
What are reserved words?
#include<stdio.h> int main( ) { Int a=300, b, c; if(a>=400) b=300; c=200; printf(“%d%d ”, b, c); return0; }