Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Saturday, January 9, 2010

Write a program in C to print " Happy Birthday " 10 times ( Using while loop , do ... while loop , for loop or statements)

This can be done in 3 different ways.

1 - way


#include<stdio.h>
main()
{
int i = 1;
while (i < = 10)
{
printf("Happy Birthday \n");
i = i +1;
}
return(0);
}


2 - way


#include<stdio.h>
main()
{
int i = 1;
do
{
printf("Happy Birthday \n");
i = i + 1;
}
while (i < = 10)
return(0);
}


3 - way


#include<stdio.h>
main()
{
int i;
for (i = 1; i < = 10; i = i+1)
{
printf("Happy Birthday \n");
}
return(0);
}


Output is same in all above 3 different loop.

Output :-
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday
Happy Birthday

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP