61. The following program is accepted by the compiler:
int sum( int x, int y )
{
int result;
result = x + y;
}
T__ F__
62. The following implementation is accepted by the compiler:
void product()
{
int a; int b; int c; int result;
cout << "Enter three integers: ";
cin >> a >> b >> c;
result = a * b * c;
cout << "Result is " << result;
return result;
}
T__ F__
63. The following program has no error:
using namespace std;
int main()
{
double number1, number2, sum;
cout << "Enter a number: ";
cin >> number1;
cout << "Enter another number: ";
cin >> number2;
sum = number1 + number2;
cout << "The sum of the two numbers is " << sum;
return 0;
}
T__ F__
64. The following program is syntactically incorrect:
#include <iostream>
using namespace std;
int main()
{
const number1, number2, product;
cout << "Enter two numbers and I will multiply\n";
cout << "them for you.\n";
cin >> number1 >> number2;
product = number1 * number2;
cout << product;
}
T__ F__
65. The following program is syntactically correct:
#include <iostream>
using namespace std;
int main()
{
double number1, number2, sum;
cout << "Enter a number: ";
cin >> number1;
cout << "Enter another number: ";
cin >> number2;
number1 + number2 = sum;
cout << "The sum of the two numbers is " << sum;
return 0;
}
T__ F__
66. The following is a function prototype:
CalcTotal();
T__ F__
67. Parameter names in a prototype are optional.
T__ F__
68. Overloaded functions:
A. are a group of functions with the same name and same
number of arguments.
B. are a group of functions with the same name and
different parameter types.
C. make life easier for the programmer.
D. none of the above.
69. The following function prototypes
int increment(char);
int increment(int);
are not accepted in C++ because they have the same name.
T__ F__
70. The following function prototypes are not accepted by compiler:
int GetValue();
double GetValue();
T__ F__
61. The following program is accepted by the compiler:
int sum( int x, int y )
{
int result;
result = x + y;
}
False, because the method has a return type integer but the method in its defination does not return anything.
62. The following implementation is accepted by the compiler:
void product()
{
int a; int b; int c; int result;
cout << "Enter three integers: ";
cin >> a >> b >> c;
result = a * b * c;
cout << "Result is " << result;
return result;
}
False, because the return type is void and we are returning an integer from the function
63. The following program has no error:
using namespace std;
int main()
{
double number1, number2, sum;
cout << "Enter a number: ";
cin >> number1;
cout << "Enter another number: ";
cin >> number2;
sum = number1 + number2;
cout << "The sum of the two numbers is " << sum;
return 0;
}
True, the program runs without error
64. The following program is syntactically incorrect:
#include <iostream>
using namespace std;
int main()
{
const number1, number2, product;
cout << "Enter two numbers and I will multiply\n";
cout << "them for you.\n";
cin >> number1 >> number2;
product = number1 * number2;
cout << product;
}
False, as we have not provided a data type to the variables number1,number2,product.
65. The following program is syntactically correct:
#include <iostream>
using namespace std;
int main()
{
double number1, number2, sum;
cout << "Enter a number: ";
cin >> number1;
cout << "Enter another number: ";
cin >> number2;
number1 + number2 = sum;
cout << "The sum of the two numbers is " << sum;
return 0;
}
False, as expression can be assigned to a variable, a variable can never be assigned to an expression
66. The following is a function prototype:
CalcTotal();
False, it should have a return type.
67. Parameter names in a prototype are optional.
true, you can have or not have parameters in a function
68. Overloaded functions:
A. are a group of functions with the same name and same
number of arguments.
B. are a group of functions with the same name and
different parameter types.
C. make life easier for the programmer.
D. none of the above.
Overloaded functions are the one with same names but different parameter types.
69. The following function prototypes
int increment(char);
int increment(int);
are not accepted in C++ because they have the same name.
False, they are accepted as they are overloaded functions with different data types.
70. The following function prototypes are not accepted by compiler:
int GetValue();
double GetValue();
True, as functions overloaded with different return types are not accepted.
if you like the answer please provide a thumbs up.
61. The following program is accepted by the compiler: int sum( int x, int y...
81. The following function call doesn’t agree with its prototype: cout << BoxVolume( 10, 5 ); int BoxVolume(int length = {1}, int width = {1}, int height = {1}); T__ F__ 82. The following function is implemented to swap in memory the argument-values passed to it: void swap(int a, int b) { int temp; temp = a; a = b; b = temp; ...
31. The following code segment is syntactically correct: int number{20}; cout << number << setbase(16) << " " << number << setbase(10) << " " << number << showpos << " " << number << endl; T__ F__ 32. The following statement wants to determine if ‘count’ is outside the range of 0 through 100: if (count < 0 && count > 100) T__ F__ 33. There is...
The program has errors. Identify and make the necessary changes to make the program work. Remember to follow the rules of functions and arrays. Here is the expected output Total = 20 Average = 15 Area = 150 Area = 70 Enter a value: 10 Value 1 entered = 10 Enter an integer: 20 Value 2 entered = 20 Enter an integer: 30 Value 3 entered = 30 .................................................................. #include <iostream> using namespace std; void total(int, int, int); double average(int...
41. Executing the "continue" statement from within a loop causes control to go A. to the next line of code B. out of the loop C. to the beginning of the loop D. to check the loop condition for repeating the loop E. none of the above 42. The 'default' statement inside a 'switch()' is optional. T__ F__ 43. The following 'switch' implementation is legal: int i = 2; ...
Flow chart of this program #include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
#include <iostream> #include <string> using namespace std; int main() { int number; int sum = 0; while(true) { cout << "Please enter a number between 1 and 11: "; cin >> number; if (number >= 1 && number <= 11) { cout << number << endl; sum = sum + number; //only add the sum when number is in range: 1-11, so add wthin this if case } else { cout << number << endl; cout << "Out of range;...
Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) { int Num1; cout << "Enter 2 numbers: "; cin >> Num2; if (Num1 < Num2) cout << "Smallest number is " << Num1; else cout << "Smallest number is " << Num2; return 0; }
Hello everyone! I am working on my assignment for C++ and I'm having a bit of trouble on the value producing functions, I am creating a program wherein I have to input a value and I need to create a function called square value where in it will square the value I have input. I cannot seem to figure out this part. Here is the code that I have so far, and thank you for any help. I greatly appreciate...
Write output of following program in C# afterremoving error if any. Note: Be sum of first two digit of your Roll no. Run the code after entering the value of B. Do not show error because of B. #include <iostream> using namespace std; class stud { public: char name[30.clas[10]; int rolage: void enter() { cout<<"Enter Student Name: "; cin>>name; cout<<"Enter Student Age: "; cin>>age; cout<<"Enter Student Roll number: "; cin>>rol; cout<<"Enter Student Class Year: "; cin>>clas; } void display {...