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 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...

  • 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 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...

  • 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              =...

  • Must Follow Example code //Add name, date, and description here //preprocessor directives #de fine CRT SECURE...

    Must Follow Example code //Add name, date, and description here //preprocessor directives #de fine CRT SECURE NO WARNINGS #includestdio.h> - //Calculate the cost of the gas on a trip /Ideclare, ask, and get the price per gallon and the mpg /Icalculate and return (by reference) the cost of gas for the number of miles passed to the function void GasCost (double miles, double *gasTotalPtr) //using a 70 MPH speed limit and the miles passed to the function //calculate and return...

  • Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read...

    Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read and process a file containing customer purchase data for books. The books available for purchase will be read from a separate data file. Process the customer sales and produce a report of the sales and the remaining book inventory. You are to read a data file (customerList.txt, provided) containing customer book purchasing data. Create a structure to contain the information. The structure will contain...

  • Part 1: Use principles of inheritance to write code calculating the area, surface area, and volume...

    Part 1: Use principles of inheritance to write code calculating the area, surface area, and volume of rectangular objects. First, write an abstract super class RectangularShape, then write a subclass Rectangle that inherits from the super class to compute areas of rectangles, including squares if there is only one data. Finally, write another subclass Cuboid that inherits from its super class Rectangle above to compute surface areas and volumes of cuboids, including 3 equal sided cube. Must apply code-reusability in...

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
ADVERTISEMENT