Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#CPP#6951

Problem Statement - 01C-2019S

Rewrite the following C++ Program after removing any/all syntactical error(s). Underline each correction done in the code:

Note: Assume all required header files are already included in the profram.

 

#define Area(L,B) = L*B
structure Recta
{
  int Length, Breadth;
};
  void main()
{
  Recta R= [10, 15];
  cout<<Area(Length.R, Breadth.R);
}

Solution

#define Area(L,B)  L*B   //Define should not have =
struct Recta                       //only struct is written not full structure
{
int Length, Breadth;
};
void main()
{
Recta R= {10, 15};         // { } braces are used for initialisation and not [ ]
cout<<Area(R.Length, R.Breadth); //Object name comes before data item name so R.Length and not Length.R
}