Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C programmers out there help me!!!!!!?

1)write a program in C to print digits like

1

123

4567

2)to print digits like

1

11

111

1111

11111

3)to print stars

*

**

***

****

*****

the out put should come like mentioned above i'll be very thankfull i'm in DIRE need of these programs 10points -five stars for the best answer

plz help me out

7 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    for

    1

    11

    111...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("1 ");

    }

    printf("\n");

    }

    getch();

    }

    for

    1

    2 3

    4 5 6...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n,count=1;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("%d ",count);

    count++;

    }

    printf("\n");

    }

    getch();

    }

    for

    *

    * *

    * * * ...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("* ");

    }

    printf("\n");

    }

    getch();

    }

    Gud Luck...

  • cja
    Lv 7
    1 decade ago

    Here's one program that answers both parts 2) and 3) of your question:

    #include <stdio.h>

    #include <math.h>

    int main(int argc, char *argv[]) {

    int n,i,j;

    char x;

    if ((argc < 2) || (sscanf(argv[1],"%d,%c",&n,&x) != 2)) {

    printf("\nusage: %s <height>,<symbol>\n",argv[0]);

    return -1;

    }

    n = fabs(n);

    for (i = 1; i <= n; i++) {

    for (j = 0; j < i; j++) {

    printf("%c",x);

    }

    puts("");

    }

    return 0;

    }

    As for part 1), I wonder if you've shown the pattern correctly. Something like this would make more sense:

    1

    23

    456

    etc. In which case a simple variation of my logic above is all you need. I'll let you work this one out yourself.

  • ?
    Lv 4
    5 years ago

    you could learn C# as you already suggested that your C++ is already cleared.. the two are a similar language yet c# has some extra stepped forward applications while in comparison with c++. in case you opt for to earnings this language you could somewhat learn on line only check out the under internet site for extra information -

  • 1 decade ago

    never post this type of qus .....

    just do yourself .......

    ask help from your teacher .......

    i'll give some hint ...

    for star printing ...

    ========

    for(k=n;k>i;k--)

    printf(" ");

    {for(i=0;i<n;i++)

    {for(j=0;j<i;j++)

    printf(" *");

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

    ====for 1 just replace it by "1"

    ===for first one do your self ....start with i,j

    then for(i=1;i<=7;i++)

    plz do the rest ...

  • How do you think about the answers? You can sign in to vote the answer.
  • 1 decade ago

    take it like a game

    you need printf, and a little bit of for loops.

    mix together and try yourself before taking a look at proposed solutions (alrady given here)

    it's really easy and you won't go further if you can't solve this yourself

  • Anonymous
    1 decade ago

    1

    11

    111...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("1 ");

    }

    printf("\n");

    }

    getch();

    }

    for

    1

    2 3

    4 5 6...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n,count=1;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("%d ",count);

    count++;

    }

    printf("\n");

    }

    getch();

    }

    for

    *

    * *

    * * * ...

    program:

    #include<stdio.h>

    #include<conio.h>

    void main()

    {

    int i,j,n;

    clrscr();

    printf("Enter the Number of lines:");

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

    for(j=0;j<=i;j++)

    {

    printf("* ");

    }

    printf("\n");

    }

    getch();

    }

  • answer of 3

    int i,j;

    for(i=0;i<5;i++)

    {

    for(j=0;j<=i;j++){

    printf("*");}

    printf("\n");

    }

    answer of 2

    int i,j;

    for(i=0;i<5;i++)

    {

    for(j=0;j<=i;j++){

    printf("1");}

    printf("\n");

    }

    answer of 1st(if it not works then you may ask me for that)

    int i,j;

    for(i=1;i<=5;i++)

    {

    for(j=1;j<=i;j++){

    printf("%d",j);}

    printf("\n");

    }

Still have questions? Get your answers by asking now.