Find the errors Each of the following declarations programs

Find the errors. Each of the following declarations, programs, and program segments has errors. Locate as many as you can. Multiple Answers. struct {Int x; float y;}; struct Values {String name; int age;}; struct TwoVals {int a, b;}; int main () {TwoVals.a = 10; Two Vals.b = 20; return 0;}

Solution

1. In first declaration the structure name after \"struct\" keyword is not specified.
And also the declaration of x is incorrect, it should be like:

struct Values
{
       int x;
       int y;
};


2. In the second declaration the data type of name is String which is incorrect.So it can be commented. And also at the end of the declaration instead of semi colon(;) colon has been used.

struct Values
{
      // String name;
       int age;
};

3. In the third declaration there is an error in main(). The object of the structure has not been defined. It should be defined as:

struct TwoVals
{
       int a,b;
}TwoVals;

int main()
{
    TwoVals.a=10;
TwoVals.b=20;
return 0;
}

 Find the errors. Each of the following declarations, programs, and program segments has errors. Locate as many as you can. Multiple Answers. struct {Int x; flo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site