A simple program , need to see where's the mistake :)



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 :)

.



Relevant Pages

  • Re: A simple program , need to see wheres the mistake :)
    ... one star increasement at each line. ... int start = 1; ... junk.c:13: warning: return type defaults to `int' ... junk.c:27: warning: ISO C89 forbids mixed declarations and code ...
    (comp.lang.c)
  • [PATCH] Memory management livelock
    ... Here is a patch for MM livelock. ... The original bug report follows after the ... I declared a mutex starvation_barrier in struct ... int nr_pages; ...
    (Linux-Kernel)
  • Re: What *is* a CtrlID?
    ... It was a bug we knew ... This dates back to the days when C only had one type, 'int', which it ... This is an infinite loop (and it is subtle to detect, ... I found that just using signed integer even for data that ...
    (microsoft.public.vc.mfc)
  • Re: [Bug #12263] Sata soft reset filling log
    ... The following bug entry is on the current list of known regressions ... int tries = 5; ... * @buf: data buffer ...
    (Linux-Kernel)
  • Re: [PATCH 2/2] tracing/events/lockdep: move tracepoints within recursive protection
    ... RSP ... Either there's a bug in the vbin_printf, or we have some crazy lock->name? ... TP_PROTO(struct lockdep_map *lock, unsigned int subclass, ... The trace points in lockdep are called all the time. ...
    (Linux-Kernel)