A simple program , need to see where's the mistake :)
- From: "Odinn" <dalamartr@xxxxxxxxx>
- Date: 25 Oct 2006 12:34:41 -0700
Greetings , This is my first year at programming and 3rd week at this
so count me as a pure newbie.
I am trying to make a program that gets a number and prints out starts
as this:
For input 3 :
*
**
***
For input 6:
*
**
***
****
*****
******
As you see the program I am trying to make generates as much as lines
as the input number , one star increasement at each line.
This is the program I wrote:
#include <stdio.h>
star(int x)
{
int i=1;
while(i<=x)
{
printf("*");
i++;
}
}
print(int x){
int start = 1;
int end = x;
while (start <= end)
{
printf("%d \n", star(start) );
start++;
}
}
main()
{
printf("Enter value \n");
int veri;
scanf("%d", &veri);
print(veri);
}
Seems works but with a bug:
I always get a number after stars such as this:
Ex:
Enter value
8
*2
**3
***4
****5
*****6
******7
*******8
********9
Thanks in advance :)
.
- Follow-Ups:
- Re: A simple program , need to see where's the mistake :)
- From: Andrew Poelstra
- Re: A simple program , need to see where's the mistake :)
- From: CBFalconer
- Re: A simple program , need to see where's the mistake :)
- From: Andrew Poelstra
- Re: A simple program , need to see where's the mistake :)
- From: Christopher Benson-Manica
- Re: A simple program , need to see where's the mistake :)
- From: michael . kirby
- Re: A simple program , need to see where's the mistake :)
- Prev by Date: Re: Garbage Collection in C
- Next by Date: Re: fclose then fopen equivalent for stdout?
- Previous by thread: bit position
- Next by thread: Re: A simple program , need to see where's the mistake :)
- Index(es):
Relevant Pages
|