Search C Program | nimishsoft@gmail.com

Number Pattern - 42

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


6 comments:

  1. #include
    int 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");

    }

    }

    ReplyDelete
  2. #include

    int 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;
    }

    ReplyDelete
  3. Input:
    sujeetsingh
    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;
    }

    ReplyDelete