26-09-2004, 02:29 PM
|
#1 (permalink)
|
|
Apprentice
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
|
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.
|
|
|
|
Advertisements. Register and be a member of the community to get rid of them.
|
|
Advertisement
|
|
26-09-2004, 03:31 PM
|
#2 (permalink)
|
|
Alpha Geek
Join Date: May 2004
Location: India
Posts: 930
|
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...
|
|
|
26-09-2004, 03:37 PM
|
#3 (permalink)
|
|
FooBar Guy
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
|
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 ?
|
|
|
26-09-2004, 03:37 PM
|
#4 (permalink)
|
|
FooBar Guy
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
|
hey nikhil bhai, i was just typing when you posted your's !!!! But you've written in C++
|
|
|
26-09-2004, 03:40 PM
|
#5 (permalink)
|
|
Apprentice
Join Date: Nov 2003
Posts: 67
|
Quote:
|
If anyone has any probs regarding programming in C++ ... Just ask me...
|
too
|
|
|
26-09-2004, 04:13 PM
|
#6 (permalink)
|
|
Apprentice
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
|
Thanks .
I want the programs to be made without using "for". U can use while
|
|
|
26-09-2004, 04:47 PM
|
#7 (permalink)
|
|
FooBar Guy
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
|
Quote:
|
Originally Posted by zeeshan_04
Thanks .
I want the programs to be made without using "for"
|
No thanks.... you can make it yourself....
|
|
|
26-09-2004, 05:58 PM
|
#8 (permalink)
|
|
Apprentice
Join Date: Aug 2004
Location: Kutch, Gujarat
Posts: 67
|
I made it
|
|
|
26-09-2004, 07:19 PM
|
#9 (permalink)
|
|
In The Zone
Join Date: Feb 2004
Location: Chennai
Posts: 300
|
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.
|
|
|
26-09-2004, 08:09 PM
|
#10 (permalink)
|
|
Apprentice
Join Date: Sep 2004
Location: Godless Savage Garden.
Posts: 61
|
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/
|
|
|
26-09-2004, 09:15 PM
|
#11 (permalink)
|
|
Alpha Geek
Join Date: May 2004
Location: India
Posts: 930
|
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...
|
|
|
27-09-2004, 02:32 AM
|
#12 (permalink)
|
|
In The Zone
Join Date: Jan 2004
Location: Panaji - Goa
Posts: 255
|
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
|
|
|
27-09-2004, 11:03 AM
|
#13 (permalink)
|
|
Apprentice
Join Date: Nov 2003
Posts: 67
|
I own Data structures
|
|
|
27-09-2004, 06:08 PM
|
#14 (permalink)
|
|
Alpha Geek
Join Date: May 2004
Location: India
Posts: 930
|
Quote:
|
Originally Posted by sniper
I own Data structures
|
Really!
I thought you knew them...
|
|
|
22-12-2005, 11:37 AM
|
#15 (permalink)
|
|
Banned
Join Date: May 2004
Location: Baudland
Posts: 2,433
|
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
|
|
|
22-12-2005, 12:03 PM
|
#16 (permalink)
|
|
In The Zone
Join Date: Jul 2005
Posts: 324
|
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.
|
|
|
22-12-2005, 02:51 PM
|
#17 (permalink)
|
|
Wise Old Owl
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
|
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 ;)
|
|
|
22-12-2005, 04:56 PM
|
#18 (permalink)
|
|
In Pursuit of "Happyness"
Join Date: May 2005
Location: New Delhi
Posts: 3,432
|
^^ exactly... Post your own code before asking for suggestions...
@slugger: Check if your paths are correct in options->directories.
|
|
|
22-12-2005, 05:57 PM
|
#19 (permalink)
|
|
Alpha Geek
Join Date: Sep 2005
Location: Hyderabad
Posts: 560
|
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:
|
|
|
22-12-2005, 11:55 PM
|
#20 (permalink)
|
|
asia://india/ka/bangalore
Join Date: Nov 2004
Location: Bangalore, India
Posts: 293
|
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 !!! :)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|