• Home
  • Game
  • C++
  • Java
  • Android
  • No Need
  • Latest Post

    Data Structure In C++

    There are a classroom where are hundred of student. They all have individual name, id, and age. If we want to collect their information we need to declare hundred of variables for name, hundred of variables for id, hundred of variable for age.  So we need to write a huge code for it. Array can help to reduce this code but when to want to update information one of student, it is hard.
    By using structure we can solve this problem. Data structure is the collection of various kinds of data under the same name. it is one kinds of advanced array system.
    Lets know more about data structure……
    Firstly we observe the syntax of  data structure
    Struct sructer_name{
    Data_type1  data_name1;
    Data_type2  data_name2;
    Data_type3  data_name3;
    Data_type(n) data_name(n);
    Lets to see a code to more learn about data structure. I think you are learn something from the syntax but it can’t  enough.


    using namespace std;

    struct info{
        string name;
        int age,id;
        float grads;

    int main(){
            for(int i=0;i<2;i++){
                cout<<"\nName:  ";
                cout<<"\nAge:  ";
                cout<<"\nId:  ";
                cout<<"\nGrads:  ";
            for(int i=0;i<2;i++){
                cout<<"\nName: "<<student[i].name;
                cout<<"\nAge: "<<student[i].age;
                cout<<"\nId: "<<student[i].id;
                cout<<"\nGread: "<<student[i].grads;
        return 0;

    At first at least two time observe this code ….
    What did you learn from this ?
    Ok ,
    Struct info{}:  Firstly declare a structure name, which has four component. String type “name”, integer type “id” and “age” and floating point type grads.  Object name student[100].
    Total structure works as array, which name is student. This is the main concept of structure, now we learn how to use structure. Object_name.data_name  is act as a variable . so Wright the code.


    Array In C++ (Basic Level)

    Just think, one day your teacher give you a box of different types chocolate, and tell you there are 10 types of chocolate you count only how much each type of chocolate , and put those numbers in your program and determine sum of them.
    What you will do? You able to count all chocolate number and store them in different variable. At least  10 variable need to store them. Do you know you can store them  into one variable? The method of this name is array.
    Array is the method of store one kinds of data into one variable.

          0             1              2            3             4            5              6           7             8             9

    Input & Output In C++ (Basic)

    Cout<<”Print sentence”;    This statement is use to print out any kinds of sentence or string type values.

    Cout<<345;    This statement is use to print out any kinds of numeric numbers, without change.

    Cout<<variable;       This statement is use to print the value of variable. The value of the which variable we want to print, It is need to write that variable on variable place.
    Support : Prosanta Chaki |
    Copyright © 2011. Funny Programmer - All Rights Reserved
    Proudly powered by Blogger