Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 26-09-2004, 02:29 PM   #1 (permalink)
Apprentice
 
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
Default How can I make these 2 programs in C ??


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.
zeeshan_04 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 26-09-2004, 03:31 PM   #2 (permalink)
Alpha Geek
 
NikhilVerma's Avatar
 
Join Date: May 2004
Location: India
Posts: 930
Default 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...
NikhilVerma is offline  
Old 26-09-2004, 03:37 PM   #3 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default Re: How can I make these 2 programs in C ??

Quote:
Originally Posted by zeeshan_04
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
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");
  }
}


Quote:
Originally Posted by zeeshan_04
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
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 ?
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 26-09-2004, 03:37 PM   #4 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default

hey nikhil bhai, i was just typing when you posted your's !!!! But you've written in C++
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 26-09-2004, 03:40 PM   #5 (permalink)
Apprentice
 
Join Date: Nov 2003
Posts: 67
Default

Quote:
If anyone has any probs regarding programming in C++ ... Just ask me...
too
sniper is offline  
Old 26-09-2004, 04:13 PM   #6 (permalink)
Apprentice
 
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
Default

Thanks .

I want the programs to be made without using "for". U can use while
zeeshan_04 is offline  
Old 26-09-2004, 04:47 PM   #7 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default

Quote:
Originally Posted by zeeshan_04
Thanks .

I want the programs to be made without using "for"
No thanks.... you can make it yourself....
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 26-09-2004, 05:58 PM   #8 (permalink)
Apprentice
 
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
Default

I made it
zeeshan_04 is offline  
Old 26-09-2004, 07:19 PM   #9 (permalink)
In The Zone
 
Join Date: Feb 2004
Location: Chennai
Posts: 300
Default

cool... if i need help... i will post

need help in Data Structures with C++ ! Anyone good on that ?
__________________
Vande Mataram - Two words that became a Fiery War Cry and Electrified the nation towards Freedom. A mantra that instills a sense of Pride and belonging.
go4inet is offline  
Old 26-09-2004, 08:09 PM   #10 (permalink)
Apprentice
 
Join Date: Sep 2004
Location: Godless Savage Garden.
Posts: 61
Default

Why you ppl make others to do your home work???
__________________
Bother no one. If someone bothers you, ask him to stop. If he does not stop, destroy him.
Visit: http://bodybuilding.name/
diab0lic666 is offline  
Old 26-09-2004, 09:15 PM   #11 (permalink)
Alpha Geek
 
NikhilVerma's Avatar
 
Join Date: May 2004
Location: India
Posts: 930
Default

Quote:
Originally Posted by go4inet
cool... if i need help... i will post

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

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


Quote:
Originally Posted by diab0lic666
Why you ppl make others to do your home work???
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...
NikhilVerma is offline  
Old 27-09-2004, 02:32 AM   #12 (permalink)
In The Zone
 
Join Date: Jan 2004
Location: Panaji - Goa
Posts: 255
Default

hey dat was easy stuff! I mean 2 say those c progs.
__________________
Ish Karo... Ishq karna Tumhara Paidaishi Haq Hai........
Magar Kyon Na Is Bar Watan Ki Mitti Ko Mashuka bana le!!!

:) http://www.aseemn.org
Aseem Nasnodkar is offline  
Old 27-09-2004, 11:03 AM   #13 (permalink)
Apprentice
 
Join Date: Nov 2003
Posts: 67
Default

I own Data structures
sniper is offline  
Old 27-09-2004, 06:08 PM   #14 (permalink)
Alpha Geek
 
NikhilVerma's Avatar
 
Join Date: May 2004
Location: India
Posts: 930
Default

Quote:
Originally Posted by sniper
I own Data structures
Really!
I thought you knew them...
NikhilVerma is offline  
Old 22-12-2005, 11:37 AM   #15 (permalink)
Banned
 
slugger's Avatar
 
Join Date: May 2004
Location: Baudland
Posts: 2,433
Default 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
slugger is offline  
Old 22-12-2005, 12:03 PM   #16 (permalink)
In The Zone
 
puja399's Avatar
 
Join Date: Jul 2005
Posts: 324
Default

Quote:
Originally Posted by NikhilVerma
....
There's noting wrong when you ask someone to do your homework..
Yeah.. If you repeatedly ask for it then it's wrong...
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.
puja399 is offline  
Old 22-12-2005, 02:51 PM   #17 (permalink)
Wise Old Owl
 
aadipa's Avatar
 
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
Default

Quote:
Originally Posted by puja399
Quote:
Originally Posted by NikhilVerma
....
There's noting wrong when you ask someone to do your homework..
Yeah.. If you repeatedly ask for it then it's wrong...
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.
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.
__________________
i generally prefer quality over quantity
1 aadi + 1 aadi = 1 full ;)
aadipa is offline  
Old 22-12-2005, 04:56 PM   #18 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

^^ exactly... Post your own code before asking for suggestions...

@slugger: Check if your paths are correct in options->directories.
kalpik is offline  
Old 22-12-2005, 05:57 PM   #19 (permalink)
Alpha Geek
 
__Virus__'s Avatar
 
Join Date: Sep 2005
Location: Hyderabad
Posts: 560
Default

Quote:
Originally Posted by diab0lic666
Why you ppl make others to do your home work???
As if you never asked me to do urs..1..2....n.. Times :roll:
__Virus__ is offline  
Old 22-12-2005, 11:55 PM   #20 (permalink)
asia://india/ka/bangalore
 
a_to_z123's Avatar
 
Join Date: Nov 2004
Location: Bangalore, India
Posts: 293
Default Re: help needed in C

Quote:
Originally Posted by slugger
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.
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...
__________________
:) I've got my F, C and K . Now all I need is You !!! :)
a_to_z123 is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by bhaskar
- by soumya
- by clinton
- by Who
- by Sujeet

Advertisement




All times are GMT +5.5. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2