Write a Program to print patten
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
using for loop , while loop and do while loop c program - Program Code
1.
Write a Program to Print Patten using for loop in c program - Program Code
/* Write a Program to print patten
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("* ");
}
printf("\n");
}
getch();
}
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("* ");
}
printf("\n");
}
getch();
}
Download Program source code
2.
Write a Program to Print Patten using while loop in c program - Program Code
/* Write a Program to print patten
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j;
clrscr();
while(i<5)
{
j=0;
while(j<5)
{
printf("* ");
j++;
}
printf("\n");
i++;
}
getch();
}
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j;
clrscr();
while(i<5)
{
j=0;
while(j<5)
{
printf("* ");
j++;
}
printf("\n");
i++;
}
getch();
}
3.
Write a Program to Print Patten using do while loop in c program - Program Code
/* Write a Program to print patten
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using do while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j;
clrscr();
while(i<5)
{
j=0;
do
{
printf("* ");
j++;
}while(j<5);
printf("\n");
i++;
}while(i<5);
getch();
}
* * * * *
* * * * *
* * * * *
* * * * *
* * * * * using do while loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j;
clrscr();
while(i<5)
{
j=0;
do
{
printf("* ");
j++;
}while(j<5);
printf("\n");
i++;
}while(i<5);
getch();
}
0 Comments
If You have any query, Please let me know..