
#include <stdio.h>
int main() {
int lett,n,i;
printf("Insert a letter -> ");
scanf("%c",&lett);
printf("Insert a number -> ");
scanf("%d",&n);
printf("A Triangle will be designed with the '%c' letter composing it, and of %d lines \n",lett,n);
int g=0;
for(i=1;i<=n;i++) {
//for ()
g=i;
while(g)
{
printf("%c",lett);
--g;
}
printf("\n"); }
//system("PAUSE");
return 0;
}


AscaL wrote:thx a lot for the help man... only thing is that i still didn't do the "while", i can't really use it ^^
as far as i think it should just be something with the two for thing
beside i'm not sure even what a for in a for does... i just started and i'm still learning
ps: i didn't even do the "--g"... just did the x++ in the for loop



tgoe wrote:@msbachman
Unformatted code *within* code tags? How is this possible? xD
AscaL wrote:i'm studying at the university, not at home... i can't just go and skip things or use knowledge i'm not supposed to have to make an exercise... there would be no point....
int nonsense_function(int g)
{
g+=g;
nonsense_function(g);
if(g>=100000)
return g;
}

msbachman wrote:
- Code: Select all
int nonsense_function(int g)
{
g+=g;
nonsense_function(g);
if(g>=100000)
return g;
}

thetan wrote:msbachman wrote:
- Code: Select all
int nonsense_function(int g)
{
g+=g;
nonsense_function(g);
if(g>=100000)
return g;
}
That function doesn't do anything at all, instead it will perform head recursion endlessly until stack space is entirely consumed and then it will error out. (yes, this program does nothing more then eat ~8mb of ram and then crashes via segmentation fault)
So to conclude on your last post, i'd say that such a method is useless.

Avery17 wrote:I think he just posted it as an example, he even stated that it doesn't do anything. Just to show him the concept of how it works.
Avery17 wrote:With some added checks it could prove quite useful for this problem.

Users browsing this forum: No registered users and 0 guests