Detailed Print – Computer Sir Ki Class


Lost your password?

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

Solved Problem!#CPP#2961

Problem Statement - Finding errors in structure declaration

Find the errors in the following structure declaration.

struct Computer {
 char type[40]="Laptop";
 char p;
 Computer comp;
 float price; 

Click to open popup


struct Computer {

char type[40]=”Laptop”;     //ERROR
A strucutre variable can not be initialised directly as done here. A structure doesn’t have memory of its own so it doesn’t have a place to store any data

char p;

Computer comp; //ERROR
A structure can not recursively nest to itself.

float price;

};c1[20]                //ERROR
This should be written as }c1[20]; A semicolon must always end a structure declaration.