-
1. Given this snippet of codes, what is the expected output?
void func(int *x, int y)
{
*x = *x + y;
y = 2;
}
void main()
{
int x = 10, y = 10;
func(&x, y);
printf("x: %d, y: %d", x, y);
}
x= ? y=?
2.
Given this snippet of codes, what is the expected output?
void func(int *x, int y)
{
*x = *x + y;
x = 10;...
-
1. (TCO 1) What is the output of the following
C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j < 5; j++)
cout << list[j];
(Points : 4)
0 1 2 3 4
0 5 10 15
0 5 10 15 20
5 10 15
20
Question 2.2. (TCO 1) What is stored in alpha
after the following code executes?
int alpha[5] = {0};
int j;
for (j = 0; j...
-
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...
-
Question 1 2 pts
The preprocessor executes after the compiler.
False
True
Question 2 2 pts
What code is human-readable and follows the standards of a
programming language?
Secret code
Source code
Key code
None of these
Machine code
Question 3 2 pts
What is the symbol that marks the beginning of a one line
comment?
Question 1 2 pts
The preprocessor executes after the compiler.
True
False
Question 5 2 pts
A statement that may be used to stop...
-
void insertion_sort(int array[], int length, int & count_comp, int & count_move);
void merge_sort(int array[], int length, int & count_comp, int & count_move);
void heap_sort(int array[], int length, int & count_comp, int & count_move);
void quick_sort_sort(int array[], int length, int & count_comp, int & count_move);
// YOUR
// Implementation
// should
// go
// here
// or be put in separated .cpp files
typedef void (*sort_algo_type)(int array[], int length, int& count_comp, int & count_move);
void run_sort_algo(int array[], int length, sort_algo_type sorting,...
-
Q1. Write a recursive function
in C++
void printNumberedChars(string str, int i=0) {
... }
which prints each character of the given string str on a new
line, with each line numbered 1, 2, 3, …. For example calling the
function with printNumberedChars("hello"); should output the
following:
1. h
2. e
3. l
4. l
5. o
Q2. Write a recursive function
in C++
int sumArray(const int* arr, unsigned int size)
{ ... }
which takes an array of integers,...
-
1. What will be the value of x after the following
code is executed?
int x = 10, y = 20;
while (y < 100)
{
x += y;
}
A. 90
B. 110
C. 210
D. This is an infinite loop
2. If a superclass has constructor(s):
A. then its subclass must initialize the superclass
fields (attributes).
B. then its subclass must call one of the constructors
that the superclass does have.
C. then its subclass does not inherit...
-
C++
Consider the definition of the following class: (1,2,3, 5,7 clasa productTyp publie productType O productType(int. double, double) productType (atring, int, double, double)s //tine6 productType (atring. atring.atring //Line1 /Line 2 /Line 3 //Line /Line s int, double, double) //Line 7 void set (atring, atring, string. int void print) const double, double) i //Line //tine 9 void setQuantitiesInstock (int x) void updateQuantitiesinstock (int x) int getQuantitiesInstock) const //Line 10 //Line 11 //Line 12 void #etPrice (double x); double getPrice) consti //Line...
-
I need a c++ code please.
32. Program. Write a program that creates an integer constant
called SIZE and initialize to the size of the array you will be
creating. Use this constant throughout your functions you will
implement for the next parts and your main program. Also, in your
main program create an integer array called numbers and initialize
it with the following values (Please see demo program below): 68,
100, 43, 58, 76, 72, 46, 55, 92, 94,...
-
what is the output for the following code? explain the
steps.
/*#include <iostream>
using namespace std;
int f(int &i)
{
i = 10;
return(5 * i);
}
int main()
{
int n = 5;
f(n);
cout << n << "\n";
return 0;
}
#include <iostream>
using namespace std;
int sub1(int n)
{
n--;
return n;
}
int main()
{
int m = 10;
for(int j = 0; j < 10; j++)
m -= sub1(j);
cout << m << "\n";
return...