/* 1. Program to print the Following output.
#include <stdio.h>
int main()
{
int i, j;
//Iterates over each row one by one
for(i=1; i<=5; i++)
{
//Iterates over each column of the i-th row
for(j=1; j<=5; j++)
{
if(i==1 || i==5 || j==1 || j==5)
{
//Print star for first and last row and for first and last column
printf("*");
}
else
{
printf(" ");
}
}
//Move to the next line/row
printf("\n");
}
return 0;
}
/* 2. Program to print the Following output.
#include <stdio.h>
int main()
{
int i, j;
//Iterates over each row one by one
for(i=1; i<=5; i++)
{
//Iterates over each column of the i-th row
for(j=1; j<=20; j++)
{
if(i==1 || i==5 || j==1 || j==20)
{
//Print star for first and last row and for first and last column
printf("*");
}
else
{
printf(" ");
}
}
//Move to the next line/row
printf("\n");
}
return 0;
}
*****
* *
* *
* *
*****
*/
int main()
{
int i, j;
//Iterates over each row one by one
for(i=1; i<=5; i++)
{
//Iterates over each column of the i-th row
for(j=1; j<=5; j++)
{
if(i==1 || i==5 || j==1 || j==5)
{
//Print star for first and last row and for first and last column
printf("*");
}
else
{
printf(" ");
}
}
//Move to the next line/row
printf("\n");
}
return 0;
}
/* 2. Program to print the Following output.
********************
* *
* *
* *
********************
*/
int main()
{
int i, j;
//Iterates over each row one by one
for(i=1; i<=5; i++)
{
//Iterates over each column of the i-th row
for(j=1; j<=20; j++)
{
if(i==1 || i==5 || j==1 || j==20)
{
//Print star for first and last row and for first and last column
printf("*");
}
else
{
printf(" ");
}
}
//Move to the next line/row
printf("\n");
}
return 0;
}