0
What is wrong in this program?
12 Respostas
+ 7
//The main logic was not good
#include <stdio.h>
int main() {
int siblings, popsicles,i;
scanf("%d", &siblings);
scanf("%d", &popsicles);
//your code goes here
//replace '?' with correct operator
i= popsicles ? siblings;
if(i==0)
{
printf("give away\n");
}
else
{
printf("eat them yourself");
}
/*no need this statement
else{
printf("there is no popsicles");
}*/
return 0;
}
+ 11
Pankaj Kumar check again code coach instruction you going right but u doing mistakes in conditions check it once.
+ 5
You have attached the link to the question, not the program. For that copy paste the code in code playground and then share it here.
+ 3
Pankaj Kumar you have been provided with the correct solution by ៎R1 . But he/she want some efforts from your side also. Just figure out what operator will replace "?" And you will be good to go.
+ 3
You got it right đ
+ 2
?=%
Thanks 7R1 and Arsenic.
+ 2
Pankaj Kumar There is no need of else if statement.
include <stdio.h>
int main() {
int siblings, popsicles;
scanf("%d", &siblings);
scanf("%d", &popsicles);
if(popsicles%siblings==0){
printf("give away");
}
else
{
printf("eat them yourself");
}
return 0;
}
+ 1
Yes, now I have corrected the mistake.
Thanks đđđ
+ 1
i= popsicles ? siblings
+ 1
Read and understand
0
#include <stdio.h>
int main() {
int siblings, popsicles,i;
scanf("%d", &siblings);
scanf("%d", &popsicles);
//your code goes here
i=siblings-popsicles;
if(i%2==0)
{
printf("give away\n");
}else if((i%2==1)||(i%2==-1))
{
printf("eat them yourself");
}
else{
printf("there is no popsicles");
}
return 0;
}
0
Not working