11111
1 1
1 1
1 1
11111
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(j==5 || j==1 || i==1 || i==5)
printf("1");
else
printf(" ");
}
printf("\n");
}
return 0;
}
Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C
#include
ReplyDeleteint main(){
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=5;j++){
if(i==1||i==5){
printf("1");
}
else if(i==2||i==3||i==4){
if(j==1||j==5){
printf("1");
}
else{
printf(" ");
}
}
}
printf("\n");
}
}
#include
ReplyDeleteint main()
{
int r,i,j;
printf("Enter the no. of rows : ");
scanf("%d",&r);
for(i=1;i<=r;i++)
{
printf("1");
for(j=1;j<=r-2;j++)
{
if(i==1||i==r)
{
printf("1");
}
else
{
printf(" ");
}
}
printf("1\n");
}
return 0;
}
how to do above by using array
ReplyDeleteInput:
ReplyDeletesujeetsingh
Output:
sujeetsingh
s s
u u
j j
e e
e e
t t
s s
i i
n n
g g
h h
sujeetsingh
code:
||||||||||||||||||||
||||||||||||||||||||
#include
int main()
{
int i,j;
char str[11];
scanf("%s",str);
// printf("%s",str);
for(i=0;i<=11;i++)
{
if(i==0 || i==11)
{
printf("%s",str);
printf("\n");
}
for(j=0;j<=11;j++)
{
if(j==0 || j==11)
printf("%c",str[i]);
else
printf(" ");
}
printf("\n");
}
return 0;
}
1234
ReplyDelete2 4
3 4
4444
1234
ReplyDelete2 4
3 4
4444