Control Statements in C | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

Control Statements in C

Date- Dec 09,2023

1429

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.

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
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 | 1190
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 Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts