Tuesday, September 3, 2013

Structure

Example 1:

//Structure
#include <stdio.h>
struct student
{
  int eng;
  int maths;
  int science;
};
int main()
{
 int total;
 struct student stud;
 stud.eng = 75;
 stud.maths = 70;
 stud.science = 65;
 total = stud.eng + stud.maths +stud.science;
 printf("Total is %d\n",total);
 return 0;
}

//Video Tutorial that how to make a structure in C++






Example 2:

#include <iostream>
using namespace std;
struct student
{
  int eng;
  int maths;
  int science;
};
int main()
{
 int total;
 struct student stud;
 stud.eng = 75;
 stud.maths = 70;
 stud.science = 65;
 total = stud.eng + stud.maths +stud.science;
 cout<<"Total is "<<total<<"\n";
 return 0;
}




2 comments: