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 |
What is dynamic memory allocation?
An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above
i want to know the procedure of qualcomm for getting a job through offcampus
marge linklist
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
why ordinary variable store the later value not the initial
What is queue in c?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
What is difference between main and void main?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
char ch=10;printf("%d",ch);what is the output
int n=1; while(1) { switch(n) { case 1:printf("a"); n++; continue; case 2:printf("b"); n++; continue; default : printf("c"); break; } break; }