Posts

Showing posts from May, 2023

Loop control statement

Image
Table of Content Introduction of loop Types of loop while loop do while loop for loop nesting of loop infinite loop odd loop difference between while loop and do while loop Introduction of loop  Loop are used when we want to execute a block of statement or a part of program at multiple times. suppose a program to print " hello world " 20 times. one way to get the desired output using printf statements, which is bad programming skill or not preferable . other way we can use loop to print the "hello world " easily.   Now I can demonstrate to you print " hello world " without using loop. /*Program to print "hello world" without using loop*/ #include <stdio.h> int main() {     printf( "hello world\n" );     printf( "hello world\n" );     printf( "hello world\n" );     printf( "hello world\n" );     printf( "hel...

if-else statement

Image
Table of Content Decision control Statement if-else statement if statement Nesting of if-else Dangling else problem else-if ladder If-else statement C uses the keyword if and else to implement the decision control statement. The general form of this statement look like this: Syntax:                       if(expression)                      statement1;                 else                      statement2; The expression inside the parenthesis is evaluated and  if it is true(Non-zero value), then state...