My teacher just told us that we have to write this program that it will compile in ".c" i was taught ver little in my intro about c++ however i dont know how to write in .c and although i told my teacher he insisted that i read the book (which i have) but i still dont know how i should go about making this program can someone assist me here is the assignment.

Program Specification:

Vera takes a jar which contains exactly 1,000 quarters to the casino with the intention to win big. She plays three machines slot machines in sequence. Unknown to her, the machines are entirely predictable.

Each play costs one quarter.

The following are constants:
The first machine pays 25 quarters every 33th time it is played;
the second machine pays 75 quarters every 99th time it is played;
the third pays 7 quarters every 9th time it is played.

So she will always lose - eventually.

Notice that she plays the machines one at a time in sequence: the first one, then the second one, the third one, the first one, the second one… You are to assume when she begins playing each machine the payout counters are set to zero for each machine.

Your program will output the number of times Vera plays until she goes broke along with the result of each time she wins money. Besides “main” you must define and use at least 4 functions.

Your program will input the number of quarters in Vera’s jar (it could be any number but for this assignment make it 1,000).

Your program will output a statement EVERYTIME Vera wins money. The output will contain the following:
1. The Number of Machine (1, 2, or 3) that she just won on
2. The Amount she just won (formatted like dollars and cents)
3. The current number of quarters remaining in the jar immediately after the win and the amount of money in the jar (i.e. there are 47 quarters in the jar with equals $11.75.
Once Vera is broke you will output put the total number of times she was able to play the machines.

Edited 5 Years Ago by Mark198995: n/a

The problem description is a good start. Now you have to think about how to organize your code. Nothing (much) to do with the language, mostly to do with logic. You will have an int main() just like in C++; and per the instructions, you will need at least four more functions. Perhaps you will want a data structure to hold the results of the run so a function can print them out. Probably you will want a function to return the outcome of Vera's next play on each of the three machines.

How you organize those functions (call them from main, in what order, and when to stop) is your task. The posters at DaniWeb will not do your work for you, but only help you make it right/better.

if you are using windows just save the file in .c extension and compile it as done for c++(for Dec C++ n Turbo C)
if you are using linux terminal. do the following steps:-

$cc <filename.c>
$./a.out

Ummmm c has same functionality as c++ with some exceptions but procedural part is almost same but the main factor is your logic and algorithm.
work with you logic if you still be having doubt,show the error along with code deniweb welcomes you for help.. :)

This article has been dead for over six months. Start a new discussion instead.