Question
C programming insert program into menu template. My prof. wants us to use a menu template to display our programs. However, when I copy and
C programming insert program into menu template.
My prof. wants us to use a menu template to display our programs. However, when I copy and past my first program into the menu template I get errors.Thumbs up to anyone who can help!
Here is the menu template:
// Menu.cpp : Defines the entry point for the console application.
//
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
#include
void program_one();
void program_two();
void program_three();
void program_four();
void program_five();
int main()
{
int menu_option = 0;
while (menu_option != 9) {
printf("
printf("
printf("
printf("
printf("
printf("Please enter number or 9 to end ");
scanf("%d", &menu_option);
getchar();
if (menu_option == 1) program_one();
if (menu_option == 2) program_two();
if (menu_option == 3) program_three();
if (menu_option == 4) program_four();
if (menu_option == 5) program_five();
}
return(0);
getchar();
}
void program_one() {
/* Program One Goes Here*/
//
printf("Program One "); //Replace this line with your program.
//
getchar();
}
void program_two() {
/* Program Two Goes Here */
//
printf("Program Two "); //Replace this line with your program.
//
getchar();
}
void program_three() {
/* Program Three Goes Here */
//
printf("Program Three "); //Replace this line with your program.
//
getchar();
}
void program_four() {
/* Program Three Goes Here */
//
printf("Program Four "); //Replace this line with your program.
//
getchar();
}
void program_five() {
/* Program Three Goes Here */
//
printf("Program Five "); //Replace this line with your program.
//
getchar();
}
Here is program one I trying to inset:
#include
void change(float coin)
{
float abc = coin*10.0*10.0; /*12.59 * 10.0 * 10.0=1259*/
int sum = abc;
int x, y, z;
z = sum / 25; /* 1259/25= 50.36 */
printf(" %d quarters ", z);
sum = sum - z * 25; /*1259-50.36*25*/
y = sum / 10;
printf(" %d dime ", y);
sum = sum - y * 10;
x = sum / 5;
printf(" %d nickels ", x);
sum = sum - x * 5;
printf(" %d pennies ", sum);
}
int main()
{
float d;
printf(" Enter a value for change :");/*EXAMPLE TEST WITH $12.59*/
scanf_s("%f", &d);
change(d);
getchar();
getchar();
return 0;
}
program two:
#include
int main()
{
void computeProduct(float, float, float, float*);/*Prototype*/
void computeSum(float, float, float, float*); /*prototype*/
float firstnum, secnum, thirdnum, sum , product;
printf("Enter first three numbers:");
scanf_s("%f %f %f", &firstnum, &secnum, &thirdnum);
computeSum(firstnum, secnum, thirdnum, &sum); /*function call*/
computeProduct(firstnum, secnum, thirdnum, &product); /*function call*/
getchar();
printf(" The sum of the entered numbers is :%6.2f", sum);
printf(" The product of the entered numbers is:%6.2f",product);
getchar();
return 0;
getchar();
}
void computeProduct(float num1, float num2, float num3, float *prodaddr)
{
*prodaddr = num1 * num2 * num3;
getchar();
return 0;
}
void computeSum(float num1, float num2, float num3, float *sumaddr)
{
*sumaddr = num1 + num2 + num3;
getchar();
return 0;
}
program three:
#include
void liquid(Total) /*Prototytpe*/
{
int Ucup = Total;
int q, g, p;
printf("%d Cups ", Ucup);
g = Ucup / 16;
printf("%d gallons ",g);
q = Ucup / 4;
printf("%d Quarts ", q);
p = Ucup / 2;
printf("%d Pints ", p);
getchar();
}
int main() {
int cup_value;
printf("Please enter number of cups ");
scanf_s("%d", &cup_value);
liquid(cup_value);
/* Comments */
getchar();
getchar();
return 0;
}
program four:
#include
void yrCalc(long n, int *y, int *m, int *d)
{
int NoOfYears, NoOfMonths, NoOfDays, RemainingDays, temp;
NoOfYears = n / 365; /*calculate the No of years since 01/01/1900)*/
RemainingDays = n % 365;
NoOfMonths = RemainingDays / 30; /*get the no of months from the remaining days*/
NoOfDays = RemainingDays % 30;
*y = 1900 + NoOfYears;
*m = 01 + NoOfMonths;
*d = 01 + NoOfDays;
}
int main()
{
long TotalDays;
int yyyy, dd, mm;
printf("Enter the No of Days since 01/01/1900 : ");
scanf_s("%ld", &TotalDays);
yrCalc(TotalDays, &yyyy, &mm, &dd); /*pass the number and the addresses of the date's variables*/
printf("The date (in mm/dd/yyyy) is : %d/%d/%d", mm, dd, yyyy);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started