How can I integrate these programs into this menu template:
#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(" = 1\n"); //Change this to your first program name. Nothing else.
printf(" = 2\n"); //Change this to your second program name. Nothing else.
printf(" = 3\n"); //Change this to your third program name. Nothing else.
printf(" = 4\n"); //Change this to your fourth program name. Nothing else.
printf(" = 5\n"); //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\n\n"); //Replace this line with your program.
//
getchar();}
void program_two() {
/* Program Two Goes Here */
//
printf("Program Two\n\n"); //Replace this line with your program.
//
getchar();}
void program_three() {
/* Program Three Goes Here */
//
printf("Program Three\n\n"); //Replace this line with your program.
//
getchar();}
void program_four() {
/* Program Three Goes Here */
//
printf("Program Four\n\n"); //Replace this line with your program.
//
getchar();
}
void program_five() {
/* Program Three Goes Here */
//
printf("Program Five\n\n"); //Replace this line with your program.
//
getchar();
}
Here are the programs I need intergrated into it:
#include
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("\n Largest element is: %d\n", large);
printf("This is element number %d in the list of numbers\n", largeIndex);
printf("\n Smallest element is: %d\n", small);
printf("This is element number %d in the list of numbers\n", smallIndex);
return 0;
}
here is program two
#include
main() {
char strtest[] = "This is a test";
int i = 0;
for (i = 10; i <= 14; i++)
{
printf("%c", strtest[i]);
}
}
program three:
#include
void show(double rates[], int size) {
int i;
for (i = 0; i
printf("%lf ", rates[i]);
}
printf("\n");
}
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
#include
void display(int a, int e, int i, int o, int u)
{
int k;
printf("a |");
for (k = 1; k <= a; k++)
printf("*");
printf("\ne |");
for (k = 1; k <= e; k++)
printf("*");
printf("\ni |");
for (k = 1; k <= i; k++)
printf("*");
printf("\no |");
for (k = 1; k <= o; k++)
printf("*");
printf("\nu |");
for (k = 1; k <= u; k++)
printf("*");
printf("\n +----|----|----|");
printf("\n0 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("\n");
display(a, e, i, o, u);
getchar();
return 0;
}
program five:
#include<stdio.h>
#define r 6
#define c 2
int main()
{
int arr[r][c] =
{ {16,18},{23,54},{91,11},{24,52},{77,16},{19,59} };
dump(arr);
min_max(arr);
return 0;
}
void dump(int arr[][c])
{
int i, j;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
printf("%d", arr[i][j]);
}
printf("\n");
}
}
void min_max(int arr[][c])
{
int i, j, min = arr[0][0], max = arr[0]
[0], min_pos_row, min_pos_col, max_pos_row, max_pos_col;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
if (arr[i][j] < min)
{
min = arr[i][j];
min_pos_row = i + 1;
min_pos_col = j + 1;
}
if (arr[i][j]);
{
max_pos_row = i + 1;
max_pos_col = j + 1;
}
}
}
printf("\nMinimum element in array: %d in %d row %d column", min, min_pos_row, min_pos_col);
printf("\n Maximum element in array:%d in %d row %d column", max, max_pos_row, max_pos_col);
}
#include<stdio.h>
#define temp 10
#define r 6
#define c 2
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("1.programOne\n"); //Change
this to your first program name. Nothing else.
printf("2.programTwo\n"); //Change
this to your second program name. Nothing else.
printf("3.programThree\n");
//Change this to your third program name. Nothing else.
printf("4.programFour\n"); //Change
this to your fourth program name. Nothing else.
printf("5.programFive\n"); //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();
else if (menu_option==2)
program_two();
else if (menu_option==3)
program_three();
else if (menu_option == 4)
program_four();
else if(menu_option==5)
program_five();
}
}
void program_one()
{
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("\n Largest element is: %d\n", large);
printf("This is element number %d in the list of
numbers\n", largeIndex);
printf("\n Smallest element is: %d\n", small);
printf("This is element number %d in the list of
numbers\n", smallIndex);
return 0;
}
void program_two()
{
char strtest[] = "This is a test";
int i = 0;
for (i = 10; i <= 14; i++)
{
printf("%c", strtest[i]);
}
printf("\n");
}
void program_three()
{
double rates[9] = {
6.5,8.2,8.5,8.3,8.6,9.4,9.6,9.8,10.0 };
int i;
for(i=0;i<9;i++){
printf("%lf ", rates[i]);
}
printf("\n");
}
void display(int a, int e, int i, int o, int u)
{
int k;
printf("a |");
for (k = 1; k <= a; k++)
printf("*");
printf("\ne |");
for (k = 1; k <= e; k++)
printf("*");
printf("\ni |");
for (k = 1; k <= i; k++)
printf("*");
printf("\no |");
for (k = 1; k <= o; k++)
printf("*");
printf("\nu |");
for (k = 1; k <= u; k++)
printf("*");
printf("\n +----|----|----|");
printf("\n0 5 10 15");
}
void program_four()
{
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("\n");
display(a, e, i, o, u);
}
void dump(int arr[][c])
{
int i, j;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
printf("%d",
arr[i][j]);
}
printf("\n");
}
}
void min_max(int arr[][c])
{
int i, j, min = arr[0][0], max = arr[0][0],
min_pos_row, min_pos_col, max_pos_row, max_pos_col;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
if (arr[i][j]
< min)
{
min = arr[i][j];
min_pos_row = i + 1;
min_pos_col = j + 1;
}
if
(arr[i][j]);
{
max_pos_row = i + 1;
max_pos_col = j + 1;
}
}
}
printf("\nMinimum element in array: %d in %d row %d
column", min, min_pos_row, min_pos_col);
printf("\n Maximum element in array:%d in %d row %d
column", max, max_pos_row, max_pos_col);
}
void program_five()
{
int arr[r][c] ={
{16,18},{23,54},{91,11},{24,52},{77,16},{19,59} };
dump(arr);
min_max(arr);
}
How can I integrate these programs into this menu template: #define _CRT_SECURE_NO_WARNINGS #include #include #include #include...
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
can u please solve it in c++ format,,,, general format which is #include<stdio.h> .......printf and scanf format dont worry about the answers i have down Q3, What is the output of the program shown below and explain why. #include #include <stdio.h> <string.h> int main(void) ( char str[ 39764 int N strlen(str) int nunj for (int i-0; i t Nǐ.de+ printf(") num (str[] 'e); I/ digits range in the ASCII code is 48-57 if (nue > e) f 9 printf( Xdin,...
what is the output? Consider the following program: #include <stdio.h> #include <stdlib.h> #define size 3 void func(int **a) {int tmp; for (int i = 0; i < size; i++) {for (int j = i; j < size, j++) {tmp = *(*(a+i)+j); *(*(a+i)+j) = *(*(a+j)+i); *(*(a+j)+i) = tmp;}}} int main() {int **arr = malloc(sizeof(int*) * size); for(int i = 0; i < size; i++) {arr[i] = malloc(sizeof(int) * size); for (int j = 0; j < size, j++) arr[i][j] = 2*i...
C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <iostream> #include <fstream> #include <string> using namespace std; int measureElementsPerLine(ifstream& inFile) { // Add your code here. string line; getline(inFile, line); int sp = 0; for (int i = 0; i < line.size(); i++) { if (line[i] == ' ') sp++; } sp++; return sp; } int measureLines(ifstream& inFile) { // Add your code here. string line; int n = 0; while (!inFile.eof()) { getline(inFile,...
C program-- the output is not right please help me to correct it. #include <stdio.h> int main() { int arr[100]; int i,j,n,p,value,temp; printf("Enter the number of elements in the array: \n "); scanf("%d",&n); printf("Enter %d elements in the array: \n",n); for(i=0;i<n;i++) { printf("\nelement %d: ",i); scanf("\n%d",&arr[i]); } printf("\nEnter the value to be inserted: \n "); scanf("\n%d",&value); printf("The exist array is: \n"); for(i=0;i<n;i++) { printf("%d",arr[i]); } p=i; for(i=0;i<n;i++) if(value<arr[i] ) { p = i; break; } arr[p]=value; printf("\n"); for (i =...
Need help with my ksmall program. I get an error saying segmentation dump. Thanks #include<iostream> using namespace std; int ksmall(int*, int, int , int); void swap(int*, int*); int main() { int SIZE = 10; int target; int begining=0; int ending=SIZE-1; int *array1= new int[SIZE]; cout << "Enter 10 integers: " << endl; for (int i=0; i<SIZE; i++) { cin>>array1[i]; } cout << " What is the Kth smallest number...
I need some with this program, please look at the changes I need closely. Its running correctly, but I need to do a few adjustments here is the list of changes I need: 1. All of the integers on a single line, sorted in ascending order. 2. The median value of the sorted array on a single line 3. The average of the sorted array on a single line Here is the program: #include<stdio.h> #include<stdlib.h> /* This places the Adds...
Write a program that replace repeated three characters in a string by the character followed by 3. For example, the string aabccccaaabbbbcc would become aabc3ca3b3cc. When there are more than three repeated characters, the first three characters will be replaced by the character followed by 3. You can assume the string has only lowercase letters (a-z). Your program should include the following function: void replace(char *str, char *replaced); Your program should include the following function: void replace(char *str, char *replaced);...
OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include<ctype.h> #define MAX_LEN 255 int numWords(char *str); int numDigit(char *str); int numUppltr(char *str); int numLwrltr(char *str); int punChar(char *str); char*readString(char *str); int main() { char givString[MAX_LEN]; puts("Enter your string(Max 255 characters):"); //readString(givString); gets(givString); printf("\nnumber of words :%d",numWords(givString)); printf("\nnumber of uppercase letters %d",numUppltr(givString)); printf("\nnumber of lowercase letters %d",numLwrltr(givString)); printf("\nnumber of punctuations %d\n",punChar(givString)); printf("\nnumber of digits:%d\n",numDigit(givString)); system("pause"); return 0; } char *readString(char *str) { int ch, i=0; while((ch=getchar())!=EOF && ch!='\n') { if(i) { str[i]=ch; i++; }...