Skip to main content

Conditional statement in c language

Conditional statement


This is very simple.you face these problem daily.if you want to go to market and go to park .
But at a time you can go only one place either market or park.
In programming you also face these problems.

These are given below

1.if
2.if-else
3.if-else-if
4.nested if

If statement-

statement is execute when condition is true other wise it will terminated from loop.
#include<stdio.h>
int main( )
{
if(condition)
          {
             statement;
          }
}

FLOW CHART OF IF STATEMENT-

2.if-else statement-

general syntax of if-else statement-

#include<stdio.h>
int main( )
{
if(condition)
{
statement1;
}
else
{
statement 2;
}

EXPLAINATION-
if condition true than  statement 1 execute otherwise it will be terminated.

flow chart of if-else-


3.if-else-if

General  syntax of if else if
#include<stdio.h>
int main( )
{
if(condition1)
{
statement1;
}
else if(condition 2)
{
statement 2;
}
 else
{ statement 3;
}

Explaination

if the condition1 is true than statement1 is execute or condition2 is true than statement2 is execute otherwise statement 3 will be execute.


flow chart-

4.nested-

general syntax of nested-
if (testExpression1) 
{
   statement1;
}
else if(testExpression2) 
{
   statement2;
}
else if (testExpression 3) 
{
    statement3;
}

else 
{
    statement4;
}

thanks.


Comments

Popular posts from this blog

top 10 youtuber of india

        TOP 10 YOUTUBER OF INDIA we are live in that age where everyone is know about youtube.Most of the people open youtube minimum twice in a day. Competition on youtube is so high that people are judge other people by know that which channel he visit. In india jio telecom increase the lavel of youtube. 1.AMIT BHADANA current subscribers-13M TYPE OF CHANNEL-comedy 13 millions is not a just a small number.Amit is very popular everywhere city or village. Amit has a big no of followers. the good things about there videos is that he never use a single words of abuse. we love him. 2.BB KI VINES-BHUVAN BAM current subscribers-12M TYPE OF CANNEL-comedy now come the best youtuber of student specially engineers. in his videos he play many role that is extra ordinary.his comedy is super he has a very good sense of humour.he is very stylish. 3.GOURAV- CHANNEL NAME- TECHNICAL GURUJI               ...

solution of-BOMARBLE - D - Playing with Marbles on spoj

BOMARBLE - D - Playing with Marbles Pablo was assigned in his class to construct pentagons inside pentagons with marbles but he doesn’t know how many marbles he will need. He knows that for one pentagon he needs 5 marbles The only way he knows to insert a second pentagon is putting a marble in the middle of each segment and drawing three lines as shown. He puts a marble in the intersecting lines and removes them. To insert a third pentagon inside he first divides all segments in two including the ones that are not needed, and repeats the procedure. Drawing a second pentagon will require 12 marbles. A third pentagon will require 22 marbles. Given the information of how many pentagons will be created, write a program to calculate the number of marbles needed. solution- #include<stdio.h> int main() {int n,k; while(scanf("%d",&n)!=EOF) { if(n==0) break; else { k=5*n+((n-1)*(3*n-2))/2; printf("%d\n",k); } ...