Why is the result of Remainder is 0 1 instead of only 1? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why is the result of Remainder is 0 1 instead of only 1?

#include<stdio.h> int main() { int num1,num2,div; printf("Enter First integer : 10 "); scanf("%d", &num1); printf("\nEnter Second integer : 3 "); scanf("%d", &num2); div=num1/num2; printf("\nRemainder : %d %d",num1/num2); return 0; }

3rd Nov 2021, 4:42 PM
Yvns Kito
3 Respostas
0
Yvns Kito logical error, agree with AĶ¢J - SĶŸoĶŸlĶŸoĶŸHĶŸeĶŸlĶŸpĶŸeĶŸrĶŸ sir, and must change your printf statement. There should be only a single %d for reminder. printf ("Reminder: %d", num1%num2); or you can also do this div = num1 % num2; printf("Reminder: %d", div);
3rd Nov 2021, 5:29 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
Yvns Kito You are dividing instead of getting reminder. To get reminder use modulus operator (%) not /
3rd Nov 2021, 4:50 PM
AĶ¢J
AĶ¢J - avatar
0
I got the correct answer anyway by me ty foršŸ¤—
3rd Nov 2021, 5:31 PM
Yvns Kito