Login


Lost your password?

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


Shop
CPP All : Structures Basics
Concept Learning Code Sheets
Structures demo program with int and char array #2767 

A program using structure with two different type of variables int and char[] grouped in one structure.

Creating global instances or objects of structures #2777 

A technique to create instances of a structure which can be used by many functions,

Initialising structure variables while creating instances #2795 

A demonstration of initialisation of values of variables while creating the instances of the structures.

Effect of partial or no intialisation of structure instance variables #2799 

Understanding default values in case of partial or no initialisation of structure instances.

Structure instance creation using pointer based notation #2911 

A system of creating structure instances using pointer based notation or the method indicating the address location of the structure.

Structure instance copying #2916 

Copying one instance of structure to another for the instances derived from the same structure definition

Case where structure instance copy is not allowed #2920 

A program to explain the case where instance copying is not permitted.

Nesting of strucutres #2924 

A program to demonstrate nested structures with one structure called within another structure.

Nested Structures Initialisation #2934 

Program to demonstrate the initialisation process of nested structures.

Preparing Array of Structures #2938 

Program to demonstrate how an array of structures is prepared to get entry of multiple similar type of data entries.

Solved Problems
Collect student details to structure and update selectively #2781 

Write a program to collect follow entry about an student in a structure type c++ data structure.
integer – rollno, char array – name, float – marks and char passfail. Declare a global instance of this structure and then collect the rollno,name and marks in the main routine. Within the main routine update the value of passfail as ‘Y’ or ‘N’ if the marks are more than or equal to 33.0 . Finally it should report as per following example.

R.No. Name Marks Status
———————————
22       Vijay  45         Pass

Write a program to collect follow entry about an student in a structure type c++ data stru ...
Finding errors in structure declaration #2961 
Find the errors in the following structure declaration.

struct Computer {
 char type[40]="Laptop";
 char p;
 Computer comp;
 float price; 
};c1[20]
Find the errors in the following structure declaration.

struct Computer {
 char t ...		
Output writing using strcpy for structure string variables #2964 

Write the output of the following program. Assume that required header files are present.

struct Game {
  char Magic[20];int Score;
};

int main()
{
  Game M={"Tiger",500};
  char a[20];
  cout<<M.Magic<<", "<<M.Score<<endl;
  strcpy(a,M.Magic);
  a[0]='L'; a[2]='o'; a[3]='n'; a[4]='';
  strcpy(M.Magic,a);
  M.Score++;
  cout<<M.Magic<<", "<<M.Score<<endl;
  return 0;
}
Write the output of the following program. Assume that required header files are present. ...
01C-2019S #6951 

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);
}
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline e ...
Output writing using structure copy and strcat use #7684 
struct Play {char Arr[20];int n;}; 
int main() 
{ 
  struct Play P={"JUDO",2};
  P.Arr[0]='L';
  P.n+=2; 
  cout<<P.Arr<<"#"<<P.n<<endl;   
  Play R = P;
  R.Arr[0]='S';R.Arr[1]='O';
  strcat(R.Arr,"KU");
  R.n-=3; 
  cout<<R.Arr<<"#"<<R.n<<endl; 
  return 0; 
}

Write the output of the above program. Assume that required header files are present.

struct Play {char Arr[20];int n;}; 
int main() 
{ 
  struct Play P={"JUDO",2};
   ...		
Output writing using structure copy and strcat use #7691 
struct Employee{double salary,hra;};
void change(Employee &a,double h=100)
{
  a.salary+=1000;
  a.hra+=h;
}   
int main() 
{ 
  Employee A={5000,2000};
  cout<<"Initial Payment  = "<<A.salary+A.hra<<endl;
  change(A,500);
  cout<<"After 1st Change = "<<A.salary+A.hra<<endl;   
  change(A);
  cout<<"After 2nd Change = "<<A.salary+A.hra<<endl;
  return 0; 
}

Write the output of the above program. Assume that required header files are present.

struct Employee{double salary,hra;};
void change(Employee &a,double h=100)
{
  ...		
Exam Questions
CBSE12A-2019-A01C  01C-2019S #6951 

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);
}
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline e ...

Code Sheets:10  Solved Problems:7  Exam Questions:1 
Back