Delicious Digg Facebook Favorites More Stumbleupon Twitter

Tuesday 28 August 2012

program for while loop


                        Program for while loop 

             syntax :-
                                 while(condition)
                                {
                                    statements;
                                    incrementation/decrementation;
                                 }
 
                 Example  for printing 1 to 10 :-
           
                                #include<stdio.h>
                                main()
                                {
                                   int i=1;
                                   clrscr();
                                   while(i<=10)
                                    printf("%d\n",i++);
                                    getch();
                                 }
                 
                output :-    1
                                  2
                                  3
                                  4
                                  5
                                  6
                                  7
                                  8
                                  9
                                10

0 comments:

Post a Comment