Question

Computer Science C++ Program What is the output? int num =5; int* ptr = # cout...

Computer Science C++ Program

What is the output?

int num =5;

int* ptr = #

cout << ptr << endl;

cout << &ptr << endl;

cout << *ptr << endl;

What are the values stored in the following array? Draw a simple picture of the array with indexes and show what each element should be.

int arrayExample [4] = { 5 };

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of code with output:

Please upvote.

Add a comment
Know the answer?
Add Answer to:
Computer Science C++ Program What is the output? int num =5; int* ptr = # cout...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the output? (3 pts) int num = 5; int* ptr = &num; cout <<...

    What is the output? (3 pts) int num = 5; int* ptr = &num; cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;

  • 51. What is the output of the following code snippet? int number = 0; int ptr_num...

    51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = &num; num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...

  • Examine each of the following program segments carefully. Determine what is printed from each program. There...

    Examine each of the following program segments carefully. Determine what is printed from each program. There are no intentional errors. 1. int array[] = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; i++) cout << array[i]*5 << “ “; Output _________________________________ 2. int *iptr; iptr = new int[5]; for (int count = 0; count < 5; count++) iptr[count] = count+1; cout << *iptr << endl; Output _________________________________ 3. int x = 50, y = 60,...

  • 4. Each of the following definitions and program s egments has errors. Rewrite them without errors....

    4. Each of the following definitions and program s egments has errors. Rewrite them without errors. a. int x, *ptr; = ptr; b. int x, *ptr; c. int x, *ptr; ptr 100; // Store 100 in x cout << x << endl; d. int numbers10, 20, 30, 40, 50); cout << "The third element in the array is"; cout << *numbers 3<< endl; e. int values [20], *iptr; iptr - values; ptr *= 2;

  • What is the output of the following C program? int x=1, y=2; int * const ptr...

    What is the output of the following C program? int x=1, y=2; int * const ptr = &x; ptr = &y; printf("%d\n", *ptr); What is the output of the following C program? int x=1, y=2; const int * ptr = &x; ptr = &y; printf("%d\n", *ptr); What is the output of the following C program? int x=1, y=2; int * ptr = &x; ptr = &y; printf("%d\n", *ptr); What is the output of the following C program? int x=1, y=2;...

  • 1.What will the following statement output? cout << &num1; A)None of these B)the value stored in...

    1.What will the following statement output? cout << &num1; A)None of these B)the value stored in the variable named num1 C)the number 1 D)the memory address of the variable named num1 E)the string &num1 2. What will the following code output? int number = 888; int *var = &number; cout << var << endl; A)the address of number B)an asterisk followed by 8888 C)8888 D)an asterisk followed by the address of number 3. Assuming ptr is a pointer variable, what...

  • 18 C++ 1. What is the output of the following program segment? int y-22: while ((y...

    18 C++ 1. What is the output of the following program segment? int y-22: while ((y 3) != 0) cout << y<< "": y=y-2; The output is 2. Suppose that the input is 100, 20,-8, 50, 20. What is the output of the following C++ code? int sum0 int num: int j cin >> num: if (num < 0) continue зит зит + num; cout<< sum << endl; The output is

  • howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE]...

    howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8};    int index;    index=0;    res = values[index];    for (int j=1; j<SIZE; j++)    {        if (values[j] > res)        {            res = values[j];            index = j;        cout << index << res << endl;        }    }    cout <<...

  • c++ Consider the following array definition: int values[5] = {4,7,6,8,2}; What does each of the following...

    c++ Consider the following array definition: int values[5] = {4,7,6,8,2}; What does each of the following statements display? cout << values[4] << endl; cout< < (values[2] + values[3])<<endl; cout << ++values[1] << endl; marks is an integer array with 20 elements. Write a for loop that prints each element of the array. The arrays numberArray 1 and numberArray2 have 100 elements. Write code that copies the values in numberArrayl to numberArray2.

  • What is the output of the following code? int num = 17;                           //Line 1 double...

    What is the output of the following code? int num = 17;                           //Line 1 double gpa = 3.85;                  //Line 2 bool done;                               //Line 3 done = (num == static_cast<int>( (2 * gpa + 9.3)));    //Line 4 cout << "The value of done is: "<< done << endl;     //Line 5

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT