Today, we will learn about Control Statements in C – programming.
There are two types of Conditional statements present and those are listed in above image.
- Iterative (for, while and do..while).
- Non – Iterative.
i . Conditional (goto, break, return, continue).
ii. Unconditional (if, if…else, nested…if, switch case).
Definition : Controlling the flow of execution of program that called..
So, we will discuss each of them and try to understand how they work.
- if :
In above example loop will be called as a dumy because, due to semi colon it will not enter in to the loop.
Example: Write a program to scan character from the user and print it’s ASCII value.
char ch; //variable declaration
printf(“Enter the character : “);
if( ch >= ‘a’ && ch <= ‘z’)
printf(“ch = %c its ASCII value is %d \n”,ch, ch);
Answer : Enter the character : a
ch = a its ASCII value is 97
TODO: Check the character whether it’s an upper case or lower case using if loop.