1. Hey Guest Did you know you can win an Honor 10 phone worth ₹33,000 and an additional ₹70,000 in paytm vouchers, just by replying to some threads and taking part in the discussions happening in the Honor Hub?

    What are you waiting for? Start commenting and start winning! Remember to read the instructions posted here.

    Dismiss Notice

How can I make these 2 programs in C ??

Discussion in 'QnA (read only)' started by zeeshan_04, Sep 26, 2004.

Thread Status:
Not open for further replies.
  1. zeeshan_04

    zeeshan_04 New Member

    Joined:
    Aug 16, 2004
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Kutch, Gujarat
    Hi Guys,

    I want 2 make 2 programs in "C" which displays numbers as shown below.

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

    -------------------------------------------------

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

    --------------------------------------------------

    How can I make these 2 programs in C ??

    Please help guys. Thanks in advance.
     
  2. NikhilVerma

    NikhilVerma New Member

    Joined:
    May 12, 2004
    Messages:
    930
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    India
    DUDE!!

    DUDE!!
    It's so simple!
    just include this in your main function...

    FIRST ONE

    Code:
    // I am supposing that number of rows is n
    
    int i,k;
    for(i=1;i<=n;i++)
    {
    	for(k=1;k<=i;k++)
    		cout<<k<<" ";
    	cout<<endl;
    }
    SECOND ONE

    Code:
    // I am supposing number of rows to be n again
    
    int i,k,ctr=1;
    for(i=1;i<=n;i++)
    {
    	for(k=1;k<=i;k++)
    		cout<<ctr++<<" ";
    	cout<<endl;
    }

    If anyone has any probs regarding programming in C++ ... Just ask me...
     
  3. GNUrag

    GNUrag FooBar Guy

    Joined:
    Jun 22, 2004
    Messages:
    1,246
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Interwebs
    Code:
    #include <stdio.h>
     
    int main() {
     
      for (int i =1; i<=10; i++) {
        for (int j=1; j<=i; j++)
          printf("%d ",j);
        printf("\n");
      }
    }
    


    Code:
    #include <stdio.h>
     
    int main() {
      int k=1;
      for (int i =1; i<=10; i++) {
        for (int j=1; j<=i; j++)
          printf("%d ",k++);
        printf("\n");
      }
    }
    


    -------------
    What purpose did this solve ?
     
  4. GNUrag

    GNUrag FooBar Guy

    Joined:
    Jun 22, 2004
    Messages:
    1,246
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Interwebs
    hey nikhil bhai, i was just typing when you posted your's !!!! But you've written in C++
     
  5. sniper

    sniper New Member

    Joined:
    Nov 17, 2003
    Messages:
    63
    Likes Received:
    0
    Trophy Points:
    0
    too
     
  6. OP
    OP
    zeeshan_04

    zeeshan_04 New Member

    Joined:
    Aug 16, 2004
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Kutch, Gujarat
    Thanks .

    I want the programs to be made without using "for". U can use while
     
  7. GNUrag

    GNUrag FooBar Guy

    Joined:
    Jun 22, 2004
    Messages:
    1,246
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Interwebs
    No thanks.... you can make it yourself....
     
  8. OP
    OP
    zeeshan_04

    zeeshan_04 New Member

    Joined:
    Aug 16, 2004
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Kutch, Gujarat
    I made it
     
  9. go4inet

    go4inet New Member

    Joined:
    Feb 18, 2004
    Messages:
    300
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Chennai
    cool... if i need help... i will post

    need help in Data Structures with C++ ! Anyone good on that ?
     
  10. diab0lic666

    diab0lic666 New Member

    Joined:
    Sep 3, 2004
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Godless Savage Garden.
    Why you ppl make others to do your home work???
     
  11. NikhilVerma

    NikhilVerma New Member

    Joined:
    May 12, 2004
    Messages:
    930
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    India

    Yep...
    What do you want to know about? Classes or structures...


    Coz It's the only place they will get help.
    There's noting wrong when you ask someone to do your homework..
    Yeah.. If you repeatedly ask for it then it's wrong...
     
  12. Aseem Nasnodkar

    Aseem Nasnodkar New Member

    Joined:
    Jan 10, 2004
    Messages:
    255
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Panaji - Goa
    hey dat was easy stuff! I mean 2 say those c progs.
     
  13. sniper

    sniper New Member

    Joined:
    Nov 17, 2003
    Messages:
    63
    Likes Received:
    0
    Trophy Points:
    0
    I own Data structures
     
  14. NikhilVerma

    NikhilVerma New Member

    Joined:
    May 12, 2004
    Messages:
    930
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    India
    Really!
    I thought you knew them... :D
     
  15. slugger

    slugger Banned

    Joined:
    May 9, 2004
    Messages:
    2,430
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Baudland
    help needed in C

    I am using Turbo C++ compiler for practicing C programming. Everytime I try to run a program, I get a message saying
    'Unable to open include file STDIO.H'
    When I ran a search for the file I found it in the same folder where the program is installed.
    Actually the problem extends to all header filez as I get the same message everytime followed by the header file name.
    BTW I'm installing Borland C++ 5.5 today. will tell u if it solves the problem. But I still want to know why am goetting the message in TC++
    Plz help
     
  16. puja399

    puja399 New Member

    Joined:
    Jul 30, 2005
    Messages:
    324
    Likes Received:
    0
    Trophy Points:
    0
    No, it's all wrong. You should not do other's homeworks. It will hamper learning. If someone has trouble in understanding a programming concept, there is no trouble in helping, but doing other's homework will retard the student. So, I suggest that we stop doing other's homeworks.
     
  17. aadipa

    aadipa New Member

    Joined:
    Feb 12, 2004
    Messages:
    997
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Palghar, Mumbai
    Doing some1's homework is no no for me. First one should try, if stuck some where, post the original code so that we can correct it, or atleast give a hint to continue.
     
  18. kalpik

    kalpik In Pursuit of "Happyness"

    Joined:
    May 18, 2005
    Messages:
    3,002
    Likes Received:
    15
    Trophy Points:
    0
    Location:
    New Delhi
    ^^ exactly... Post your own code before asking for suggestions...

    @slugger: Check if your paths are correct in options->directories.
     
  19. __Virus__

    __Virus__ New Member

    Joined:
    Sep 15, 2005
    Messages:
    560
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Hyderabad
    As if you never asked me to do urs..1..2....n.. Times :roll:
     
  20. a_to_z123

    a_to_z123 asia://india/ka/bangalore

    Joined:
    Nov 4, 2004
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bangalore, India
    Re: help needed in C

    Just go to the 'Options-->Directories' Menu and set the paths where you've your TC copied to.
    e.g.
    For 'Include Directories' ------ C:\TC\INCLUDE\
    For 'Library Directories' ------ C:\TC\LIB\
    etc. etc.
    'Output Directory' is the one where you want your EXE files to be created.
    And I don't know what are the 'Source Directories' :)
    Anyway this much will solve your problem...
     
Thread Status:
Not open for further replies.

Share This Page