Output
1
4
9
16
25
36
49
64
81
100
Total is385
What does the following program print? I // Exercise 3.12 Solution: ex03_12.cpp // What does this...
c++ only. Please follow directions. What does the following program print and why? Comment each line of code to explain what it is doing. #include <iostream> using namespace std; int main() { int track[ ] = { 10, 20, 30, 40 }; int * ptr; ptr = track; track[1] += 30; cout << * ptr << " "; *ptr -= 10; ptr++; cout << * ptr << " "; ptr += 2; cout << * ptr << " "; cout...
Can someone help me fix this program? //SwatTheBugs22.cpp - displays the following pattern of numbers //2 4 6 //8 10 12 //14 16 18 //20 22 24 //Created/revised by Brandon Tousignant on November 30, 2018 #include <iostream> using namespace std; int main() { int number = 0; for (int outer = 1; outer < 5; outer =+ 1) { for (int inner = 1; inner < 4; inner += 1) number += 2; cout << number << " "; //end...
4. (10 pts) Show the output of the following program: (list the program outputs in the order as they would appear on screen) #include <iostream> using namespace std; int Mystery(int); int main() int x=2, y: y=Mystery(x - 1)+1; cout << "x="«x«", y="«y < endl; y=Mystery( 2 *x); cout << "x="«x«", y="«y < endl; return 0; int Mystery (int num) int y=5; // This is a regular local variable, not a static local variable int result; y=y+num; cout << "y=" <y<",...
15.6: Fix the code to print the count from 1 to x (to loop x times) #include <iostream> // include the header file using namespace std; void count(int x){ for(int i=1; i<=x; i++){ cout<<x; } } int main(){ int x,i; cin >> x; count(x); return 0; } 15.7 Fix the nested for loops to print the count from 1 to x twice, e.g. "12....x12.....x" #include <iostream> // include the header file using namespace std; int main(){...
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
I have to type and explain in class each code in every detail filled with // commentary. Explains how does work in every codes. 1) What does the below print #include <iostream> using namespace std ; int main() { int var1 = 20 ; int var2 = 30 ; int* ptr1 ; int* ptr2 ; int* temp ; ptr1 = &var1 ; ptr2 = &var2 ; cout << *ptr1 << endl ;...
One dimensional array What this code print #include <iostream> using namespace std; int main () { const int SIZE = 7; int numbers [SIZE] = {1, 2, 4, 8): // Initialize first 4 elements cout << Here are the contents of the array:\n"; for (int index = 0; index < SIZE: index++} cout << numbers[index] << ; cout << endl; return 0; }
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"; }
Follow the instructions for starting C++ and viewing the Intermediate23.cpp file, which is contained in either the Cpp8IChap11\Intermediate23 Project folder or the Cpp8\Chap11 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) The program uses an array to store the amount of money a game show contestant won in each of five days. The program should display the total amount won and the average daily amount won. It should also display the day...
a) Hand-trace the following program and determine and write down what is the output of the code. b) Run the code and compare the program output to your hand-traced result obtained from part (a). #include <iostream> #include <iomanip> using namespace std; void f(); int x = 5; int main() { cout << "x = " << x << endl; int x = 6; cout << "x = " << x << endl; { int...