Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Language : C++ Identify the lines containing syntax or run-time erro

ID: 3699075 • Letter: P

Question

Programming Language : C++

Identify the lines containing syntax or run-time errors in the code segment below. Select all that apply.

float burgerPrice = 5.99, fryPrice = 3.99, shakePrice = 4.49;

float* bp, sp;

int *fp;

*bp = 5.75;

fp = &fryPrice;

sp = &shakePrice;

*bp = shakePrice;

declaration of pointers

assigning a floating point literal to bp

assign address of variable to fp

assign address of variable to sp

assign variable to bp

Programming Language : C++

Identify the lines containing syntax or run-time errors in the code segment below. Select all that apply.

float burgerPrice = 5.99, fryPrice = 3.99, shakePrice = 4.49;

float* bp, sp;

int *fp;

*bp = 5.75;

fp = &fryPrice;

sp = &shakePrice;

*bp = shakePrice;

Answers:

declaration of pointers

assigning a floating point literal to bp

assign address of variable to fp

assign address of variable to sp

assign variable to bp

Explanation / Answer

here are the answers..errors are hghlighted in bold..

================================================================

#include <stdio.h>

int main()

{
  
   float burgerPrice = 5.99, fryPrice = 3.99, shakePrice = 4.49;

float* bp, sp;

int *fp;

*bp = 5.75;

fp = &fryPrice; //error     fp is an integer point but assigned a float value

sp = &shakePrice; //error

*bp = shakePrice;

   return 0;
}

================================================================

Ony the below options gives syntax error.

assign address of variable to fp

assign address of variable to sp