1. (2 points each) Indicate whether each of the following statements are valid or invalid function declarations (prototypes) by highlighting your answer choice (Are they syntactically correct?).
a) double change( X, Y); answer: Valid Invalid
b) char sign(double x); answer: Valid Invalid
c) int max(int x, int y, int z) answer: Valid Invalid
2. (2 points each) Indicate whether each of the following statements are syntactically valid or invalid function headers by highlighting your answer choice.
a) double change( X, Y); answer: Valid Invalid
b) char sign(double x); answer: Valid Invalid
c) int max(int x, int y, int z) answer: Valid Invalid
3. (2 points each) Indicate whether each of the following statements are syntactically valid or invalid function call statements by highlighting your answer choice.
a) change( X, Y); answer: Valid Invalid
b) sign(double x); answer: Valid Invalid
1. Function declaration: In this, the return type, function name, number and order of parameters and their data types are provided to the compiler.
Syntax: return_type function_name(parameter list);
Therefore,
a.) Answer: Invalid
Reason: The data type of parameters are not defined.
b.) Answer: Valid
Reason: Everything as mentioned in the syntax shown above has been there in the declaration.
c.) Answer: Valid
Reason: Correct as mentioned in the syntax above described.
2. Function header: When defining a function, it contains function header and the body. So the function header is similar to function declaration but there is not semi colon in the last whereas it has curly braces to contain body.
a.) Answer: Invalid
Reason: Does not have data types of the parameters.
b.) Answer: Invalid
Reason: It has everything as mentioned in the syntax but has a semi colon which makes it a declaration rather than function header.
c.) Answer: Valid
Reason: Everything matches with the syntax without a semi colon.
3. Function call: A call has to make to function so as to use it to perform defined task. To make a call parameters needed to be passed along with the function name and If values is returned by the function then need to be store in a variable.
Syntax: function_name(parameters)
a.) Answer: Valid
Reason: The statement is according to the syntax therefore it is valid.
b.) Answer: Invalid
Reason: Since the parameters data type has also been passed so it is invalid.
1. (2 points each) Indicate whether each of the following statements are valid or invalid function...
Consider the following declarations as you determine whether each of the assignment statements in questions 6-12 is valid or invalid (it either won't compile or could crash):
DauGR Code 2. State whether the following are valid function names and if so, whether they're mnemonic names that convey some idea of the function's purpose. If they are invalid names, state why (10 points). a. ObtainName b. getAge&Sex c. double DauGR Code 2. State whether the following are valid function names and if so, whether they're mnemonic names that convey some idea of the function's purpose. If they are invalid names, state why (10 points). a. ObtainName b. getAge&Sex...
Problem - 1: For the following declarations below, indicate which of the following statements are valid or not 5 Points int At yAddst; long *dtAddst, ptAddst; double *ptZ int a long b; double c 1. yAddst =&a; 3. yAddst Atl 4, pt2=&a; 5, ptAddst &b: 2. yAddst =&c; Problem - 2: Consider Problem - 1 in HW-3 that calculates the value of the series e, sinx, cos r using functions. Now modify this C++ program to calculate the value of...
Problems 9-35 odd numbers only(9,11,13,15 …35) k newNum numi (int) (4.6/2)1 . Do a walk-through to find the value assigned to e. Assume that all variables are properly declared. a -31 es" (a%b) * 6; e-(a b+ d)/ 4 10. Which of the following variable declarations are correct? If'a variable declaration is not correct, give the reasoníy) and provide the correct variable declaration. n = 12; char letter int one = 5, two; //Line 3 double x, Y zi //tine...
Consider the following program: # include <iostream> using namesapce std; void Func(int a, int bl double number-25.0: int main) f int x-18, y-20; cout<c"Before: x- kex<" and y-eyecendl; Fundxy 1// end of main void Funcfint a, int b) int sum a+b; a-200; b-300; numberanumber+1.0 Which of the statements below are correct? (Select only the correct answers. There may be more than one) D A The statement double number-25.0; declares a global variable number B. The variables x and y are...
1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...
,,1. Which of the following statments are valid C++ statements? A) cout << "Hello World" : B) cout << Hello World; C) cout << "Hello " << "World" ; D) cout << "Hello" << "World" ; 2. What is the difference between the literals 'A' and "A"? ,3. Read the input from user; Check for valid entries If input is invalid: print an error message; else: calculate the result and print to the console; exit; The code snippet above may...
2. For each function, find all critical points and use the Hessian to determine whether they are local maxima, minima, or saddle points. (a) f(x,y,z) = x — 2 sin x – 3yz (b) g(x, y, z) = cosh x + 4yz – 2y2 – 24 (c) u(x, y, z) = (x – z)4 – x2 + y2 + 6x2 – 22