What's new

Closed C++ problem please help po

Status
Not open for further replies.

Yang D

Addict
Joined
Mar 7, 2017
Posts
239
Reaction
47
Points
114
Age
27
#include<stdio.h>
int main()
{
int a;
int b=20;

printf("the value of B is 20\n");
printf("the value of a\n");
scanf("%d",&a);
if(a==b);
printf("equal");
}
else if(a<b)
{
printf("less than");
}
else if(a>b)
{
printf("greater than");
}
else
{
printf("invalid");
return 0;
}


mga sir ano po mali sa code ko,patuling nman po sa mga magagaling jan sa c++
 
hndi na printf ang code nyan.

cout >> " output code " ; c++ to dba?

if C yan.

heres the error.

if(a==b); <----- error yan. close mo agad if statement mo.

tangallin mo ang semi colon
it should look like this

if(a==b)

THANK ME LATER
 
#include <stdio.h>
int main()
{
int a;
int b=20;

printf("the value of B is 20\n");
printf("the value of a\n");
scanf("%d",&a);
if(a==b)
printf("equal");

else if(a<b)

printf("less than");

else if(a>b)

printf("greater than");

else

printf("invalid");

return 0;
}

online compiler lang kasi ginamit ko kaya d ko alam kung tama yung ouput.pero successful naman yung pag compile
 
#include<stdio.h>
int main()
{
int a;
int b=20;

printf("the value of B is 20\n");
printf("the value of a\n");
scanf("%d",&a);
if(a==b); <<<<<<<<<<<<<<<<<<<<<<<<< natypo ka dito sir. dapat "{" instead of ";"
printf("equal");
}
else if(a<b)
{
printf("less than");
}
else if(a>b)
{
printf("greater than");
}
else
{
printf("invalid");
return 0; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< dapat wala sya sa loob ng if else. nasa labas dapat sya pero nasa loob ng int main().
}
 
#include<stdio.h>
int main()
{
int a;
int b=20;

printf("the value of B is 20\n");
printf("the value of a\n");
scanf("%d",&a);

if(a==b); <<<<<<<<<tama sila, palitan mo ng {
printf("equal");
}
else if(a<b)
{
printf("less than");
}
else if(a>b)
{
printf("greater than");
}
else
{
printf("invalid");
return 0;
}

}<<<<<<<<<<<<<Kulang ng brace
 
Status
Not open for further replies.

Similar threads

Back
Top