Sunday, June 26, 2011

How Use Loops in C-'While' Loops

0 comments
WHILE loops are very simple and the syntax is: while(condition) { Code to execute while the condition is true }  The true represent a boolean expression which could be while(x==1) or while(x!=7),x does not equal to 7.It can be any combination of boolean statements that are legal.Even, while(x==5||y==7) which says execute the code while x equal to 5 or y equal to 7. Example: To print numbers up to 10: #include<stdio.h> int main() { int x=0;  /*Don't forget to declare variables*/ while(x<10) /*while x less than 10*/ { printf("%d",x); x++; /*Update x ...
Continue reading →

How Use Loops in C-'FOR' Loops

0 comments
Loops are used to repeat a block of code.Loops are one of the most basic but useful task in programming.We can simply produce extremely complex out put using loops.A loops let you write a very simple statement to produce a significantly greater result  simply by repetition. FOR LOOPS: FOR loops are the most useful one.The syntax of FOR loops: for(variable initialization; condition; variable update) { code to execute while the condition is true } Example: To print numbers upto 10: #include<stdio.h> int main() {     int x;     /* ...
Continue reading →