0

Is there any bug in the code below? I am solving the problem number 1044 from URI online judge.

#include <stdio.h> int main() {int A,B; scanf("%d %d",&A,&B); if(A%B==0 || B%A==0); {printf("%Sao Multiplos\n");} else {printf("Nao sao Multiplos\n");} return 0; }

25th Jun 2018, 4:24 PM
Mehrin Jahan
10 Antworten
+ 3
There is semi colon after the if condition and printf ("%???what?") there is a format specifier missing with what value you want to print. Add some spaces and line breaks for better readability.
25th Jun 2018, 4:37 PM
Akib
Akib - avatar
+ 2
you can use %d format specifier
25th Jun 2018, 4:42 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 1
Thanks Akib Reza ...The program ran successfully
25th Jun 2018, 4:41 PM
Mehrin Jahan
0
Which format specifier should I use?
25th Jun 2018, 4:39 PM
Mehrin Jahan
0
#include <stdio.h> int main() {int A,B; scanf("%d %d",&A,&B); if(A%B==0 || B%A==0) {printf("%Sao Multiplos\n");} else {printf("Nao sao Multiplos\n");} return 0; }
25th Jun 2018, 4:41 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
After running the program I have noticed that a 1 or 0 is printed in the output.. But I don't want to print them. What can I do now?
25th Jun 2018, 4:53 PM
Mehrin Jahan
0
// Why you have inserted % below??? printf("%Sao Multiplos\n"); Anyway i also making challenges there and i use codechef for online compiling
25th Jun 2018, 7:17 PM
KrOW
KrOW - avatar
0
KrOW It was a typing mistake.. By the way thanks
25th Jun 2018, 7:56 PM
Mehrin Jahan
0
Can you save your code on Code Playground section and post here his link? In this way we can run it
25th Jun 2018, 8:20 PM
KrOW
KrOW - avatar
0
Mehrin Jahan I have seen your code and ITS not the same that you have pasted... In your printf remove the format strinf param "%d" and you will see that no int will output... Please next time post your code link directly
25th Jun 2018, 8:24 PM
KrOW
KrOW - avatar