Please help! Studying for my c++ test!
include <iostream>
using namespace std;
void my_function(int n);
void main() {
my_function(546);
}
void my_function(int n) {
if (n < 10)
cout << n << endl;
else {
my_function(n/10);
cout << (n%10) << endl;
}
}
int j=32, k=5, r;
r = j ^ k;
cout << r << "#";
r = j << 2;
cout << r << "#" << endl;
QUESTION (1):-
OUTPUT:
5
4
6
#include <iostream> // error missing #
using namespace std;
void my_function(int n);
int main() { // error return type must be int
my_function(546);
return 0;
}
void my_function(int n) {
if (n < 10)
cout << n << endl;
else {
my_function(n/10);
cout << (n%10) << endl;
}
}
QUESTION (2):-
OUTPUT: 37#128#
#include <iostream>
using namespace std;
int main() {
int j=32, k=5, r;
r = j ^ k;
cout << r << "#";
r = j << 2;
cout << r << "#" << endl;
return 0;
}
Please help! Studying for my c++ test! What does the following code produce? include <iostream> ...
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...
My C++ code won't loop like it should. What am I doing wrong? #include <iostream> using namespace std; int main() { int n; int flag= 1; cout << "Prime/Not Prime" << endl; cout << "Enter the Number to check Prime:" << endl; cin >> n; int m = n / 2; int i; for (i = 2; i <= m; i++) if (n % i == 0) ...
Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...
Question 28 What is the output of the following program? Assume code is correct. #include <iostream> using namespace std; int main() { int i = 1,j,x = 5, y = 4; while (i <= y) { for (j = 0; j <= y2; j++) cout << 'Z'; cout << endl; i=i+1; } return 0; 3 B IV AA-I E333 X X, B, GT 12pt Paragraph
Fix the following code to print whether the input is positive or negative #include <iostream> #include <string> using namespace std; void positiveOrNegative(int); // declare function int main(){ int y; int result; cin >> y; result = positiveOrNegative(y); return 0; } void positiveOrNegative(int x){ if (x>=0) cout << "Positive"; else cout << "Negative"; }
Convert the below code into if else selection: #include <iostream> using namespace std; int main() { int num; sin. >> num; switch (num) { case 1: cout << "Casel: Value is: << num << endl; break; case 2: break; case 3: cout << "Case3: Value is: " << num << endl; break; default: cout << "Default: Value is: << num << endl; break; } return; }
Subject: Object Oriented Programming (OOP)
Please kindly solve the above two questions as soon as possible
would be really grateful to a quick solution. would give a thumbs
up.
Thank you!
Q3: Question # 3 [20] Will the following code compile? If it does not, state the errors. If it does compile, write the output. //Function.cpp #include <iostream> using namespace std; void printData (long i) cout<<"In long print Data "«<i<<endl; } void printData(int i) cout<<"In int printData "<<i<<endl; ) void...
C++ Fix the errors in the following code. (Not all errors are syntax related) #include <iostream> using namespace std; int main() { //Part A int numA numA = 10; cout << numA << end; /* Part B */*/ int numB = numA; cin >> usrInput; int usrInput = 0; numB = numB + usrInput; cout << numB <"/n"; /* Part C */ int numC = 10000000000; cout << numC << endl; return 0; }
include<iostream> #include<cstring> using namespace std; char reg[30]; int main() { //char reg[30]; char DNA[30]; int flag = 0; int n, ni, i, j, k; cout << "Enter a regular expression" << ; cin >> reg; cout << endl; n = reg.size(); for (int i = 0; i < n; i++) { strcpy(DNA, reg.substr(i, j)); ni = DNA.lenghth(); for (k = 0; k < ni;...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...