Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write the syntax for if/else statement.

0 votes
asked Oct 31, 2018 by fazrin

9 Answers

+1 vote
answered Oct 31, 2018 by anonymous
#include <stdio.h>

int main()

declare variables;

if(write the condition here){

block of codes

}

else {

block of codes

}
+1 vote
answered Oct 31, 2018 by pankaj529 (160 points)
#include<stdio.h>

int main()

{

int n=0;

if(n=0) .   //here n= 0 so condition is true

{

printf("yes n = %d",n);

}

else

{

printf(" n  is not equal to  %d ,n);

}

}
+1 vote
answered Dec 22, 2019 by kotha kushal (560 points)

if(condition)

{

     if body;

}

else

{

     else body;

}

commented Dec 22, 2019 by kotha kushal (560 points)
super answer
0 votes
answered Dec 23, 2019 by anonymous
if(condition){

if body // code to execute if true

}

else{

else body //code to execute if false

}

//Don't need { } if code to execute is only one line. Also, can try elseif(condition){ } between if and else statements
0 votes
answered Dec 24, 2019 by Ravi Kumar (140 points)
#include<stdio.h>

int main()

{

int i;

if(write the condition )

{

statement block

}

else

{

statement block

}

return 0;

}
0 votes
answered Dec 24, 2019 by ramprasad (140 points)
#include<stdio.h>

int main()

{

int a;

printf("enter the value of a");

scanf("%d",&a);

if(a%2=0);

{

printf("the number is even number");

}

else

{

printf("odd number");

}

return 0;

}
0 votes
answered Dec 25, 2019 by siva surya (150 points)
#include<stdio.h>

void main()

{

int,a;

a=5;

if("%d",a<=4)

{

printf("enter the number of students pass");

else

printf("enter the number of students fail" );

}

}
0 votes
answered Dec 26, 2019 by Prabhuchand (180 points)
if(condition)

{

statements;

}

else

{

statements;

}
0 votes
answered Dec 28, 2019 by anonymous

if(test condition)

{   

      statement 1;         //if test condition true

             :

             :

      statement n;

}  

else

{

       statement 1;         //if test condition false

              :

              :

         statement n;

}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...