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