C Interview Programs to print number patterns

by Madhulika Reddy on April 8, 2009


c interview questions This post has few of basic number pattern programs in C. Question.56(multiplication table) tests the ability to convert an elementary algorithm into a program. Question.57, Question.58 are programs that test the ability of candidate to use nested while/for loops to print special number patterns. Question.59, Question.60 test ability of using simple while/for loops and basics of formatting using printf statement. See all C interview questions in this blog in one page.

Also Read:

Showing 5 out of 65 C Interview Questions.

C Language Interview Questions (56 to 60)
  1. Write a program to display the multiplication table of a given number.
  2. Write C program to print the following pattern:
             1
            2 2
           3 3 3
          4 4 4 4
         5 5 5 5 5
  3. Write C program to print the following pattern:
             1
           1 2 1
         1 2 3 2 1
       1 2 3 4 3 2 1
     1 2 3 4 5 4 3 2 1
  4. Write a C program to display the following format:
    ------
      a b
    ------
      1 5
      2 4
      3 3
      4 2
      5 1
     ------
  5. Write a C program to display the following format:
    --------
     no. sum
    --------
      1  1
      2  3
      3  6
      4  10
      5  15
     --------

  1. Write a program to display the multiplication table of a given number.
  2. Program: Multiplication table of a given number

    #include <stdio.h>
    int main() {
          int num, i = 1;
          printf("\n Enter any Number:");
          scanf("%d", &num);
          printf("Multiplication table of %d: \n", num);
          while (i <= 10) {
                printf("\n %d x %d = %d", num, i, num * i);
                i++;
          }
          return 0;
    }

    Download Code

    Output:

    Enter any Number:5
     5 x 1 = 5
     5 x 2 = 10
     5 x 3 = 15
     5 x 4 = 20
     5 x 5 = 25
     5 x 6 = 30
     5 x 7 = 35
     5 x 8 = 40
     5 x 9 = 45
     5 x 10 = 50

    Explanation: We need to multiply the given number (i.e. the number for which we want the multiplication table) with value of ‘i’ which increments from 1 to 10.

    Back to top

  3. Write C program to print the following pattern:
  4.          1
            2 2
           3 3 3
          4 4 4 4
         5 5 5 5 5

    Program:

    #include<stdio.h>
    int main() {
        int i, j, k, c = 5;
        for (i = 1; i <= 5; i++) {
                /* k is taken for spaces */
                for (k = 1; k <= c; k++) {
                      /* blank space */
                      printf(" ");
                }
                for (j = 1; j <= i; j++) {
                      /* %2d ensures that the number is printed in
    two spaces for alignment and the numbers are printed in the order. */
                      printf("%2d", i);
                }
                printf("\n");
                /*c is decremented by 1 */
                c--;
          }
          return 0;
    }

    Download Code

    Output:

             1
            2 2
           3 3 3
          4 4 4 4
         5 5 5 5 5

    Explanation: Here ‘i’ loop is used for printing the numbers in the respective rows and ‘k’ loop is used for providing spaces. ‘j’ loop prints the numbers. ‘c’ is decremented for numbers to be displayed in alternate columns.

    Back to top


  5. Write C program to print the following pattern:
  6.          1
           1 2 1
         1 2 3 2 1
       1 2 3 4 3 2 1
     1 2 3 4 5 4 3 2 1

    Program:

    #include<stdio.h>
    int main() {
          /* c taken for columns */
          int i, j, c = 9, m, k;
          for (i = 1; i <= 5; i++) {
                /* k is used for spaces */
                for (k = 1; k <= c; k++) {
                      printf(" ");
                }
                for (j = 1; j <= i; j++) {                   printf("%2d", j);             }             for (m = j - 2; m > 0; m--) {
                      /* %2d ensures that the number
                       * is printed in two spaces
                       * for alignment */
                      printf("%2d", m);
                }
                printf("\n");
                /* c is decremented by 2 */
                c = c - 2;
          }
          return 0;
    }

    Download Code

    Output:

             1
           1 2 1
         1 2 3 2 1
       1 2 3 4 3 2 1
     1 2 3 4 5 4 3 2 1

    Explanation: Here ‘i’ loop is used for printing numbers in rows and ‘k’ loop is used for providing spaces. ‘j’ loop is used for printing numbers in increasing order. ‘m’ loop is used for printing numbers in reverse order.

    Back to top

  7. Write a C program to display the following format:
  8. ------
      a b
     ------
      1 5
      2 4
      3 3
      4 2
      5 1
     ------

    Program:

    #include<stdio.h>
    int main() {
          int i = 1, j = 5;
          printf("----------\n");
          printf("a \t b \n");
          printf("----------\n");
          /* logic: while loop repeats
           * 5 times i.e. until
           * the condition i<=5 fails */
          while (i <= 5) {
                /* i and j value printed */
                printf("%d \t %d\n", i, j);
                /* i and j value incremented
                 by 1 for every iteration */
                i++;
                j--;
          }
          printf("----------");
          return 0;
    }

    Download Code

    Output:

    ------
      a b
     ------
      1 5
      2 4
      3 3
      4 2
      5 1
     ------

    Explanation: Here, ‘i’ is initialized to least value 1 and ‘j’ initialized to highest value 5. We keep incrementing the i’ value and decrementing the ‘j’ value until the condition fails. The value is displayed at each increment and at each decrement. Back to top

  9. Write a C program to display the following format:
  10. --------
     no. sum
     --------
      1  1
      2  3
      3  6
      4  10
      5  15
     --------

    Program:

    #include<stdio.h>
    int main() {
          int num = 1, sum = 0;
          printf("-----------\n");
          printf("num \t sum\n");
          printf("-----------\n");
          /* while loop repeats 5 times
           *  i.e. until the condition
           *  num <= 5 fails */
          while (num <= 5) {
                sum = sum + num;
                printf("%d \t %d\n", num, sum);
                /* num incremented by 1
                 * for every time
                 * the loop is executed */
                num++;
          }
          printf("-----------");
          return 0;
    }

    Download Code

    Output:

    --------
     no. sum
     --------
      1  1
      2  3
      3  6
      4  10
      5  15
     --------

    Explanation: In the above program we have taken two variables ‘num’ and ‘sum’. ‘num’ is used to check the condition and to display the numbers up to 5. ‘sum’ is used to add the numbers which are displayed using variable ‘num’. The ‘sum’ value is initialized to zero. sum is added to the numbers which are incremented by ‘i’ and displayed.

    Back to top

Over 1600 professionals follow Interview Mantra.


About the Author:  This post was written by Madhulika Reddy. You can connect with Madhulika on Orkut.


2,250 readers have already subscribed to email updates!

