Hourglass in C++

Hi all!
I want to make an hourglass program, but the problem is i don't know how to do it!
I would like it more in C
Pls help me!
Last edited on
what do you mean by hour glass? a time program would look something like this

1
2
3
4
5
6
void waitt ( int seconds )
{
    clock_t endwait;
    endwait = clock () + seconds * CLOCKS_PER_SEC ;
    while (clock() < endwait) {}
}


and you could write a function to display a certain graphic per percent finished (say: glass full, half ful, empty, flip)

not exactly sure what you mean though
Lol thanks for the reply but it is not the hour i want :P

If the user inputs 3 it shows this:
***
*
***
If the user inputs 5 it shows this:
*****
***
*
***
*****
and so on! Pls help xD

Edit: Sorry but the chat window doesnt use spaces!
So it means that what you see is the half of the hourglass, i mean like the egyptian ones with
stars like this one: *
See an hourglass from this photo:
http://listverse.files.wordpress.com/2007/09/hourglass.jpg
Last edited on
I understand what an hour glass is, it is used to keep time. So if:
If the user inputs 3 it shows this:
***
*
***
If the user inputs 5 it shows this:
*****
***
*
***
*****
and so on


then what happens if you put 4? an error?
if it is an error than it is just a math algarithm which im sure you can figure out if you think about it. once you have this equation then for every input there should be an output and all you have to do is write a script to display a certain amount of *'s based on that output.
It needs to have only odd numbers :)
So if you ask me i think an exception
Pls help me with the hourglass!
Last edited on
Try to do this.
A function that will print n characters. This will be the prototype void print_char(int quantity, char character);
So if you call it like print_char(4, 'o'); that output will be
oooo

Don't add a line break.
I dont want a pattern of asterx
I wanted an hourglass
Can someone post the source code of the hourglass?
Also, i want it in C if possible
Last edited on
I just made the half of the hourglass in c, here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int hourglass(){
int i,j,k;

printf("Width of hourglass <positive odd number> \n");
scanf("%d",&k);


for(i=1; i>=k; i++)

{

for(j=1; j<=k-i; j++)

{
printf(" ");
}

for(j=1; j>=2*i-1; j++)

{
printf("*");
}

printf("\n");

}

for(i=1; i<k; i++)

{

for(j=1; j<=i; j++)

{
printf(" ");
}

for(j=2*k-2*i-1; j>=1; j--)

{
printf("*");
}

printf("\n");

}


Pls someone help! xD
Last edited on
Indent your code.
for(i=1; i>=k; i++)Do twenty push-ups

It may be easier if you modularize it.
If found it. Thank you all for the replies :)
Topic archived. No new replies allowed.