Hi im new here...i am only an high school student, i hav a problem on my this output...im using turbo c, can u help me with ths?? i cant get it...pls help

1.
55555
4444
333
22
1

2.
12345
1234
123
12
1

3.
****5
***4*
**3**
*2***
1****

help me

Hi im new here...i am only an high school student, i hav a problem on my this output...im using turbo c, can u help me with ths?? i cant get it...pls help help me

Please post your code so we can what the problem is and point it out to you.

here's my prog on #1,

#include<stdio.h>
main()
{ int ctr[5], number=0
   clrscr();
   for(number=5;number>0;number--)
   { printf("%d", ctr[number]);
      printf("\n");
    }
 getch();
}

i guess it has too many errors?? im a newbie...i tried it but still i cant get it, i also tried another prog but it wont display what i wanted..
it only displays

output:
5
4
3
2
1

There is actually no need to create an array, the problem can be solved using just two "loops". Dont use the function "clrscr()" since it kills program portability and it is a non standard function. If possible try to move from the age old turbo compiler to the list of new compilers provided in the thread mentioned below.

And as far as the thing that you are a newbie is concerned, if you are in need of tutorials, look at the sticky at the top of the forum named "Starting C", it can help you a lot.

Also here is a sample of how you can do it and i wont tell you how to solve the rest of them, you need to think about them.

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int i, j ;

    for (i = 5; i > 0; --i)
    {
        for (j = i; j > 0; --j)
        {
            printf ("%d", i) ;
        }
        putchar ('\n') ;
    }
    getchar () ;
    return 0 ;
}

Hope it helped, bye.

hi i can help you in your prob..

#1.

#include<stdio.h>
#include<conio.h>
main()
{
int r,c;
clrscr();
for(r=5;r>=1;r--){
  for(c=r;c>=1;c--){
      printf("%d",r);
  }
  printf("\n");
}
getche();
}

Edited 6 Years Ago by Nick Evan: Added code-tags

#2

source code:

#include<stdio.h>
#include<conio.h>
main()
{
int r,c;
clrscr();
for(r=5;r>=1;r--){
   for(c=1;c<=r;c++){
      printf("%d",c);
   }
    printf("\n");
}
getche();
}

hi i can help you in your prob..

hmm. This thread is quite old, I guess the OP has allready solved his problem.

Now for a few tips on your code:

- Don't use getche() use the standard function getchar() instead.
- Don't use clrscr; it makes you code non-portable
- The prototype (one of two) for main() is [B]int[/B] main(void) not main()
- When taking the above in account, you don't need to include <conio.h> anymore.

Edited 6 Years Ago by Nick Evan: n/a

hehe...yeah right...thanks...by d way can you help with my assignment? we were told to make a program that printed the pascal's triangle using nested loop...the output goes like this..

1
            1    1
          1   2    1
        1   3   3    1
     1    4   6   4    1
  1    5   10  10  5    1
so on and so forth...thanks(we use Turbo C)

by d way can you help with my assignment?

Yes I can. But first you should make a new thread for this question, it it not allowed to piggyback (or hijack) other threads. Then show what you have done so far.
You should use the searchfunction here on daniweb because there are *a lot* of threads about pascaltriangles here.

Regards Niek

This article has been dead for over six months. Start a new discussion instead.