Enter your email address:

  • http://www.interviewmantra.net Sridhar

    Now applied syntax highlighter to all the code in this page

    -Sridhar

  • http://www.interviewmantra.net Sridhar

    Experimentally implemented C Syntax highlighter to program in question 56(Program to print multiplication table). Sorry about the inconsistency in the code formatting. Just testing this syntax highlighter (http://alexgorbatchev.com)

    If this goes fine, will apply syntax highlighter to all the code in this blog. Dear reader, what do you think?

    Sridhar,
    - Editor of Interview Mantra

  • swati

    hey i need a source code for the follwing format
    _______1
    _____1___2
    ___1___2___3

    and also for..

    _____________1
    __________1_____1
    ________1_________1
    ______1_____________1

    where __ is spaces

  • Payal

    i want the following output.
    1________1
    1 2_____2 1
    1 2 3__3 2 1
    1 2 3 4 3 2 1

  • Amrutha

    i want the c code for the following output.

    1________1
    1 2_____2 1
    1 2 3__3 2 1
    1 2 3 4 3 2 1

    i use “_”to represent spaces.

  • admin

    @Amrutha,
    The question you have asked is similar to this question in my blog. Check it out. I think you will be able to write the logic for producing 1,2,3 easily and get desired output. Let me know if you have any problems.

  • http://porntube.kradou.cz Nye

    Thanks to those who hated me, they made me a stronger person.

  • swamy

    i really appreciate for ur information it is very help full for freshers its very good. can u tell please in c can we do graphical representation, if we can how tell me, and one more thing u can we same pattern for data structures and c++

  • ramana reddy

    how can find out first 3 biggest numbers with using one single iteration and with out using any sorting tech
    ex:
    58
    5
    666
    696
    659
    996
    589
    197
    3
    998



    6
    695

    847
    474

  • somnath

    1
    1 2
    1 2 3
    1 2 3 6
    1 2 3 6 12 what the logic??????????

  • Nishant jain

    what will be the logic of following pattern?
    0
    1 0
    1 0 1
    0 1 0 1
    0 1 0 1 0
    1 0 1 0 1 0 1

  • Rushabh

    *__ *__ *
    *_ *_ *
    ***

    I want code logic for the above method where ( _ ) indicates Space.

  • mohsin vajir mulani

    1)create application to display structure in visual basic simple code
    output is given
    1
    2 3
    4 5 6
    7 8 9

  • http://www.google.com vaibhav

    1 2 3 4 5 4 3 2 1
    2 3 4 5 5 4 3 2
    3 4 5 5 4 3
    4 5 5 4
    5 5

  • http://www.google.com vaibhav

    i want c coding of following
    1 2 3 4 5 4 3 2 1
    2 3 4 5 5 4 3 2
    3 4 5 5 4 3
    4 5 5 4
    5 5

  • http://google ramya theja

    program code to search for keyword in square grid of alphabets

  • http://google ramya theja

    give the program code to search a keyword in square grid of alphabets.

  • Madhuri

    I want c program of this pattern
    1
    23
    456
    78910
    1112131415

  • varun

    hey i want following code for program
    1
    23
    456
    78910

    if u have code plz mail me on my mail id…….

  • http://c-programing shivangishukla

    nathing

  • sachin bhanushali

    what is logic of following pattern?
    12345
    2345
    345
    45
    5

  • sachin bhanushali

    what is logic of following pattern?
    1
    01
    010
    1010
    10101

  • sachin bhanushali

    what is logic of following pattern?
    1
    10
    101
    1010
    10101

  • harshil

    i need this pattern without the help of nesting of for loops.
    *
    **
    ***
    ****
    *****
    can u do guyz?

  • Nikhil

    i want the code for pattern
    1234 5 4321
    2345 5432
    345 543
    45 54
    5 5

  • hemal shanischra

    1
    23
    456
    78910

    use for loop
    ans. mail in my acount

  • sai charan

    1
    232
    34543
    4567654

  • Keeran

    hi,cud u help with,when we pass 2alphabets the it shud prnt in pattern of star like ex-SK
    *** * *
    * * *
    *** * *
    * * *
    *** * *

  • Keeran

    *** * *
    * * *
    *** * *
    * * *
    *** * *

  • sia

    help me with 1
    121
    12321
    121
    1 upto N rows

  • Aman

    how did this pattern formed
    *_____*
    **___**
    ***_***
    *******
    where “_” is space??

  • v.prathyusha

    @swati
    1. #include
    void main()
    {
    int i,j,nos=4,s;
    clrscr();
    for(i=1;i=1;s–)
    printf(” “);
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    printf(" ");
    }
    printf('\n");
    –nos;
    }
    }
    2. #include
    void main()
    {
    int i,j,nos=4,s;
    clrscr();
    for(i=1;i=1;s–)
    printf(” “);
    for(j=1;j<=i;j++)
    {
    printf("1");
    printf(" ");
    }
    printf('\n");
    –nos;
    }
    }

  • abhishek

    1
    2 3
    4 5 6
    7 8 9 10

  • PARNEET

    i want the code for ABCDEFEDCBA
    ABCDE EDCBA
    ABCD DCBA
    ABC CBA
    AB BA
    A A

  • http://solmri.com expert coder

    @harshil
    Its easy to print
    *
    **
    ***
    ****
    *****

    #include

    int main()
    {
    int i,j;

    for(i=1;i<=5;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("*");
    }
    printf("\n");
    }
    }

  • prakash

    i like this….

  • http://google keerthi

    i am so satisfied with ur websit
    and thank u a lot.
    and make this website available to more members.
    try to make it more efficient better than now.
    thanks a lott ur website
    good answers

  • Manikantha

    can any one tell how to print this pattern??????????
    01 02 03 04 05
    16 17 18 19 06
    15 24 25 20 07
    14 23 22 21 08
    13 12 11 10 09

  • simant

    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************

  • simant

    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************
    ************

  • s siva prasad reddy

    please anyone tell me program to print
    1=1
    1+2=3
    1+2+3=6
    1+2+3+4=10

  • http://yahoo sarvesh

    1
    212
    32123
    4321234
    32123
    212
    1

  • aswin vp

    thankyou. Very helpfull site.

  • tchoujar

    1
    23
    4567
    89101112131415

    could u help me with this, the no of elements in a line is double the no in the prev line

  • amar

    i want to this structure programming in c
    5
    45
    345
    2345
    12345

  • geetha

    write a c program to follow the pattern
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5

  • foram

    hey geetha here is ur answer
    void main()
    {
    int i,j;
    clrscr();
    for(i=1;i<=5;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    }
    printf("\n");
    }
    getch();
    }

  • Abhi

    help me ta print this..
    1
    3 5
    7 11 13
    17 19 21 29

  • shrutika

    to print this pattern??????????
    01 02 03 04 05
    16 17 18 19 06
    15 24 25 20 07
    14 23 22 21 08
    13 12 11 10 09

  • farooq

    hey can some one help me in printing the patterns as
    if N = 4
    1 1 1 1
    1 1 2
    2 2
    1 3
    n = 5
    1 1 1 1 1
    1 1 1 2
    1 1 3
    1 2 2
    like that all numbers should be printed

  • sandeep

    im sandeep………………
    can you provide me a logic for
    1
    01
    010
    1010
    10101

  • vishal rami

    gr8 dear i use dis all patten in my computer lab n i got output so i thanx full to u for giving me such gud code thanx buddy .
    bye tc ………………

  • jaspreet

    print this

    4 4 4 4
    3 3 3
    2 2
    1

  • ravikiran

    how to print the o/p as follows
    1 2 3
    1 2
    1
    1 2
    1 2 3

    pls let me know how to write it?

  • ashwini

    hi i am ashwini

    can you provide me a logic for
    1
    01
    010
    1010
    10101

  • preethi

    give the code to get
    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5

  • stranger

    // preeti
    #include
    #include
    int main()
    {
    int i,j,k;
    for(i=1;i<6;i++)
    {
    //for(k=0;k<
    for(j=i,k=i;k<=i+i-1;k++)
    {
    printf("%d",j);
    }
    printf("\n");
    }
    getch();
    }

  • stranger

    #include
    #include
    int main()
    {
    int i,j,k;
    for(i=1;i<6;i++)
    {
    //for(k=0;k<
    for(j=i,k=i;k<=i+i-1;k++)
    {
    printf("%d",j);
    }
    printf("\n");
    }
    getch();
    }

  • stranger

    ad header file name i tried bt it printing here

  • helper

    please give me program for the following pattern.
    1
    23
    456
    7890
    12345

  • aditya

    print this
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1

  • subham

    can ne 1 provide the code for this pattern?????????
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1

  • manish

    wap to display table of n from 1 to m.

  • vikee singh

    \\helper
    #include
    void main()
    {
    int count=1,j,i;
    for(i=1;i<=5;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",count);

    count=count+1;
    if(count==10)
    count=0;
    }
    printf("\n");
    }
    }

  • vikee singh

    //ravi sankar
    #include
    void main()
    {
    int i,j,count=3;
    for(i=1;i<=5;i++)
    {
    for(j=1;j=3)
    count++;
    else
    count–;
    }
    }

  • smrithi

    Write a C program to print the following pattern.
    1
    1 2
    1 2 3
    1 2 3 4

  • Mukesh

    How to provide [assword to c and c++ programme files????
    rg
    my file is mypc.cpp
    i provide password to this file…

  • veena

    pls give me code to print
    1=1
    1+2=3
    1+2+3=6
    1+2+3+4=10
    1+2+3+4+5=15
    vna.b.tech@gmail.com

  • Stranger

    #include
    void main()
    {
    int i,j,k;
    for(i=1;i<6;i++)
    {
    k=0;
    for(j=1;j<=i;j++)
    {
    k=k+j;
    printf("%d",j);
    if(j!=i)
    printf("+");
    }
    printf("= %d \n",k);
    }
    }

  • Stranger

    MUKESH

    you can use unix code to provide password if u want that i cn write it

  • sri

    can some1 provide me d c++ code for this pattern??
    1
    11
    21
    1211
    111221

  • ravi

    how to print
    *
    * *
    * * *
    * * * *

  • Ronak Patel

    print this in c language….
    01 02 03 04
    12 13 14 05
    11 16 15 06
    10 09 08 07

    “pattern move in scream”

  • foram

    plz give me source code of this pattern
    1
    01
    010
    1010
    10101

  • Rajitha

    Program of this output::
    4444
    333
    22
    1

    #include
    #include
    main()
    {
    int i,j;
    clrscr();
    for(i=4;i0;i–)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",i);
    }
    printf("\n");
    }
    getch();
    return 0;
    }

  • Rajitha

    Coding of this pattern
    *
    **
    ***
    ****
    #include
    #include
    main()
    {
    char i;
    int k,j;
    i=’*';
    clrscr();
    for(k=1;k<=4;k++)
    {
    for(j=1;j<=k;j++)
    {
    printf("%s",&i);
    }
    printf("\n");
    }
    getch();
    return 0;

  • Rajitha

    can any one code for this pls
    4 4
    3 3 3 3
    2 2 2 2 2 2
    1 1 1 1 1 1 1 1
    0 0 0 0 0 0 0 0 0
    1 1 1 1 1 1 1
    2 2 2 2 2
    3 3 3
    4

  • Rajitha

    4 – - – - – - – - 4
    3 3 – - – - – 3 3
    2 2 2 – - – 2 2 2
    1 1 1 1 -1 1 1 1
    0 0 0 0 0 0 0 0 0
    1 1 1 1 1 1 1
    2 2 2 2 2
    3 3 3
    4

  • nitish gupta

    o
    101
    21012
    3210123
    432101234
    54321012345
    432101234
    3210123
    21012
    101
    0

  • amit sisodiaa

    so helpful yaar

  • http://bully_amy@yahoo.com Rashi Agarwal

    T
    TM
    TMI
    TMIM
    TMIMT
    TMIM
    TMI
    TM
    T

  • Praveen

    This is the wonderful blog….and helped me very well in getting all the questions at a glance…..
    thanx to the Team

  • Shashi Arjula

    Hi Folks,

    Can anyone help me to get the code of following program:

    4 – – – – – – – – 4
    3 3 – – – – – 3 3
    2 2 2 – – – 2 2 2
    1 1 1 1 -1 1 1 1
    0 0 0 0 0 0 0 0 0
    1 1 1 1 1 1 1
    2 2 2 2 2
    3 3 3
    4

    Thanking you genius !

    Cheers,
    Shashi Arjula
    91 9966667299

  • jay

    please give me code for to print like this…
    suppose n=4…then

    1 2 3 4
    8 7 6 5
    9 10 11 12
    16 15 14 13

  • Vijay G

    @jay

    #include
    #include
    void main()
    {
    int i,j,nxt=1,n;
    printf(“Enter the no. of rows to be printed : “);
    scanf(“%d”,&n);
    for(i=1;i<=n;i++)
    {
    for(j=1;j<=n;j++)
    {
    printf("%-4d",nxt);
    nxt=nxt+1;
    }
    printf("\n");
    }
    }

  • Vijay G

    @ Shashi Arjula

    #include
    #include
    void main()
    {
    int j,n,x,k=0;
    printf(“Enter the no. of digits to be printed in 1st row : “);
    scanf(“%d”,&n);
    printf(“Enter the Starting number for sequence(1 to 9): “);
    scanf(“%d”,&x);
    while(n>0)
    {
    for(j=1;j<=n;j++)
    {
    printf("%d",x);
    }
    n=n-2;
    if(k==0)
    x=x-1;
    else
    x=x+1;
    if(x==0)
    k=1;
    printf("\n");
    }
    }

    I have given the code for generalized format. Give input as n=17 and x=4

    Njoy !!!!

  • Vijay G

    @ Jay

    In the previous post I was confused and gave the code for
    1 2 3 4
    5 6 7 8
    9 10 11 12
    13 14 15 16
    ——————————————————————————–
    Find the code written below for your actual problem

    #include
    #include
    void main()
    {
    int arr[10][10];
    int i,j,k,n;
    int num=1;
    printf(“\nEnter the number : “);
    scanf(“%d”,&n);
    for(i=0;i<n;i++)
    {
    if(k==0)
    {
    for(j=0;j=0;j–)
    {
    arr[i][j]=num;
    num=num+1;
    k=0;
    }
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=0;j<n;j++)
    {
    printf("%-3d",arr[i][j]);
    }
    printf("\n");
    }
    }

  • shraisy

    aditya: the pattern will be printed by the following code

    #include
    void main()
    {
    int a=1;
    int i;
    clrscr();
    printf(“%d”,a);
    for(i=1;i<5;i++)
    {
    a*=11;
    printf("\n%d",a);
    }
    getch();
    }

  • http://www.rediff.com umesh singh kushwaha

    #include
    #include
    void main()
    {
    int a,b,c;
    a=10;
    b=20;
    c=a+b;
    printf(“%d”,c)
    getch();
    }

  • marklechugs

    help me, i need a program for these patterns

    A.) n=3
    ***
    ***
    ***

    B.) n=3
    *_*
    _*_
    *_*

    n=4
    *_*_
    _*_*
    *_*_
    _*_*

    C.) n=3
    ***

    ***

    n=4
    ****
    —-
    ****
    —-

  • ivy

    how can i print this pattern

    4321
    321
    21
    1

  • ravi

    4567654
    34543
    232
    1

  • nilesh

    print this
    1234567
    123 567
    12 67
    1 7

  • Sidharth Chaudhri

    Please give code for this pattern:

    5432112345
    5432 2345
    543 345
    54 45
    5 5
    5 5
    54 45
    543 345
    5432 2345
    5432112345

  • me

    for this pls
    *
    * *
    * *
    **********

  • http://google xxxx

    how to write a c program to print the below format:
    1
    1 1
    1 1 1
    .
    .
    1 1 1 1. . . . . . . . . n

  • Aashish

    //Ravikiran

    #include
    #include
    void main()
    {
    int i,j,n;
    clrscr();

    for(i=3;i>1;i–)
    {
    for(j=1;j<=i;j++)
    {

    printf("%d",j);

    }

    printf("\n");
    }
    for(i=1;i<=3;i++)
    {
    for(j=1;j<=i;j++)
    {

    printf("%d",j);

    }

    printf("\n");
    }
    getch();
    }

  • manoj

    please send me this series code in c…..

    1
    1 1
    1 2 3
    1 2 3 4

  • mohammed

    1
    0 1
    1 0 1
    0 1 0 1
    1 0 1 0 1

  • arun bansal

    hi all can u provide me logic for the problem

    array a= 5 7 4 3

    and output should be like
    5 7 4 3
    *
    * *
    * * *
    * * *
    * * * *
    * *
    * *
    * *
    *

  • mayur

    Please give code for this pattern:
    1
    12
    123
    1234
    12345
    1234
    123
    12
    1

  • dinesh

    Dinesh kumar September 16, 2011 at 5:05 PM
    printf this jalebi program

    8 9 10 11 12 13 14
    1 2 3 4 5 6 7
    15 16 17 18 19 20
    PLZ PRINT THIS

  • Gautam Mehta

    Write a program to print following pattern using loop statement for n row.

    1
    1 3
    1 3 5
    1 3 5 7

  • pushpendra

    write a virus program in c

  • Saurabh Mittal

    did you got the answer or should i?

  • safianu

    how do i write a program to generate the following pattern,using for loop,while loop and do while loop..
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    1 2 3 4 5 6
    1 2 3 4 5 6 7
    1 2 3 4 5 6 7 8
    1 2 3 4 5 6 7 8 9

    plz any one who can help me should plz email me..   safianu_hamid2000@yahoo.com

  • Ankit Kumar Chaurasia

    #include
    void main()
    {int i,n,j;
    printf(“Enter the limit:”);
    scanf(“%d”,&n);
    for(i=1; i<=n; i++)
    {
         for(j=1; j<=i; j++)
          {
             printf("1");
            }
          printf("n");
    }
    getch();
    }

  • Shraddhabansode27

    Aa
    Aa  Bb
    Aa  Bb  Cc
    Aa  Bb  Cc  Dd

  • Melting_heart_07

    #include
    #include
    void main() {
        int i,j;
        clrscr();
        for(i=1;i<=4;i++)    {      for(j=1;j<=i;j++)       {         printf("*");       }     printf("n");
       }
     getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          if(j%2!=0)
           printf("1");
          else
           printf("0");
         }
        printf("n");
       }
      getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          printf("%d",j);
         }
        printf("n");
       }
      getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          printf("1");
         }
        printf("n");
       }
      getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          printf("*");
         }
        printf("n");
       }
      getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          printf("%d",j);
         }
        printf("n");
       }
      getch();
     }

  • Beginner

    #include
    #include
    void main()
     {
      int i,j,n;
      clrscr();
      printf(“n Enter the number of rows: “);
      scanf(“%d”,&n);
      for(i=1;i<=n;i++)  // displays rows
       {
        for(j=1;j<=i;j++)   // displays colums
         {
          printf("%d",i);
         }
        printf("n");
       }
      getch();
     }

  • Gohillove

    Thank you!!!!!!! you are help me to create this programe

  • Gohilove

    please give code for this programe
                      
                             1
                         2     2
                     3     3     3
                 4     4     4     4
                    3      3     3
                         2     2
                             1

  • Smartlalit77

    i am waiting your reply

  • saiprem

    i need good gohilove wt i do?

  • saiprem

    sorry i send wrongly i need code wt can i do now?

  • Gohi llove

    what r u saying i dont understand hindi me batavo

  • Gohillove

    please no one can give me answer????????????

  • Rakesh Kumar

    class test3
    {
        public static void main(String args[])
    {
     
            for(int i=1;i<=9;i++)
       {
           
      for(int j=1;j<=i;j++)
             System.out.print(j);
             System.out.println();
        }
      }
     }

  • Rakesh Kumar

    class test1
    {
       public static void main(String args[])
    {
         int space=3;
         int counter=1;   
       for(int i=1;i<=7;i++)
    {
          for(int j=1;j<=space;j++)
           System.out.print(" ");
           if(i<4)
                    space–;
            else
                   space++;        
     
          for(int k=1;k<=counter;k++)
          System.out.print(counter+" ");
          System.out.println();
          if(i<4)
                   counter++;
           else
                  counter–;
      }
     
      }       
    }

  • Rakesh Kumar

    This is your answer in java if you have more problems you can me any time my at 
    royalrakesh.87@gmail.com 

  • Anonymous

    class num
    {
         public static void main(String args[])
    {
            int a=1;
          for(int i=1;i<=4;i++)
     {
           if(i<=2)
               {
                  for(int j=1;j<=i;j++)
                   {
                       System.out.print(a);
                        a++;
                      }
                   }
          else if(i<=3)
                {
                    for(int j=4;j<=7;j++)
                    System.out.print(j);
                 }
         else
           {
                for(int j=8;j<=15;j++)
                System.out.print(j);
                 }
          System.out.println();
         }
      }
    }

  • Anonymous

    class num
    {
      public static void main(String args[])
    {
          for(int i=1;i<=3;i++)
     {
            if(i<=1)
               {
                        for(int j=8;j<=14;j++)
                         System.out.print(j);
                    }
               else if(i<=2)
                      {
                          for(int j=1;j<=7;j++)
                          System.out.print(j);
                        }
                 else
                      {
                          for(int j=15;j<=20;j++) 
                          System.out.print(j);
                           }
                         System.out.println();
                         }
                    }
                }

  • Anonymous

    class num
    {
       public static void main(String args[])
    {
            for(int i=1;i<=4;i++)
     {
            if(i<=2)
                     { 
                          for(int j=1;j<=i;j++)
                          System.out.print("1");
                        }
                 else
                      {
                         for(int j=1;j<=i;j++)
                         System.out.print(j);
                       }
                     System.out.println();
                } 
            }
          }

  • Anonymous

    class num
    {
           public static void main(String args[])
    {
            for(int i=1;i<=6;i++)
    {
             if(i<=3)
                   {
                       for(int j=1;j<=i;j++)
                        System.out.print("1");
                     }
               else if(i<=5)
                     {
                        for(int j=1;j<=1;j++)
                        System.out.print(".");
                       }
                else
                      {
                    System.out.print("1111………n");
                 }
                 System.out.println();
            }
       }
    }
             

  • Anonymous

    class num2
    {
       public static void main(String args[])
    {
            for(int i=1;i<=4;i++)
    {
         if(i<=1)
               System.out.print("*"+" ");
         else if(i<=3)
             {
                  for(int j=1;j<=2;j++)
                  System.out.print("*"+" ");
               }
          else
              { 
               System.out.print("**********");
             }
            System.out.println();
        }
    }
          
     }   

  • Anonymous

    class te
    {
       public static void main(String args[])
    {
            int a=1;
     
       for(int i=1;i<=4;i++)
    {
          for(int j=1;j<=4;j++)
          {
          System.out.print(a);
               a++;
            }
          System.out.println();
        }
     
       
      }
    }

  • Harlaksha

    plsssssssssssssss i need the answer right now can anyone?????????????

  • guriya kumari

    #include
    #include
    void main()
    {
     int i,j,k;
     for(i=1;i<=5;i++)
      {
       for(j=1;j<=i;j++)
        {
         if(i%2==0)
          {
           if(j%2==0)
                            {
                               k=1;
                               printf("%d",k);
            }
           else
            {
             k=0;
             printf("%d",k);
                             }
                      }
                    else
          {
           if(j%2==0)
                            {
                               k=0;
                               printf("%d",k);
            }
           else
            {
             k=1;
             printf("%d",k);
                             }
                      }
                   }
        printf("n");
               }
    }

  • Gohillove

    thank you very much sir for helping me and other student thanks

  • Anonymous

    class hi
    {
        public static void main(String args[])
    {
            int counter=5;

        for(int i=1;i<=5;i++)
     {
         for(int j=counter;j<=5;j++)
         System.out.print(j);
          System.out.println();
               counter–;
                  
           }
        }
    }

  • Anonymous

    class hii
    {
       public static void main(String args[])
    {
              int n=0,i,j,counter=1,counter1=2;
        for(i=1;i=1;j–)
            System.out.print(j);

                       if(i<=4)
                        n=i;
                     else if(i<=5)
                                n=3;
                     else if(i<=6)
                                n=2;
                      else
                                n=1;
            for(int m=2;m<=n;m++)
            System.out.print(m);
           System.out.println();
             if(i<4)
                    counter++;
             else
                    counter–;
                
               
         }
      }
    }

  • Anonymous

    class h
    {
         public static void main(String args[])
    {       
             char c=65;
             char counter=70;
             for(int i=1;i<=6;i++)
           {
         
                for(char ch=c;ch=c;m–)
                 System.out.print(m);
                 System.out.println();
                counter–;
      }
    }

  • Anonymous

    class prog
    {
        public static void main(String args[])
    {
                int counter=4;
                int n=7;

            for(int i=1;i<=4;i++)
       {
                for(int j=counter;j=counter;j–) 
                System.out.print(j);
                System.out.println();
                      counter–;
                      n-=2;
             }
          }
        }

  • Anonymous

    class pat
    {
       public static void main(String args[])
    {
          for(int i=1;i<=4;i++)
    {
            int temp=i/2;
         if(i%2==1)
                {
                    temp=(temp*8);
                    for(int j=temp+1;j(temp-4);j–)
                 System.out.print(j+” “);
              }
           System.out.println();
          }
      }
     }

  • Anonymous

    class pat3
    {
       public static void main(String args[])
    {
         int counter=0;
         int n=2;
        for(int i=1;i=0;j–)
         System.out.print(j);
          if(i<=6)
          {
              for(int j=1;j<i;j++)
              System.out.print(j);
          }
         else
          {
             for(int j=1;j<i-n;j++)
             System.out.print(j);
               n+=2;
             }   
         System.out.println();
               
       
          if(i<6)          
               counter++;
        else
               counter–;
       }
     }
    }

  • Anonymous

    class Aa
      {
           public static void main(String args[])
        {
             for(int i=1;i<=4;i++)
             { 
                  char ch=65;
                       for(int j=1;j<=i;j++)
                  {
                       System.out.print(ch);
                       ch+=32;
                       System.out.print(ch + " ");
                       ch-=31;
                  }
               System.out.println("");
             }
        }
     }

  • PRIM

    Please can you write a program to print the below, using JAVA.
    #)
    ##))
    ###)))

    Send to my email. pr_kins@yahoo:disqus .com
    thanks in advance.

  • Rakesh Kumar

    class hiii
    {
        public static void main(String args[])
    {
          int counter=4,space=7,n=7;
      
        for(int i=1;i<=9;i++)
    {
          if(i<=4)
      {
           for(int j=1;j<=i;j++)
           System.out.print(counter);
           for(int j=1;j<=space;j++)
           System.out.print("-");
           for(int j=1;j<=i;j++)
           System.out.print(counter);
                 space-=2;
          }
        else if(i<=5)
                  {
                        for(int j=1;j<=9;j++)
                        System.out.print(counter);
                    }
          else
                {
                   for(int j=1;j<=n;j++)
                   System.out.print(counter);
                           n-=2;
                        
                   }
              if(i<5)
                       counter–;
     
             else
                      counter++;
         System.out.println();
      }
    }
    }

  • Rakesh87

    import java.util.Scanner;
    class mail
    {
         public static void main(String args[])
    {
           Scanner obj=new Scanner(System.in);
           System.out.print(“Enter number for print pattern:”);
           int num=obj.nextInt();
             for(int i=1;i<=num;i++)
        {
              for(int j=1;j<=i;j++)
              System.out.print("#");
              System.out.print(")");
              System.out.println();
           }
       }

  • Anonymous

    import java.util.Scanner;
    class num
    {
         public static void main(String args[])
      {
            Scanner obj=new Scanner(System.in);
            System.out.print(“Enter the number of Row:”); 
            int num=obj.nextInt(); 
             int a=1;
           for(int i=1;i<=num;i++)
             {
                for(int j=1;j<=i;j++)
                  {
                System.out.print(a);
                   a++;
                  if(a==10)
                       a=0;
                 }
               System.out.println();
             
                        
             } 
        }
      }

  • hershislala

    *
    **
    ***
    ****

    white a while loop for this patter ( n = 4)
    you can only have one loop 
    if n < 1 there should be no output 

  • Savitha p s

    can u tel me the c code to print tat if user enter 5 then output should be 5 5 5 5 5

  • Anonymous

    class dec
    {
         public static void main(String args[])
     {
              int counter=3;
             for(int i=1;i<=5;i++)
        {
            for(int j=1;j<=counter;j++)
              System.out.print(j);
               System.out.println();
                 if(i<3)
                        counter–;
                else
                       counter++;
               
             }
         }
       }
                  

  • Anonymous

    import java.util.Scanner;

    class spiral
      {public static void main(String args[])
         {Scanner obj = new Scanner(System.in);
          System.out.print(“nEnter no. of rows of this spiral matrix: “);
          int rows = obj.nextInt();
          System.out.print(“nEnter no. of columns of this spiral matrix: “);
          int columns = obj.nextInt();
          int [][]array = new int[rows][columns];
          int top=0,left=0,right=columns-1,bottom=rows-1;
          int counter=1;
     
          while(counter<=(rows*columns))
            { 
              for(int i=left;i<=right;i++)
                 array[top][i] =counter++;
              top++;

              for(int i=top;i=left;i–)
                 array[bottom][i] =counter++;
              bottom–;

              for(int i=bottom;i>=top;i–)
                 array[i][left] =counter++;
              left++;
             }

           for(int i=0;i<rows;i++)
             { for(int j=0;j<columns;j++)
                 {System.out.print(array[i][j]);
                  if(array[i][j]<10)
                      System.out.print("  ");
                  else
                      System.out.print(" ");
                 }
               System.out.print("n");
             }
        }
     }

  • Anonymous

    import java.util.Scanner;
    class test
    {
         public static void main(String args[])
    {
            Scanner obj=new Scanner(System.in);
            System.out.print(“Enter Row:”);
            int row=obj.nextInt(); 
            System.out.print(“Enter colom:”);
            int colom=obj.nextInt();
            for(int i=1;i<=row;i++)
        {
              for(int j=1;j<=colom;j++)
              System.out.print("*");
              System.out.println();
            }
        }
    }

  • Anonymous

    import java.util.Scanner;class spiral  {public static void main(String args[])     {Scanner obj = new Scanner(System.in);      System.out.print(“nEnter no. of rows of this spiral matrix: “);      int rows = obj.nextInt();      System.out.print(“nEnter no. of columns of this spiral matrix: “);      int columns = obj.nextInt();      int [][]array = new int[rows][columns];      int top=0,left=0,right=columns-1,bottom=rows-1;      int counter=1;       while(counter<=(rows*columns))        {           for(int i=left;i<=right;i++)             array[top][i] =counter++;          top++;          for(int i=top;i=left;i–)             array[bottom][i] =counter++;          bottom–;          for(int i=bottom;i>=top;i–)             array[i][left] =counter++;          left++;         }       for(int i=0;i<rows;i++)         { for(int j=0;j<columns;j++)             {System.out.print(array[i][j]);              if(array[i][j]<10)                  System.out.print("  ");              else                  System.out.print(" ");             }           System.out.print("n");         }    } }

  • Anonymous

    import java.util.Scanner;

    class spiral
      {public static void main(String args[])
         {Scanner obj = new Scanner(System.in);
          System.out.print(“nEnter no. of rows of this spiral matrix: “);
          int rows = obj.nextInt();
          System.out.print(“nEnter no. of columns of this spiral matrix: “);
          int columns = obj.nextInt();
          int [][]array = new int[rows][columns];
          int top=0,left=0,right=columns-1,bottom=rows-1;
          int counter=1;
     
          while(counter<=(rows*columns))
            { 
              for(int i=left;i<=right;i++)
                 array[top][i] =counter++;
              top++;

              for(int i=top;i=left;i–)
                 array[bottom][i] =counter++;
              bottom–;

              for(int i=bottom;i>=top;i–)
                 array[i][left] =counter++;
              left++;
             }

           for(int i=0;i<rows;i++)
             { for(int j=0;j<columns;j++)
                 {System.out.print(array[i][j]);
                  if(array[i][j]<10)
                      System.out.print("  ");
                  else
                      System.out.print(" ");
                 }
               System.out.print("n");
             }
        }
     }

  • Anonymous

    import java.util.Scanner;
    class keeran
    {
          public static void main(String args[])
    {
            Scanner obj=new Scanner(System.in);
            System.out.print(“Enter the number:”);
            int num=obj.nextInt();
          for(int i=1;i<=num;i++)
         {
               if(i%2!=0)
              {
                  for(int j=1;j<=5;j++)
                  System.out.print("*");
                }
            else
              {
                   for(int j=1;j<=3;j++)
                   System.out.print("*");
                 }
                System.out.println();
             }
        }
    }

  • Anonymous

    Hiiii
    Keeran i am sending your problems solution if you have any problem you can ask me any time.
    Email-royalrakesh.87@gmail:disqus .com
    cont-09650687258

  • Saurabh Mittal

    /* WAP to print the pattern
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    */

    import java.util.Scanner;
    class pattern11
      { public static void main(String args[])
           {  System.out.print(“nEnter the number of lines to print: “);
              Scanner object = new Scanner(System.in);
              int lines = object.nextInt();
            
              for(int i=0;i<lines;i++)
                 { System.out.print("1 ");
                   if(i%2==0)
                       {int temp=i;
                         for(int j=1;j<=(i/2);j++)
                            {System.out.print(temp + " ");
                             temp+=2;
                            }
                        temp-=4;
                        for(int j=1;j<(i/2);j++)
                            {System.out.print(temp + " ");
                             temp-=2;
                            }
                       }
                   else
                       {for(int j=1;j=1;j–)
                            System.out.print(i*j + ” “);
                       }
                   if(i!=0)
                   System.out.print(“1″);

                   System.out.print(“n”);               
                 }
            }
      }

  • Saurabh Mittal

    If you want any explanation, then let me know!!!!!!!!!

  • Saurabh Mittal

    </lines;i++) is added to above program, i don’t know how.
    Ans a too
    I am pasting the program again

    /* WAP to print the pattern11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1*/import java.util.Scanner;class pattern11  { public static void main(String args[])       {  System.out.print(“nEnter the number of lines to print: “);          Scanner object = new Scanner(System.in);          int lines = object.nextInt();                  for(int i=0;i<lines;i++)             { System.out.print("1 ");               if(i%2==0)                   {int temp=i;                     for(int j=1;j<=(i/2);j++)                        {System.out.print(temp + " ");                         temp+=2;                        }                    temp-=4;                    for(int j=1;j<(i/2);j++)                        {System.out.print(temp + " ");                         temp-=2;                        }                   }               else                   {for(int j=1;j=1;j–)                        System.out.print(i*j + ” “);                   }               if(i!=0)               System.out.print(“1″);               System.out.print(“n”);                            }        }  }

  • Saurabh Mittal

    I do not know what’s wrong with the site, i can mail you the prog.
    It’s not getting pasting on this damm site.:-(

  • Saurabh Mittal

    /* WAP to print the pattern11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1If still this prog doesn’t got pasted in my third attempt, mail me your e-mail id’s at saurabhmittal1987@gmail.com,  i’ll mail you the program*/import java.util.Scanner;class pattern11{ public static void main(String args[])     {  System.out.print(“nEnter the number of lines to print:  ”);         Scanner object = new Scanner(System.in);         int lines = object.nextInt();         for(int i=0;i<lines;i++)             { System.out.print("1 ");               if(i%2==0)                   {int temp=i;                     for(int j=1;j<=(i/2);j++)                        {System.out.print(temp + " ");                         temp+=2;                        }                    temp-=4;                    for(int j=1;j<(i/2);j++)                        {System.out.print(temp + " ");                         temp-=2;                        }                   }               else                   {for(int j=1;j=1;j–)                        System.out.print(i*j + ” “);                   }               if(i!=0)               System.out.print(“1″);               System.out.print(“n”);             }        }}

  • Blaze

    can u give a program made in c

  • Suvodip7

    #include
    #include
    void main()
    {
    int i,j,k,a;clrscr();
    printf(“Enter the line no:”);
    scanf(“%d”,&a);
    for(i=1;i<=a;i++)
    {
    for(j=1;j<=a-i;j++)
      {
      printf(" ");
      }
      {
      printf("%d",i);
      }
      for(k=1;k0;i–)
        {
        for(j=1;j<=a-i;j++)
        {
        printf(" ");
        }

        {
        printf("%d",i);
        }

        for(k=1;k<=i-1;k++)
        {
        printf(" %d",i) ;
        }
       {
        printf("n");
        }
        }
        getch();
        }

  • Suvodip7

    #include
    #include
    void main()
    {
    int i,j,k=1;  clrscr();
    for(i=1;i<=4;i++)
      {
      for(j=1;j<=i;j++)
        {
        printf("%d",k);
        k++;
        }
        printf("n");
        }
        getch();
        }

  • Suvodip7

    the last conio.h and stdio.h has come mistakenly so dont use it

  • Suvodip7

    #include
    #include
    void main()
    {
    int i,j,k=5;    clrscr();
    for(i=1;i<=5;i++)
       {
       for(j=k;j<=5;j++)
       {
       printf("%d",j);
       }
       k–;
       printf("n");
       }
       getch();
       }

  • Suvodip7

    #include
    #include
    void main()
    {
    int i,z=0,a,k=0;
    printf(“Enter the required no. of terms:”);
    scanf(“%d”,&a);
    for(i=1;i<=a;i++)
      {z++;
        k=k+z;
    }
    printf("%d",k);
    getch();
    }

  • Saurabh Mittal

    /* WAP to print the pattern
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    */
    #include
    void main()
     {int i,j,lines,temp;
    printf(“nEnter the number of lines to print: “);
    scanf(“%d”,&lines);

    for(i=0;i<lines;i++)
    { printf("1 ");
    if(i%2==0)
    {temp=i;
    for(j=1;j<=(i/2);j++)
    {printf("%d ",temp);
    temp+=2;
    }
     temp-=4;
     for(j=1;j<(i/2);j++)
    {printf("%d ",temp);
    temp-=2;
    }
    }
    else
    {for(j=1;j=1;j–)
    printf(“%d “,i*j);
    }
    if(i!=0)
    printf(“1″);

    printf(“n”);
                 }
    }

  • Nikhil Nikumbh

    1 2 3 4 3 2 1
    1 2 3     3 2 1
    1 2             2 1
    1                     1

  • Anonymous

    class dec
    {
       public static void main(String args[])
    {
          int space=-1,counter=4;

       for(int i=1;i<=4;i++)
     {
          if(i<=1)
           {
                 for(int j=1;j=1;j–)
                 System.out.print(j);
             }
        else
        {
               for(int j=1;j<=counter;j++)
               System.out.print(j);
               for(int j=1;j=1;j–)
               System.out.print(j);
               }
          System.out.println();
             counter–;
             space+=2;
           }
          }
       }

  • Anjali godayal

    please give the coding

  • Kuldeep Suthar

    /* WAP to print the pattern54321123455432 2345543 34554 455 55 554 45543 3455432 23455432112345
    */

     #include  main()  { int i,j,k,l,m,n; for(i=1;i=i;j–) printf(“%d”,j); for(k=i;k<=5;k++) printf("%d",k); printf("n"); } for(l=1;l=6-l;m–) printf(“%d”,m); for(n=6-l;n<=5;n++) printf("%d",n); printf("n"); }  }

  • Kuldeep Suthar

    /* WAP to print the pattern5432112345
    5432 2345
    543 345
    54 45
    5 5
    5 5
    54 45
    543 345
    5432 2345
    5432112345
    */
     #include
    main(){int i,j,k,l,m,n;for(i=1;i<=5;i++){ for(j=5;j>=i;j–) printf(“%d”,j); for(k=i;k<=5;k++) printf(“%d”,k); printf(“n”);}for(l=1;l<=5;l++){ for(m=5;m>=6-l;m–)         printf(“%d”,m); for(n=6-l;n<=5;n++) printf(“%d”,n); printf(“n”);} }

  • Dattu Londhe

    this is c program section dont write code in other language… i kwn logic is same but same new c user raffer this code they are confused ……….. use your c lavel knolagde

  • Dattu Londhe

    provide c code

  • Dost991

    Write a
    program that prints the following output

    ?$$$$$?

    ?$$$$?

    ?$$$?

    ?$$?
    ?$?

  • Anonymous

    /*
    ?$$$$$?
    ?$$$$?
    ?$$$?
    ?$$?
    ?$?
    */
    class aaa
    {
     public static void main(String args[])
    {
            int count=5;
       for(int i=1;i<=5;i++)
     {
           System.out.print("?");
           for(int j=1;j<=count;j++) 
           System.out.print("$");
           System.out.print("?");
           System.out.println();
                count–;
           }
       }
    }

  • K S S Kumar1207139

    void main()
    {
    int i,j;
    for(i=0;i<=4;i++)
    {
    for(j=0;j<=i;j++)
    printf("%d",2*j+1);
    printf("n");
    }
    getch();
    }

  • Anonymous

    /*
    1
    1 3
    1 3 5
    1 3 5 7
    1 3 5 7 9
       */
    import java.util.Scanner;
    class a 
    {
        public static void main(String args[])
    {
         
        Scanner obj=new Scanner(System.in);
        System.out.print(“Enter the number of row: “);
        int n=obj.nextInt();
       for(int i=1;i<=n;i++)
     {
               int count=1;
          for(int j=1;j<=i;j++)
       {
            System.out.print(count+" ");
                    count+=2;
             }
                System.out.println();
               }
         }
     }

  • Anonymous

    /*
    44
    3333
    222222
    11111111
    000000000
    1111111
    22222
    333
    4
       */
    class a3
    {
        public static void main(String args[])
    {
               int counter=2;
               int count=4;

           for(int i=1;i<=9;i++)
     {
                for(int j=1;j<=counter;j++)
                 System.out.print(count);
                System.out.println();
                    if(i<5)
                             count–;
                     else
                             count++;
                  
                 if(i<4)
                          counter+=2;
                else if(i<5)
                          counter=9;
                  else
                         counter-=2;
                }
         }
    }
                       

  • Anonymous

    class patt2
    {
        public static void main(String arsg[])
    {
          int count=1,count1=5;
     
      for(int i=1;i<=10;i++)
        {
           if(i=count;j–)
              System.out.print(j);
              for(int j=count;j=count1;j–)
                   System.out.print(j);
                   for(int j=count1;j<=5;j++)
                   System.out.print(j);
                           count1–;
                   }
                System.out.println();
              }
          }
      }
             

  • Venkat Mumma

    u r website is good.

  • Anooj

    //print following structure
    /*     1
          1   1
        1   2   1
      1   3   3   1

    */
    #include
    #include
    void main()
    {
    int i,j;
    clrscr();
    printf(“n Tripoid trianglen”);
    for(i=1;ii;j–)
    printf(” “);
    for(j=1;j=1;j–)
    printf(“%d “,j);
    printf(“n”);
    }

    getch();
    }

  • Mrmshilpa

    i need a program to print
    1
    1 2 1
    1 2 3 2 1
    1 2 3 4 3 2 1
    plz help ma xams are soon..

  • Anonymous

    class dis
      {
              public static void main(String args[])
     {
               int count=2;
                for(int i=1;i<=4;i++)
                {
                         if(i<=1)
                                 System.out.print("1");
                         else
                                {
                                    for(int j=1;j=1;j–)
                                      System.out.print(j);
                                              count++;
                                      }
                                    System.out.println();
                                   }
                                }
                              }

  • Jdumer

    12345
    2345
    345
    45
    5

    help  me  how  to  print  this

  • Anonymous

    class test
     {
           public static void main(String args[])
           {
                        int count=1;
                     for(int i=1;i<=5;i++)
                      {
                                for(int j=i;j<=5;j++)
                                 System.out.print(j);
                                System.out.println();
                                    }
                                   }
                                 }                            

  • Raunak

    Pls Help Me with this one :-

     1 3  2 4  5  6 10 9  8  7 

  • Is Living

     1

     3  2

     4  5  6

     10 9  8  7 

  • adhiyash

    plz can you give a c++ program displaying the foll. pattern??????????????
    1
    12
    123
    1234

  • Zeros

    i had to write a program that receives 2 integers n and m. and to show this:


       n=8 (number of lines)
       m=3 (number of columns)

       #
       ##
       ###
       ##
       #
       ##
       ###
       ##

                                                              ”

    i wrote it like this:

    #include int main(){    int m, n;    printf(“Enter value n:n”,&n);    scanf(“%d”,&n);    printf(“Enter value m:n”,&m);    scanf(“%d”,&m);    printf(“nn=%d (number of lines)”, n);    printf(“nm=%d (number of columns)nn”, m);    printf(“#n##n###n##n#n##n###n##n”);    getchar();    return 0;}                                                                                                       ”

    I saw that here is made quite complicated, is my way good? if not why not?

  • Zeros

    I don’t know why it put it like that here it is again with enters :D
    #include
      int main()
    {    int m, n;
          printf(“Enter value n:n”,&n);
          scanf(“%d”,&n);
          printf(“Enter value m:n”,&m);
          scanf(“%d”,&m);
          printf(“nn=%d (number of lines)”, n);
          printf(“nm=%d (number of columns)nn”, m);
          printf(“#n##n###n##n#n##n###n##n”);
          getchar();
          return 0;
    }       

  • 402shanwaz

    Do u Know
    Top 20 C programs for Technical Interview

  • Mohsin Makwal

    give me coding of this
    0 1 2 3 4 
    1 2 3 4
    2 3 4
    3 4 
    4

  • madhu

    I want the following pattern
    ********
    ***    ***
    **         **
    *             *

  • Mani

    #include
    main()
    {
        int i,j;
        for(i=1;i<=4;i++)
        {
            for(j=1;j<=i;j++)
                {
                printf("%d",j);
                }
        printf("n");
        }
    }

  • Mani Balu785

    #include
    main()
    {
        int i,j,n;
        printf(“Enter that howmany rows do u want :”);
        scanf(“%d”,&n);
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=i;j++)
                {
                printf("*");
                }
        printf("n");
        }
    }

  • Raveenatanwani

    can i get the answer of 

    1      2       3       4
    5                         8
    9                        12
    13   14    15    16 

    plzz i need right now

  • Raveenatanwani

    can i get the answer of 

    1      2       3       4
    5                         8
    9                        12
    13   14    15    16 

    plzz i need right now

  • Dassupriyo01

    #include
    #include
    void main()
    {
    int i,n,j;
    clrscr();
    printf(“enter number”);
    scanf(“%d”,&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j=1;i–)
      {
        for(j=1;j<=i;j++)
        {
        printf("%d",j);

        }
       printf("n");
      }
    getch();
    }

  • Yogashanmugam

    for(i=0;i<5;i++)
    {
    printf("n");
    for(j=i;j<5;j++)
    printf("%d ",j);
    }

  • Sadula Archana

    write a program to print the following pattern;
     4                                    4
         3                            3
              2                 2
                  1         1
                       0
                   1         1
               2                  2
           3                             3
     4                                        4
    please send me  a mail if anyone know this ans…

  • Raj

    3 4 5 * * * 3 4 5
    6 7 8 * * * 6 7 8
    9 0 1 * * * 9 0 1
    * * * 3 4 5 * * *
    * * * 6 7 8 * * *
    * * * 9 0 1 * * *
    3 4 5 * * * 3 4 5
    6 7 8 * * * 6 7 8
    9 0 1 * * * 9 0 1Code For this one please

  • Sanne_dhankuta

    I need souece code to generate following pattern

    1
    21
    3  1
    4     154321

  • Sanne_dhankuta

    I need souece code to generate following pattern 
    1213  14      154321

  • Jithu Khandelwal

    hello mam this is jithu khandelwal…… i’ve an program for the above pattern so pleasesend me ur e-mail id i’ll send the program

  • Prashant Gupta

    #include
    #include
    void main()
    {
    int i,j,k;
    clrscr();
    for(i=1;i<=4;i++)
    {
       for(k=1;k<=(4-i);k++)
       {
           printf(" ");
       }
           for(j=1;j=1;i–)
    {
         for(k=1;k<=(4-i);k++)
         {
              printf(" ");
         }
              for(j=1;j<=i;j++)
              {
                   printf("%d",i);
              }
    printf("n");
    }
    getch();
    }

  • anil

                                   * * * * * * * * * *
                                    * * * * * * * * *
                                     * * * * * * * *
                                      * * * * * * *
                                       * * * * * *
                                        * * * * * 
                                         * * * *
                                          * * *
                                           * *
                                            *

  • Raavi Swami

    plz tell me code plzzzzzzzzz

Previous post:

Next post: