Login Register
Code2night
  • Home
  • Blog Archive
  • Tutorial
  • Interview Q&A
  • Languages
    • Angular
    • C
    • c#
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • Security
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
    • SEO Analyzer
  1. Home
  2. Blog
  3. Control Statements in C

Control Statements in C

Date- Dec 09,2023

3044

In C, control statements are used to control the flow of program execution based on certain conditions or loops. These statements allow you to make decisions and repeat actions in your code.Here are some of the key control statements in C:

1.Conditional Statements:
  • if Statement: It is used to execute a block of code if a specified condition is true.
    
    if (condition) {
        // Code to be executed if the condition is true
    }
    
    
    
  • if-else Statement: It allows you to execute one block of code if the condition is true and another block if it's false.
    
    if (condition) {
        // Code to be executed if the condition is true
    } else {
        // Code to be executed if the condition is false
    }
    
    
    
  • else-if Ladder: You can use multiple else if conditions to handle multiple possibilities
    
    if (condition1) {
        // Code to be executed if condition1 is true
    } else if (condition2) {
        // Code to be executed if condition2 is true
    } else {
        // Code to be executed if no condition is true
    }
    
    
    
2.Switch Statement: The switch statement allows you to select one of many code blocks to be executed.

switch (expression) {
    case constant1:
        // Code to be executed if expression equals constant1
        break;
    case constant2:
        // Code to be executed if expression equals constant2
        break;
    // More cases...
    default:
        // Code to be executed if expression doesn't match any case
}


3.Looping Statements:
  • for Loop: It is used for executing a block of code a specific number of times.
    
    for (initialization; condition; increment/decrement) {
        // Code to be executed in each iteration
    }
    
    
    
  • while Loop: It executes a block of code as long as a specified condition is true.
    
    while (condition) {
        // Code to be executed while the condition is true
    }
    
    
    
    
  • do-while Loop: Similar to the while loop but ensures that the code block is executed at least once, as the condition is checked after the code block.
    
    do {
        // Code to be executed at least once
    } while (condition);
    
    
    
Jump Statements:
  • break: Used to exit a loop prematurely.
  • continue: Used to skip the current iteration of a loop and continue to the next iteration.
  • return: Used to exit a function and return a value.

S
Shubham Saini
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Unconditional statements in C
Sep 21, 2023
What is C?
Dec 31, 2022
Swich Statement in C
Sep 23, 2023
2-D Array in C
Sep 25, 2023

Comments

Contents

More in C

  • Chapter-1 (Introduction of C) 3525 views
  • Check if the character is a vowel or a consonant. 3481 views
  • Chapter-5 (format specifier in c) 3391 views
  • Chapter-3 (Input/Output functions in C) 3318 views
  • Chapter-4 (Operators in C) 3143 views
View all C posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
  • SEO Analyzer
By Language
  • Angular
  • C
  • c#
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page