Problem: Program to print 'Hello' 5 times.
Using while
#include<stdio.h>
int main() {
int i = 1;
while(i<=5){
printf("Hello\n");
i++;
}
return 0;
}
int main() {
int i = 1;
while(i<=5){
printf("Hello\n");
i++;
}
return 0;
}
Using do-while
#include<stdio.h>
int main() {
int i = 1;
do{
printf("Hello\n");
i++;
}while(i<=5);
return 0;
}
int main() {
int i = 1;
do{
printf("Hello\n");
i++;
}while(i<=5);
return 0;
}
Using for
#include<stdio.h>
int main() {
int i;
for(i=1;i<=5;i++){
printf("Hello\n");
}
return 0;
}
int main() {
int i;
for(i=1;i<=5;i++){
printf("Hello\n");
}
return 0;
}