Answer to Question #253536 in C for Jack

Question #253536
write a program that reads a four digit positive integer and determine how many digits in the integer are equal to the last character of your roll number and print the result on the speed of the user enter and negative integer or an integer greater than four digit print a message on the screen in management teacher
1
Expert's answer
2021-10-19T16:18:06-0400
#include<stdio.h>
#include<stdlib.h>
int main ()
{ 
int d, d1, d2, d3, d4,digi;
printf("Enter 4-Digit Number:\n");
scanf("%d", &d);
d1 = (d/1000);
printf ("first digit is: %d \n", d1);
d2 = (d-(d1*1000))/100;
printf ("Second d is: %d \n", d2);
di = ((d/100)*100);
d3 = (d-digi)/10;
printf ("Third digit is: %d \n", d3);
d4 = ((d-((d/10)*10)));


printf ("Digit at unit place is: %d \n", d4 );
if(d4==" "){
    printf("The number is not a four digit");
}
else{
    printf("%d",d);
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS