Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ computer program please answer all practice correct from Q1 until Q3 I want the answer sure 100 % correct. and please sir When you

C++ computer program

please answer all practice correct from Q1 until Q3

I want the answer sure 100 % correct.

and please sir When you answer , put answer with its number . such as answer Q1 , answer Q2 like this .... thanks .image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed please sir answer correctly all auestion .

PRACTICE SECTION (30 marks) Practice 01 (A): One Dimensional Array (5 marks) 1. Copy, compile and run the program of Code_Examplel.cpp. Type 1 to 10 when ask for input. The program will produce the following output as shown in Figure 6.1. Note that the program is unable to display the correct value. Type 10integer numbers. Data #1:1 Data #2:2 Data #3:3 Data #4:4 Data #5:5 Data #6:6 Data #7:7 Data #8:8 Data #9:9 Data #10:10 Display in reverse order Data #10: 10 Data #9: 10 Data #8: 10 Data #7: 10 Data #6: 10 Data #5: 10 Data #4: 10 Data #3: 10 Data #2: 10 Data #1: 10 Data #0: 10 Press any key to continue Figure 6.1: Output Program 6.1 2. Now, without changing the original code, fix the program using array. Fix the C++ code at the highlighted lines as shown in Program 6.1. Then compile and run. Input the data as in Figure 6.1. Make sure you display the correct value. //Program 6.1: Working with arrays The main function calls a user-defined function named readData without transfers anything. The myProgram reads the input from the user up to 10 integer numbers. Then, it displays it in reverse order. */ #include #include using namespace std; const int N = 10; void myProgram(void); //prototype of myProgram int main(void) { my Program(); //calls myProgram and transfers nothing system ("pause"); return 0; 2 my Program function //********* my Program function // Read up to 10 integer numbers // Then, write the numbers back to the screen in its reverse order. void my Program(void) { const int noof Input = 10; int data[noof Input]={0}; /*declare data as an array and intialise set element with @*/ cout >data[i]; /*store the input value in the data array */ } //Display the input in reverse order cout =0; i--) { cout #include using namespace std; const int NO_OF_ROWS = 2; const int NO_OF_COLS = 4; typedef float NewType [NO_OF_ROWS] [NO_OF_COLS]; //declares a new data type 1/which is a 2 dimensional array of floats NewType val; // defines val as a 2 dimensional array of NewType void getData(); //prototype of getData void displayData(NewType array); //prototype of displayData int main() { getData(); //call getData function and transfer nothing system ("pause"); return 0; } getData // task: This function receive inputs from user // data in: None // data returned: None //********* void getData() void getData() { int noOfInput=0; cout > val[row_pos][col_pos]; } } displayData(val); //call displayData function and transfer array val displayData 5 Lab L05: Functions Prepared by: Mohd Helmy Abd Wahab This function displays all entered inputs // task: // data in: the array containing val // data returned: none void displayData (NewType array) for (int row_pos = 0; row_pos #include using namespace std; const int NO_OF_ROWS = 2; const int NO_OF_COLS = 4; typedef float NewType [NO_OF_ROWS] [NO_OF_COLS]; //declares a new data type 1/which is a 2 dimensional array of floats NewType val; // defines val as a 2 dimensional array of NewType void getData(); //prototype of getData void displayData(NewType array); //prototype of displayData 1/6.3(a) prototype of calculate int main() { getData(); //call getData function and transfer nothing cout> val[row_pos] [col_pos]; } 7 displayData(val); //call displayData function and transfer array val } // displayData // task: This function displays all entered inputs // data in: the array containing val // data returned: none //***** void displayData (NewType array) { for (int row_pos = 0; row_pos

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions