Control Statement in C Programming

20 Aug 2022 Balmiki Mandal 0 C Programming

Mastering Control Statements in C Programming

Control statements are used for controlling the execution of flow, by Default statements are Executed in sequence, one after another

Purpose of control statements

  • To Control program flow
  • To Control program flow Execution

Control Statements are two types

  1. iterative control statement
  2. No-iterative control statements

Iterative control statements:

A Statement which are in loops is called iterative controls statements, once the conditions is false the control come out of the loop.

iterative control statements are three Types

  1. for
  2. while
  3. do while 

Non-iterative control statements:

Statements are not Based on a loop, it's based on conditions true or False, if True Execute Treue statements if Fales execute False statements.

No-iterative control statements are two types

  1. unconditional
  2. conditional 

 

Unconditional non-iterative controls statements:

it's a Non-iterative also but it has no condition whatever we mention or pointer just control go over it.

unconditional is four types

  • go-to
  • break
  • return
  • continue

 

Conditional Non-iterative control statements:

it follows the conditions mean true or False if true go with the true condition if false go with the false condition.

conditional Non-iterative control statements are five type

  1. if
  2. if-eles
  3. else if ladder
  4. ladder if
  5. switch case

If Statements:

if is a conditional Non-iterative control statement

Syntax:     

if(EXP \ Variable \ Constatnt)
{
statements.....
}

 Program 01: Write a c programming using if

#include<stdio.h>
int main()
{
printf("hello....\n");
if(0)
printf("hai..\n");
printf("bye...\n");
}

output: 

if(1) :  hello  hai   bye
if(0):   hello    bye

Some Programs are based on conditions

  • Write A program to scan a character from the user and display that character and its ASCII value only if the given input is small later.
  • Write a program to scan a character from the user and display the given character in lower case and uppercase
  • write the program form student marks.

 

Nested If of if else ladder: 

syntax:

if(Exp)
{
       if(exp)
              { 
               if(exp)
                     {
                         ....

                     }  
             }
}

 

Write a program for student database

Write A program to scan a number and bits position from the user after that display a menu for the options 1. set bit 2. clear bit 3. compliment a bit scan and options from the user depends on the options provided by the user perform the task and display the result.

To be contine click once

Switch and case:

 

Go-to control statements in c programming

Further Reading:

 For further information and examples, Please visit[ C-Programming From Scratch to Advanced 2023-2024]

 

 

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.