Results 1 to 5 of 5

Thread: Examples of C++

  1. #1
    Join Date
    Mar 2010
    Posts
    576

    Examples of C++

    Hey Guys, I want to know the three examples of C++ programming language so that I could understand its code. I want to understand how the code of c++ is actually. So, I thought that first I will start with 3 programs then later on I will increase it when I am familiar with it. So, if anyone having any information about it then please let me know as soon as possible.

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: Examples of C++

    This Program is to declare structure student.I have taken input for 5 students and then find the details of student such as name roll no, percentage ,student name, and roll no. Over here we have made a structure named student which consists of roll no, student name and percentage.


    Code:
    # include<iostream.h>
    # include<conio.h>
    struct student
               { 
                      int rollno;
                      char student_name[40];
                       float percentage;
                }
         main()
                {
              struct student s[5];
               int i;
              clrscr();
               cout<<”enter data for 5 students”;
                for(i=0;i<=4;++i)
                    {
                        cout<<”Enter  students rollno, name and percentage”;
                         cin>>s[i].rollno>>s[i].student_name>>s[i].percentage;
                    }
               for( i=0;i<4;++i)
                  {
                            cout<<”Students Roll no = ”<<s[i].rollno;
                            cout<<”Students name =”<<s[i].student_name;
                             cout<<”Students percentage= “<<percentage;        
                   }
            }

  3. #3
    Join Date
    May 2009
    Posts
    637

    Re: Examples of C++

    This Program is to declare class student, having variables rollno,student_name and percentage which creates one object and then initialize it ,display details. In this program you will find that how the object is created and then initialized it. This is the perfect example for it.

    Code:
    # include<iostream.h>
    # include<conio.h>
    class student
               { 
                      int rollno;
                      char student_name[40];
                       float percentage;
               public :
                    void get_data()
                       {
                         cout<<”Enter  students rollno”;
                         cin>>rollno;
                         cout<<endl;
                          cout<<” Enter  students name”;
                          cin>>student_name;
                          cout<<endl;
                         cout<<”Enter  students percentage”;
                          cin>>percentage;
                          cout<<endl;
                       }
                    void display()
                    {  
                         cout<<”  students rollno =”<<rollno <<endl;
                         cout<<”  students name”<<student_name<<endl;
                          cout<<” students percentage”<<percentage<<endl;
                     
                     }
                 }
         main()
                {
               student s;
              s.get_data();
               s.display();
               }

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Examples of C++

    This Program is to declare class employee,having variables emp_id,emp_name and salary which creates one object and initialize it ,display details. This is very simple program which will display all the details of employee

    Code:
    # include<iostream.h>
    # include<conio.h>
    class employee
               { 
                      int emp_id;
                      char emp_name[40];
                       int basic_sal;
               public :
                    void get_data()
                       {
                         cout<<”Enter  Employees id”;
                         cin>>emp_id;
                         cout<<endl;
                         cout<<” Enter  Employees name”;
                         cin>>emp_name;
                         cout<<endl;
                          cout<<”Enter  employees salary”;
                          cin>>basic_sal;
                          cout<<endl;
                        }
                    void display()
                    {  
                         cout<<”  Employees id =”<<emp_id <<endl;
                         cout<<”  Employees name”<<emp_name<<endl;
                          cout<<”  Employees salary”<<basic_sal<<endl;
                     
                     }
                 }
         main()
                {
               employee e;
              e.get_data();
               e.display();

  5. #5
    Join Date
    May 2009
    Posts
    539

    Re: Examples of C++

    This Program is to declare class student,having variables rollno,student_name and percentage which creates two object and initialize it ,display details> this program is bit different from other one as it initializes two objects in it.

    Code:
    # include<iostream.h>
    # include<conio.h>
    class student
               { 
                      int rollno;
                      char student_name[40];
                       float percentage;
               public :
                    void get_data()
                       {
                         cout<<”Enter  students rollno”;
                         cin>>rollno;
                          cout<<endl;
                         cout<<” Enter  students name”;
                          cin>>student_name;
                          cout<<endl;
                          cout<<”Enter  students percentage”;
                          cin>>percentage;
                          cout<<endl;
                        }
                    void display()
                    {  
                         cout<<”  students rollno =”<<rollno <<endl;
                         cout<<”  students name”<<student_name<<endl;
                          cout<<” students percentage”<<percentage<<endl;
                     
                     }
                 }
         main()
                {
               student s,s1;
              s.get_data();
               s1.get_data();
               s.display();
               s1.display();
               }

Similar Threads

  1. Silverlight Treeview examples in VB
    By Sheravat in forum Software Development
    Replies: 5
    Last Post: 06-08-2010, 05:38 AM
  2. Business application examples for silverlight
    By Devabrata in forum Windows Software
    Replies: 5
    Last Post: 06-08-2010, 04:59 AM
  3. Help for Timer examples in Java
    By Feng in forum Software Development
    Replies: 5
    Last Post: 24-07-2010, 03:36 AM
  4. Sources of Java Application Examples
    By Steyn in forum Software Development
    Replies: 5
    Last Post: 09-01-2010, 01:51 AM
  5. Trojan Horse Examples
    By Kundanlal in forum Networking & Security
    Replies: 3
    Last Post: 22-08-2009, 09:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,059,195.32056 seconds with 17 queries