Fix the code to print the result[] array properly:
Answer:
At line no:27 no need of brackets in the above code.
in the below code line no:19
i gave input value of x is 1.
firstArray[2] is assigned to{10,20}
then secondArray[0] is assigned to 1.
and secondArray[1] assigned to x+15 means 1+15, that is 16.
this is the program and result was printed.
Thank you...
Fix the code to print the result[] array properly: 1 #include <iostream> 2 3 using namespace...
Question 1: Fix the 2D dynamic array initialization in following code #include <iostream> using namespace std; int main(){ int rows = 5; int cols = 5; int x; int** arr = new int[rows][cols] cin >> x; arr[x][x] = x; cout << "arr[x][x] = " << arr[x][x]; return 0; } Question 2: Fix the code to initialize the 2D array elements to x #include <iostream> using namespace std; int main(){ int rows; int cols; int x;...
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"; }
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(){...
Fix the code to print the "exact" result of the division of a/b (Pass by reference) #include <iostream> using namespace std; void division (int& a, int& b, int& result) { result = a/b; } int main () { float a, b, result; cin >> a; cin >> b; division(a, b, result); cout << "result = " << result << endl; return 0; }
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...
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; }
#include#includeusing namespace std;// Implement printArray here// Implement deleteSmallest here// DO NOT CHANGE MAIN FUNCTION BELOWint main() {int myarray[100];cout << "Enter number of integers : ";int n;cin >> n;cout << "Enter " << n << " integers" << endl;for (int i = 0; i < n; i++)cin >> myarray[i];cout << "Contents of array : ";printArray(myarray, n);deleteSmallest(myarray, n);cout << "Contents of array after deleteSmallest: ";printArray(myarray, n-1);}
Make the pointer point at the 5th element of an array 1 #include <iostream> 3 using namespace std; 4 //make the pointer point at the 5th element of an array 6 int main) 7 int x[10]; 9 cin x[i]; 10 11 int*ptr; 12 13 14 cout <<*ptr << endl; 15 1 #include 3 using namespace std; 4 //make the pointer point at the 5th element of an array 6 int main) 7 int x[10]; 9 cin x[i]; 10 11 int*ptr;...
The following code will not compile. Fix it by inserting one line of code. Do not change anything else. Hint: copy and paste the code below into your answer box, then make the required addition. Also include a comment indicating the line of code that you inserted, and why that line of code is required include <iostream> using namespace std int mainO cout <<"The word of the day is: sayword 0 return 0 void sayWordO f cout くく "WORD!";