How can I integrate these programs into this menu template: #define _CRT_SECURE_
ID: 3711109 • Letter: H
Question
How can I integrate these programs into this menu template:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
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("<program name one> = 1 "); //Change this to your first program name. Nothing else.
printf("<program name two> = 2 "); //Change this to your second program name. Nothing else.
printf("<program name three> = 3 "); //Change this to your third program name. Nothing else.
printf("<program name three> = 4 "); //Change this to your fourth program name. Nothing else.
printf("<program name three> = 5 "); //Change this to your fifth program name. Nothing else.
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 are the programs I need intergrated into it:
#include <stdio.h>
int main()
{
#define temp 10
int user_data[temp];
int i;
int total = 0;
int small, smallIndex;
int large, largeIndex;
int b;
int s;
/*inputing the numbers*/
for (i = 0; i < temp; i++) {
printf("Please enter a number:");
scanf_s("%d", &user_data[i]);
}
small = user_data[0];
large = user_data[0];
/*Displaying the numbers*/
for (i = 1; i < temp; i++)
{
if (user_data[i] < small) {
smallIndex = i;
small = user_data[i];
}
if (user_data[i] > large)
{
largeIndex = i;
large = user_data[i];
}
}
printf(" Largest element is: %d ", large);
printf("This is element number %d in the list of numbers ", largeIndex);
printf(" Smallest element is: %d ", small);
printf("This is element number %d in the list of numbers ", smallIndex);
return 0;
}
here is program two
#include<stdio.h>
main() {
char strtest[] = "This is a test";
int i = 0;
for (i = 10; i <= 14; i++)
{
printf("%c", strtest[i]);
}
}
program three:
#include<stdio.h>
void show(double rates[], int size) {
int i;
for (i = 0; i<size; i++) {
printf("%lf ", rates[i]);
}
printf(" ");
}
int main() {
double rates[9] = { 6.5,8.2,8.5,8.3,8.6,9.4,9.6,9.8,10.0 };
show(rates, 9);
getchar();
}
program four:
#include<stdio.h>
#include<string.h>
void display(int a, int e, int i, int o, int u)
{
int k;
printf("a |");
for (k = 1; k <= a; k++)
printf("*");
printf(" e |");
for (k = 1; k <= e; k++)
printf("*");
printf(" i |");
for (k = 1; k <= i; k++)
printf("*");
printf(" o |");
for (k = 1; k <= o; k++)
printf("*");
printf(" u |");
for (k = 1; k <= u; k++)
printf("*");
printf(" +----|----|----|");
printf(" 0 5 10 15");
}
int main()
{
char str[200];
gets(str);
int a = 0, e = 0, i = 0, o = 0, u = 0;
int k;
for (k = 0; k < strlen(str); k++)
{
if (str[k] == 'a' || str[k] == 'A')
a++;
else if (str[k] == 'e' || str[k] == 'E')
e++;
else if (str[k] == 'i' || str[k] == 'I')
i++;
else if (str[k] == 'o' || str[k] == 'O')
o++;
else if (str[k] == 'u' || str[k] == 'U')
u++;
}
printf(" ");
display(a, e, i, o, u);
getchar();
return 0;
}
Explanation / Answer
//including header files
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
//function declaration
void program_one ();
void program_two ();
void program_three ();
void program_four();
void program_five();
//Main Program
int main()
{
int menu_option = 0;
while (menu_option != 9) {
printf(" <program name one> = 1 "); //Change this to your first program name. Nothing else.
printf("<program name two> = 2 "); //Change this to your second program name. Nothing else.
printf("<program name three> = 3 "); //Change this to your third program name. Nothing else.
printf("<program name three> = 4 "); //Change this to your fourth program name. Nothing else.
printf("<program name three> = 5 "); //Change this to your fifth program name. Nothing else.
printf("Please select program 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();
}
//function definition
void program_one()
{
/* Program One Goes Here*/
//
#define temp 10
int user_data[temp];
int i;
int total = 0;
int small, smallIndex;
int large, largeIndex;
int b;
int s;
/*inputing the numbers*/
for (i = 0; i < temp; i++) {
printf("Please enter number :");
scanf("%d", &user_data[i]);
}
small = user_data[0];
large = user_data[0];
/*Displaying the numbers*/
for (i = 1; i < temp; i++)
{
if (user_data[i] < small) {
smallIndex = i;
small = user_data[i];
}
if (user_data[i] > large)
{
largeIndex = i;
large = user_data[i];
}
}
printf(" Largest element is: %d ", large);
printf("This is element number %d in the list of numbers ", largeIndex);
printf(" Smallest element is: %d ", small);
printf("This is element number %d in the list of numbers ", smallIndex);
//
getchar();
}
void program_two()
{
/* Program Two Goes Here */
//
char strtest[] = "This is a test";
int i = 0;
for (i = 10; i <= 14; i++)
{
printf("%c", strtest[i]);
}
//
getchar();
}
void program_three()
{
/* Program Three Goes Here */
//
void show(double rates[], int size) {
int i;
for (i = 0; i<size; i++) {
printf("%lf ", rates[i]);
}
printf(" ");
}
double rates[9] = { 6.5,8.2,8.5,8.3,8.6,9.4,9.6,9.8,10.0 };
show(rates, 9);
//
getchar();
}
void program_four()
{
/* Program four Goes Here */
//
void display(int a, int e, int i, int o, int u)
{
int k;
printf("a |");
for (k = 1; k <= a; k++)
printf("*");
printf(" e |");
for (k = 1; k <= e; k++)
printf("*");
printf(" i |");
for (k = 1; k <= i; k++)
printf("*");
printf(" o |");
for (k = 1; k <= o; k++)
printf("*");
printf(" u |");
for (k = 1; k <= u; k++)
printf("*");
printf(" +----|----|----|");
printf(" 0 5 10 15");
}
char str[200];
gets(str);
int a = 0, e = 0, i = 0, o = 0, u = 0;
int k;
for (k = 0; k < strlen(str); k++)
{
if (str[k] == 'a' || str[k] == 'A')
a++;
else if (str[k] == 'e' || str[k] == 'E')
e++;
else if (str[k] == 'i' || str[k] == 'I')
i++;
else if (str[k] == 'o' || str[k] == 'O')
o++;
else if (str[k] == 'u' || str[k] == 'U')
u++;
}
printf(" ");
display(a, e, i, o, u);
//
getchar();
}
void program_five()
{
/* Program Three Goes Here */
//
printf("Program Five not given in example "); //Replace this line with your program.
//
getchar();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.