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.

Exam Paper Problems

01C-2019S #6951

( As In Exam - CBSE12A-2019 )

Rewrite the following C++ Program after removing any/all syntactical error(s)

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);
}
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

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

Nested Structure Initialisation #2928

Write the output of the following program.

Write the output of the following program.

Finding errors in structure declaration #2961

Find the errors in the following structure declaration.

struct Computer 

Find the errors in the following structure declaration.

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

Output writing using strcpy for structure string variables #2964

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

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;
}

Differences between structure and array #5366

Write the main differences between structure and array

Write the main differences between structure and array

Output writing using structure copy and strcat use #7684

struct Play {char Arr[20];int n;}; 
int main() 
{ 
  struct Play P={"JUD

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.

Output writing using structure copy and strcat use #7691

struct Employee{double salary,hra;};
void change(Employee &a,double h=

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.


Code Sheets:10  Exam Paper Problems:1  Solved Problems:7 
×
Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues


Back