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
2 - way
3 - way
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
1 - way
#include< main() { int i = 1; while (i < = 10) { printf("Happy Birthday \n"); i = i +1; } return(0); } |
---|
2 - way
#include< main() { int i = 1; do { printf("Happy Birthday \n"); i = i + 1; } while (i < = 10) return(0); } |
---|
3 - way
#include< 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
0 comments:
Post a Comment