🔒 Closed C++ problem please help po

Status
Not open for further replies.

Yang D

Enthusiast
#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

About this Thread

  • 7
    Replies
  • 689
    Views
  • 6
    Participants
Last reply from:
smurf25

Online now

Members online
1,015
Guests online
1,751
Total visitors
2,766

Forum statistics

Threads
2,275,217
Posts
28,961,536
Members
1,232,669
Latest member
dhallak879
Back
Top