For loop is also a type of repetition structure. This repetition structure is simpler in syntax as compared with other 2 loops because all four loop conditions can be defined in single line. Following simple program explains how to use for loop to print numbers from 1-10.
Do-while loop is also a type of repetition structure used to repeat statement(s) for certain number of times. The major difference between while and do while loop is that in do while loop the loop termination condition is checked after the execution of loop body whereas in while loop the loop termination condition is checked before the execution of loop body. Do-while loop at least runs one time no matter if the loop termination condition is true or false. Following simple program explains how to use do-while repetition structure (also called as do-while loop) to print numbers from 1-10.
Sometimes in C program we need to repeat statements for certain number of times. So in order to repeat statements for number of times we use repetition structure in C programming. There are 3 types of repetition structures available in C programming namely while, do-while and for. Following simple program explains how to use while repetition structure (also called as while loop) to print numbers from 1-10.
Switch statement is also called as multiple selection structure in C Programming. Switch selection structure is similar to if-else selection structure. The difference is instead of using multiple if-else statement we use 'cases' to check for multiple conditions. The 'default' case will run when no condition is true. The following simple c program explains how to use switch statement in c programming.
In previous post we discussed about if statement in C Programming. If-else statement called as double selection structure in C Programming. In simple words it says "Do something when a condition is true, else (when condition is false) do some other thing". Following simple c program explains how to use if-else statement in C Programming.
If statement is called as selection structure in C Programming. If statement checks a condition and proceed further depending upon the fact that whether the condition being checked is true or false. In simple words it says "Do something when this condition is true". Following simple program explains how to use if statement to compare 2 numbers entered by the user.
In our previous post we discussed about how to get values from user. Sometimes we need to define variables and assign values to those variables. This simple program explains how to define variables and how to assign values to the variables in c programming.
Sometimes in a program we need to get values from user, process the values entered by user and print / output the results of that processing on the screen. In order to get values from user we use 'scanf' function which is part of the stdio.h library. Following simple program explains how to use scanf function to get 2 numbers from user, sum the 2 entered by the user and print the sum of 2 numbers on the output screen.
In C programming we use printf function (which is part of stdio.h library) to print / output some text or variable on the screen. Following simple C program outputs a text on the screen. It also explains how to move to the new line and how to add tabbed space between words.
|
ArchivesCategories |