Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 11-30-2004, 02:47 PM   #1 (permalink)
cloud's Avatar
 
Super Techie

Join Date: Nov 2004

Posts: 406

cloud is on a distinguished road

Talking Yet another C program....

sorry to keep posting these things, but my teacher just sort of threw me into C, and I'm having trouble. Here' s my problem:

I have to make a program that takes a number from the user , between 0-12. Then posts a string of numbers from 0 to that number. example, if the user puts in 5, it will give:

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

Then it stays open and continues until the user puts in a number not between 0-12 then it terminates.

I've been trying and the best i can get is if i put in 5 it gives me:
012345

I've been workin on it for a long time and i'm really getting frustrated.:mad:

Any advice will be welcome, and sorry for all the qestions.
__________________
antec nine hundred
abit IP35 pro
Q6600 @ 3.3ghz
Evga 8800GTX
4GB Corsair XMS 800
150gb WD 10k
300gb seagate 7.2k
22" Samsung 5ms lcd
21" Sceptre lcd
cloud is offline  
Old 12-01-2004, 12:02 AM   #2 (permalink)
 
Ultra Techie

Join Date: Jun 2004

Posts: 973

intercodes

Send a message via Yahoo to intercodes
Default

cloud,

#include <stdio.h>
int main(void)
{
int no,i,j;
printf ("Enter a number bet 1-12 : ");
scanf("%d",&no);
for(i=0;i<=no+1;i++)
{
for(j=0;j<i;j++)
{
printf ("%d",j);
printf (" ");
}
printf("\n");
}
}
intercodes is offline  
Old 12-01-2004, 12:34 AM   #3 (permalink)
cloud's Avatar
 
Super Techie

Join Date: Nov 2004

Posts: 406

cloud is on a distinguished road

Default

Thanks again codes, savin my life
__________________
antec nine hundred
abit IP35 pro
Q6600 @ 3.3ghz
Evga 8800GTX
4GB Corsair XMS 800
150gb WD 10k
300gb seagate 7.2k
22" Samsung 5ms lcd
21" Sceptre lcd
cloud is offline  
 
Closed Thread

Thread Tools
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