Hi everyone. This is my 3rd program I have ever written in C and I am needing some help. The objective is to display the total number of coins for each type, the monetary value by type, the total monetary value for all coins, and the total number of all coins. I don't really know if I am doing this right. I was hoping someone could lead me in the right direction in the "Option B" part of my program. First of all, I keep coming up with the error message
error C2144: syntax error : 'int' should be preceded by ';'
but I cannot figure out where it is actually talking about it. I would appreciate any suggestions to lead me in the right direction. Thank you in advance.
Allison
Code:
<#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define MAX 5
void display_menu();
char get_choice();
void option_A();
void option_B();
void main()
{
char choice;
do
{
display_menu();
choice = get_choice();
switch(choice)
{
case 'A':
option_A();
break;
case 'B':
option_B();
break;
}
} while(choice != 'C');
}
void display_menu()
{
system("cls");
printf("\n~~Select one of the following options~~\n\n");
printf("A-------Option A-The Magic Number!\n");
printf("B-------Option B-Counting Change!\n");
printf("C-------Quit\n");
}
char get_choice()
{
char ch;
do
{
ch = toupper(_getch());
} while (!strchr("ABC",ch));
return ch;
}
void option_A()
{
int magic,
guess,
tries = 0;
srand( (unsigned)time( NULL ) );
magic = rand()%MAX;
system("cls");
printf("\n\nGuess the random number from 0 to %d\n\n",MAX);
do
{
printf("guess: ");
scanf_s("%d",&guess);
if(guess == magic)
{
printf("** Right **");
printf("%d is the magic number\n", magic);
}
else
if (guess > magic)
printf(".. Wrong .. Too High\n");
else
printf(".. Wrong .. Too Low\n");
tries++;
} while(guess != magic);
printf("You took %d tries.\n", tries);
printf("\n\n\n\nPress any key to return to the main menu!");
_getch();
}
void option_B()
int count()
{
double num;
double pennies;
double quarters;
double dimes;
double nickels;
double half;
printf("Enter pennies amount: \n");
scanf_s("%d",pennies);
printf("Enter quarters amount: \n");
scanf_s("%d",quarters);
printf("Enter dimes amount: \n");
scanf_s("%d",dimes);
printf("Enter nickels amount: \n");
scanf_s("%d",nickels);
printf("Enter half dollar amount: \n");
scanf_s("%d",half);
quarters = (num * .25);
dimes = (num * .10);
nickels = (num * .05);
pennies = (num * .01);
half = (num * .50);
printf ("Your amount contains the following");
printf ("quarters: " ,quarters);
printf ("dimes: " ,dimes);
printf ("nickels: " ,nickels);
printf ("pennies: " ,pennies);
printf ("Half dollars:", half);
scanf_s("%d", &num);
return 0;
}