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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.