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 Program code plzz fast!?

here's the output:

*********1

********2 3

*******4 5 6

******7 8 9 10

(without * , *=blank)

plz help me out with the C prog code fast!

Update:

there are no stars just the sequence..

in your prog no nos. are printed

4 Answers

Relevance
  • cja
    Lv 7
    1 decade ago
    Favorite Answer

    I don't like to produce a solution that will only work for one specific case, e.g. N = 10, so the code below will create a nice looking pyramid for the command-line-provided N up to 990. If you want to get into 4-digit numbers, just change the two instances of 4 in the code to 5 (or 6 for 5-digit numbers, etc.)

    If this is for a class assignment, study and understand the code before using its techniques in your own solution. I'm sure you'll learn something.

    #include <stdio.h>

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

    int N,i,j,n,nSpace,h;

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

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

    return -1;

    }

    for (i = 1, h = 1; i < N; i += ++h);

    nSpace = h * 2;

    for (j = 0, n = 1; j < h; j++, nSpace -= 2) {

    for (i = 0; i < nSpace; i++) printf("%c",' ');

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

    puts("");

    }

    return 0;

    }

  • 1 decade ago

    /* This is a fast simple program. (!i) is the same as saying (i==0). I'm sure it will need fixing to do what you want. C'mon try."/

    #include <stdio.h>

    int main()

    {

    int i, j;

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

    {

    for (j=0;j<10-(i+1);j++)

    printf(" ");

    if (!i) printf("1\n");

    else if (i==1)printf("23\n");

    else if (i==2)printf("456\n");

    else printf("78910\n");

    }

    return 0;

    }

  • ?
    Lv 4
    5 years ago

    basically google c++ and there are quite some academic web content. as far as studying the language is worried, It takes a lengthy time period and also you're able to continually study new issues. also dont assume it to be common, yet in case you recognize different languages its really a wide plus

  • Runa
    Lv 7
    1 decade ago

    #include "stdio.h"

    #define N 10

    main()

    {

    int i,j;

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

    {

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

    printf("*");

    printf("\n");

    }

    printf("\n");

    for(i=N; i>=1; i--)

    {

    for(j=i; j>=1; j--)

    printf("*");

    printf("\n");

    }

    printf("\n");

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

    {

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

    printf(" ");

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

    printf("*");

    printf("\n");

    }

    }

Still have questions? Get your answers by asking now.