Skip to main content

Posts

Showing posts with the label Control Structure
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

Switch Statement-:

A Switch case statement is a multi way decision statement, that is a simplified version of if-else block,switch statement are mostly used in two situation-: 1- When there is only one variable to evaluate in the expression. 2- When many condition are being tested for when there are many condition to test, using the "if " and " if-else " construct becomes a bit complicated and confusing,therefore switch case statement are often used as alternative to long if statement. ads The switch case expression is either an integer or character type.If the value of switch expression matches any of the constant case, the relevant code is executed and control moves out of the switch case statement.If the expression does not matches any of the constant case,then the default statement is executed.        In switch statement case and default are keyword or reserved words. Every case statement terminates with colon(;). The break statementis used to exit from current case...

if-else-if Ladder-:

C language support if-else-if   statement to test additional condition apart from the initial text expression.In this kind of statement numbers of logical statement is checked for executing various statement,if any logical statement is TRUE then compiler executes the block followed by if condition otherwise it skipes and execute else block. ads Syntax -: if (condition-1) statement-1; else if (condition-2) statement-2; else if (condition-3) statement-3; else statement-4; } Example -: #include<stdio.h> #include<conio.h> main() {char ch;    printf("Enter any character");    scanf("%c",&ch);     if (ch>=65)&&(ch<=90)    printf("%c is an alphabet in uppercase",ch);    else if (ch>=97)&&(ch<=122)    printf("%c is an alphabet in lower case",ch);    else if (ch>=48)&&(ch<=57)    printf("%c is a digit",ch);    el...

Nested if-:

Nested of 'if ' means one ' if '  is enclosed with in another ' if '.  In nested if , every ' if '  have an else statement.   Syntax -: if(condition)   if(condition)   statement-1;   else   statement-2; else statement-3; } ads Example -: #include<stdio.h> #include<conio.h> main() { int a=0,b=0,c=0;    printf("Enter the value of a,b,c);    scanf("%d %d %d",&a,&b,&c);    if(a>b)      {if(a>c)      printf("\n %d is largest",a);      else      printf("\n %d is largest",c);      } else if(b>c)  printf("\n %d is largest",b); else printf("\n %d is largest",c); getch(); } output -: Enter the value of a,b,c 10                15                 22             ...

if-else Statement-:

if-else statement is a conditional statement which allows us to select and execute one statement or a group of statement out of two available statements or group of statements depending upon the truthfulness of a condition. ads Syntax -:  if(condition) statement-1; else statement-2; or, if(condition); { statement-1;   statement-2;   statement-3;     -     -     -   statement-n; } else {statement-1;    -    -    - statement-n; } ads Example -: #include<stdio.h> #include<conio.h> main() {int num=0; printf("Enter the value of num"); scanf("%d",&num); if(num%2==0) printf("\n Even number"); else printf("\n odd number); getch(); } output-:Enter the value of num 15                odd number Watch The Video Below

if-Statement-:

The if statement is simplest form of decision control statement i.e. frequently used in decision making.The syntax of if statement is as follow-: syntax -: if(condition)                statement; or if(condition) {statement-1;   statement-2;   statement-3;    -    -    -    statement-n; } From above syntax if the condition is TRUE,then the statement will execute or a block of statement-1 to statement-n will execute. ads Example -: #include<stdio.h> #include<conio.h> main() {int num=0;   printf("Enter The Value of num");   scanf("%d",&num);   if(num%2==0)   printf("\n %d is an  Even Number",num);   getch(); } output -:Enter The Value of num 30               30 is an Even Number ads Watch The Video Below

Control Structure-:

Decision Control Statements We know that the code in C programming executed sequentially from the first line of the program to its last line.In some case we want only selected statements,to be executed,this can be done through decision control statement also called conditional branching statement. The decision control statement are as follow-: (a-) if statement  CLICK HERE (b-) if-else statement CLICK HERE (c-) Nested if  CLICK HERE (d-) if-else ladder CLICK HERE (e-) switch statement CLICK HERE ads Watch The Video Below   

Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey