GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Jul-2005, 20:33
likeit likeit is offline
New Member
 
Join Date: Jul 2005
Posts: 11
likeit is on a distinguished road

ask looping


i have a problem bout looping so the output prog like this:

1
11
111
1111

*
**
***
****
*****

*
**
***
**
*
i have problem to make a prog with algorithm and code-code,if u have any tips or from ur experience to create prog with quick ,pls share .thanks
  #2  
Old 24-Jul-2005, 20:49
Dave Sinkula Dave Sinkula is offline
Member
 
Join Date: Apr 2005
Posts: 199
Dave Sinkula will become famous soon enough
Quote:
Originally Posted by likeit
i have a problem bout looping so the output prog like this:
Would you care to share the problem with the rest of us? Or are we supposed to write your homework assignment for you? Why not just post your instructor's email so we can send it in directly?

[edit]Post what you have worked on, and folks will improve on it from there.
  #3  
Old 26-Jul-2005, 11:38
alcedo's Avatar
alcedo alcedo is offline
Member
 
Join Date: Jul 2005
Location: Singapore
Posts: 198
alcedo will become famous soon enough
Hmm how are we going to know the nature of the question you are asking ? and the problems you faced while doing the question?
__________________
People should read the rules and regulation before posting!

The Best is yet to be...
  #4  
Old 26-Jul-2005, 19:14
likeit likeit is offline
New Member
 
Join Date: Jul 2005
Posts: 11
likeit is on a distinguished road
i figure out the looping like this:
j=0 1 2 3
---------------
i=0 | 1
1 | 1 1
2 | 1 1 1
3 | 1 1 1 1

here is the code :
CPP / C++ / C Code:
#include<stdio.h>
#include<conio.h>
main(){
int a,i,j;
printf("many looping:");
scanf("%d",&a);
for(i=0;i<a;i++)
 for(j=0;j<a;j++)
   printf("1");
   printf("");
printf("\n");
getch();
return 0;
}

the output is :
1

i spend many time to find the design but it's hard to find the correct,can anyone help?
  #5  
Old 26-Jul-2005, 19:49
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by likeit
i figure out the looping like this:
j=0 1 2 3
---------------
i=0 | 1
1 | 1 1
2 | 1 1 1
3 | 1 1 1 1

here is the code :
CPP / C++ / C Code:
#include<stdio.h>
#include<conio.h>
main(){
int a,i,j;
printf("many looping:");
scanf("%d",&a);
for(i=0;i<a;i++)
 for(j=0;j<a;j++)
   printf("1");
   printf("");
printf("\n");
getch();
return 0;
}

the output is :
1

i spend many time to find the design but it's hard to find the correct,can anyone help?

Here's what I get when I run it:
Quote:
many looping:4
1111111111111111

which is exactly what I expected.

Since I'm note sure what you're thoughts are I'm not sure what you're trying to accomplish in the code. My first suggestion is to put braces around your for statements. I'll comment what you've got and maybe you can see what you need to do, or ask about.
CPP / C++ / C Code:
#include<stdio.h>
#include<conio.h>
main(){
int a,i,j;
printf("many looping:");
scanf("%d",&a);
for(i=0;i<a;i++)    // outer loop for row
{
 for(j=0;j<a;j++)   // inner loop for column
 {
   printf("1");  // always output a '1' for each position
 }
}
   printf("");   // when done, output a nuthing (empty string)
printf("\n");   // next line
getch();
return 0;
}
So first off, rearrange the braces so you start getting the lines correct.

Then you have to decide how to tell if you need to output a '1', and empty string, or another character. I'd recommend outputting a '0' or '-' until you get the pattern right:
1---
11--
111-
1111
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
 
 

Recent GIDBlogA Week in Kuwait by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
for looping prob Rosmayati C Programming Language 1 30-Jun-2004 11:39

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:10.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.