C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter E, Problem E.12E
Program Plan Intro
#define SQR(x) x* x:
when preprocessor expands this macros it will produce the square of the suppiled number correctely and will not give any error.
#define SQR(x) (x*x):
when preprocessor expands this macros it will produce the square of the suppiled number correctely and will not give any error.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C-programming
Execute the following operation for the 2D matrix input M.
Print the matrix M on the screen in matrix format
Display the transpose of the matrix M
Find the max of each column of matrix M and write to a file
Input
From the keyboard, user will enter:
The matrix size.the elements of the matrix.Choice of which process to execute.
Output
Program will show :
Matrix size .Choice of process :1. Display the matrix2. Display the matrix and its transpose3. Display the matrix and max values from each column and write to the file4. Exit
When user choose '1' print the matrix M.When user choose '2' print the matrix M and its transpose.When user choose '3' print the matrix M and Max value for corresponding column below it. Then print "File is successfully created!" when a file is successfully created. If it is not successfully created it will print "File is failed to be created!".When user choose '4' terminate the program
ADDITIONAL FEATURESThe program will give repetition for…
7. Translate the following function into pseudo-assembly:
Void swap_nums(int a, int b){
if (a
b)
return a;
3
int temp = 0;
temp = a;
a = b;
b temp;
C language for solution
Note: soution this program Use Array
1. Write a program to do the following:
a. Write a Cover Page function to print the HW details passing the needed
parameters and has no return.
b. Write a function that gets student grades and ID (maximum number of
students is 20) then the function has a switch statement to enable the user to
choose one of the following operation:
i. Call MaxMin function to find and print the maximum and minimum
grades as well as their ID
ii. Call function Average to return the average grade of the class.
iii. Call mark function to print students ID, their grades, and marks (as in
the below table)
iv. Call Sort function to sort the student ascending or descending based
on their grades.
The program will repeat the operation tile the user wish to terminate the program.
Note:
Student's grades are between 0 and 100 (use data validation technique).
• You will get zero if you don't use comments and print HW details (your name,
course name, course…
Chapter E Solutions
C++ How to Program (10th Edition)
Knowledge Booster
Similar questions
- In the function malloc(), each byte of allocated space is initialized to zero. a) True b) Falsearrow_forwardIn C++ Write the following functions.1) Int**createArray(int **arr, int row, int colm);In this function just pass 2D pointer ,row and column size as arguments and create 2D dynamic array against received 2D pointer and return the 2D pointer from function. 2) inputArray(int **arr, int row, int colm)Input values in array;3) displayArray(int **arr, int row, int colm);Display the values of 2D array. 4) sumOfEven(int **arr, int row, int colm);Display the sum of even values into the array.Main function should be something as below.int main(){int **arr;int row,col;cout<<”enter row: ”;cin>>row;cout<<”enter column: ”;cin>>col;arr=createArray(arr,row,col);inputArray(arr,row,col);displayArray(arr,row,col);sumOfEven(arr, row, col);return 0;}arrow_forwardQ3. A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Given the C code and memory content mapping shown in Figure 4, complete the Table 2 after the program execution. #include ... Ox11223344 a int main() { int a = 2018, b = 2020; ... Ox12345678 int *ptr_a = &a, *ptr_b = &b; OX8899AABB ptr_a *ptr_a = a + 50; *ptr_b = *ptr_b - *ptr_a; OX89ABCDEF ptr_b ptr_b = ptr_a; ..... ... return 0; Figure 4. C code and memory content mapping. Table 2 Variable Value a) |b b) &ptr_a c) ptr_b d) *ptr_barrow_forward
- Using pointers create a c program with a function that asks for a maximum number of inputs and counts how many even numbers are there in the array. Example: Enter max inputs: 3 Enter input 1: 561 Enter input 2: 780 Enter input 3: 943 Even count: 1 Even numbers: 780 Address: xarrow_forwardC++ Code: This function will print out the information that has been previously read (using the function readData) in a format that aligns an individual's STR counts along a column. For example, the output for the above input will be: name Alice Bob Charlie ---------------------------------------- AGAT 5 3 6 AATG 2 7 1 TATC 8 4 5 This output uses text manipulators to left-align each name and counts within 10 characters. The row of dashes is set to 40 characters. /** * Computes the longest consecutive occurrences of several STRs in a DNA sequence * * @param sequence a DNA sequence of an individual * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @returns the count of the longest consecutive occurrences of each STR in nameSTRs **/ vector<int> getSTRcounts(string& sequence, vector<string>& nameSTRs) For example, if the sequence is AACCCTGCGCGCGCGCGATCTATCTATCTATCTATCCAGCATTAGCTAGCATCAAGATAGATAGATGAATTTCGAAATGAATGAATGAATGAATGAATGAATG and the vector namesSTRs is…arrow_forwardUsing the concept of a pointer to pointer create a c++ program that adds two float values *(*p1)+*(*p2)arrow_forward
- Write the function that prints a 23 numbered array sent into it with the mainfunction.in C programming (Please generate the 23 numbers randomly)arrow_forwardPROBLEM 3 Using python, write a function named display_elist() that reads data from the data structures generated by the read_file() function and prints the e-list to the terminal according to the following format. Here is the e-list for Mart 007 ------------------ Welcome ------------------ ============================================= Please select the item you want to buy from the following menu: 1. Spiked Umbrella ($7.25 each), 5 available 2. Voice Changer ($5.5 each), 10 available 3. Spy Camera ($15.0 each), 8 available Press 4 when you are done! =============================================arrow_forwardparameter list can also contain the data type of the output of function : true/false a function declared int addition (int a and b) is capable of returning one value back to the main loop : true/false main () is a void function: true / false the address returned by the reference pointer is always the same regardless of operating system: true/false a function declares as int addition (int a, int b) has a and b as output arguments : true/ falsearrow_forward
- 15. The only way to access data stored in heap memory is through pointer variables malloc () allocation tables а. b. С. d. a buffer memoryarrow_forwarda C++ program that creates a two-dimensional integer array (4x3) initialized with user given data. The program should have the following functions: • Print the sum of all values in the array. • Print the average of all the values in the array. • Take row number from user and print the sum of the values in that specified row.(use loop and no if statement) • Take column number from user and print the sum of the values in that specified column.(use loop and no if statement)arrow_forward2. Test Scores File: test_scores.py Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score. When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data. Remember that we've done the JCU grades question before, so copy your function from that practical code file. Sample Output Score: 3 Score: 50.5 Score: 66 Score: 100 Score 3.0, which is N Score 50.5, which is P Score 66.0, which is C Score 100.0, which is HD The average score was 54.875 Enhancements When you have that working... We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning