Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

my question is related to pattern

0 votes
asked May 1, 2018 by Kashyap 1 flag
4

33

222

1111

222

33

4

1 Answer

0 votes
answered May 5, 2018 by mohana mona
#include <stdio.h>

int main()
{
    int i,j,n=4,k=1;
    for(i=1;i<=4*2-1;i++)
    {
        for(j=1;j<=k;j++)
        {
            printf("%d",n);
        }
        if(i<4)
        {
            n--;
            k++;
         }
        else
        {
            n++;
            k--;
        }
     printf("\n");
    }
}
commented May 9, 2018 by anonymous
import java.util.Scanner;
public class Main
{
    public static void main(String[] args) {
        System.out.println("Enter an odd number: ");
        Scanner sn=new Scanner(System.in);
        int num=sn.nextInt();
        int strt=(num+1)/2;
        for(int j=1;j<=num;j++){
            if(j<=(num+1)/2){
                
                for(int k=1;k<=j;k++){
                    System.out.print(strt-j+1);
                }
            }
            else{
                for(int k=1;k<=num+1-j;k++){
                    System.out.print(j-strt+1);
                }
            }
           System.out.println();
        }
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...