There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark them in the code and explain the reason briefly in place.
#include<iostream>
using namespace std;
int main()
{
cout<<”Please input the radius (in integer): ”>>endl;
int 1var = 10, var=20;
double area = 40;
cin<< var; //get an input of the radius and store in var
float continue;
float const pi = 2.64;
pi += 0.5;
do
{
cout<<”The radius is ”<<”var”<<endl; //print the value of var to console
}while(var <0) //wanted to make sure that user input (var) >=0
area = pi*var; //variable area should store the area of the circle with radius var
return 0;
#include<iostream>
using namespace std;
int main(){
// ERROR 1: we should use << not >>
cout<<”Please input the radius (in integer):
”<<endl;
//ERROR 2: variale name can't start with digit
int var1 = 10, var=20;
double area = 40;
//ERROR 3
// we use >> to get input
cin>> var; //get an input of the radius and store in var
// ERROR 4: we can't use keywords as variale names
float continue;
float const pi = 2.64;
//ERROR 5: we can't change the value of const
pi += 0.5;
do
{
// ERROR: we shoud not use "" to print variable data
cout<<”The radius is ”<<”var”<<endl; //print the
value of var to console
var++; // ERROR 7: here we should change the value otherwise it
will be infinite loop
}while(var <0) // ERROR 6: ; semicolon missed
//wanted to make sure that user input (var) >=0
area = pi*var; //variable area should store the area of the circle with radius var
return 0;
Get Answers For Free
Most questions answered within 1 hours.