Question

Read the following code. Is the description of the order of execution (listed below the code) correct? #include <stdio.h> voi1. main starts executing 2. main calls printPizzaArea function, passing the diameter of a pizza 3. printPizzaArea function ex

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

The answer of the given problem is below:

Explanation about the code given.

There is a two integer variable a and b in which a has value 4. we know that when we create variables in programming it reserves some space in the memory which has some address. so variable a and b will have memory adresses. now p1 is a pointer variable which has stored the address of a, it means p1 is pointing to a. now *p1 means the value stored in the memory address pointed by p1. p1 has pointed a and variable a has value 4 so the line b=*p1 means b will also have the value 4.

Now come to the question.

a.) The correct answer of the 1st question is option 1.

which is "a and b are declared to be integer variable".

b.) The correct answer of the 2nd question is " all four options are correct means 1 2 3 4"

c.) only options 1 and 2 are corrcet.

a and b is integer variable and p1 is declared to be pointer variable these statements are true.

d.) correct answers are option1 and option 2.

which is same as c maens a and b is integer variable and p1 is declared to be pointer variable

Here is the screenshot of the executed code in which u can see what is the output when above runs.

screenshot of code--

#include<bits/stdc++.h> using namespace std; int main() { int a=4,b; int *p1; p1=&a; cout<<p1<<endl; b=*p1; cout<<b; }

Ox7ffefb1c9edo 4 Program finished with exit code 0 Press ENTER to exit console. I

here in first line address pointed by p1 is printed,

and second line value of b which is 4.

Please upvote bro!!! if u have anu doubts comment me.

Add a comment
Know the answer?
Add Answer to:
Read the following code. Is the description of the order of execution (listed below the code)...
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
  • Modify the following C code to the changes listed below. Please format code correctly. #include <stdio.h>...

    Modify the following C code to the changes listed below. Please format code correctly. #include <stdio.h> #include <stdlib.h> #define SIZE 5 void displayData(int [], int s); void getData(int array[], int size) {     for(int i=0; i<SIZE; i++)     {         scanf("%d", &array[i]);     } } int main() {     int grades[SIZE];     for(int i=0; i<SIZE; i++)     {         grades[i] = 0;     }     getData(grades,SIZE);     displayData(grades, SIZE); } void displayData(int grades[], int size) {     for(int i=0; i<size;...

  • modify sample code from example two to calculate the surface area and volume of a sphere...

    modify sample code from example two to calculate the surface area and volume of a sphere givin the radius int main() Example 2 Introduction to structures and passing the structure variables as arguments into functions. 1. A structure is created with circle related variables. 2. Two functions are created related to circle calculations. 3. This example passes structure variables from the main function to the message Circle function 4. The message Circle function converts the structure variables into regular double...

  • c++ help Write a program that obtains the execution times for the following three code segments...

    c++ help Write a program that obtains the execution times for the following three code segments with the different n. code 1: for(int i = 0; i <= n; i++)   { x = i; } code 2: for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { x = i + j; } } code 3: for (int i = 0; i <= n; i++) { for (int j =...

  • Exercise 4 – Passing an argument to a new thread and reporting on execution times================...

    Exercise 4 – Passing an argument to a new thread and reporting on execution times===================================================================== Here are some miscellaneous items on threads and resource usage times. This is a very short exercise to learn how to pass an argument to a thread’s start function. Write a program called threadArgA.c that simply does the following: Pass a simple integer to a thread’s start function at thread creation time. ii) The thread function will assign this argument as variable int i (just...

  • C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream>...

    C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) {     /*     dynamic memory management     */     double * dmptr;     double circumference;         /*     add the code below to:     - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer     - assign 3.14 to the variable in heap via the pointer....

  • In the code (C++) below, if you input 2 as length and 4 as width, the...

    In the code (C++) below, if you input 2 as length and 4 as width, the output is: Enter the rectangle's length: 2 Enter the rectangle's width: 4 Length: 2 | Width: 4 | Area: 8 | Perimeter:12 We worked on this code during class, but there were some things that I did not understand. 1) how does compiler read"l" as length, "w" as width, etc.? I thought you had to update it first, like "w=width." 2) i thought you...

  • NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A...

    NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION.   Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...

  • In C please Write a function so that the main() code below can be replaced by...

    In C please Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...

  • PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs...

    PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to:             -define a recursive procedure/function and call it.             -use syscall operations to display integers and strings on the console window             -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9                      if n <= 5              =...

  • Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a...

    Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a class called Circle. The class should have an integer member variable named radius and three member functions; setRadius, getRadius, calArea; the functions' prototypes should be done inside the class declaration and the functions' definitions should come after the main function #include <iostream> using namespace std; const double PI = 3.14; // fill in the declaration of the class Circle here int main() { Circle...

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