Tutorial on Basic Concepts of C++ Program Part 1

Concepts

Structure of C++ Program:
  • C++ Program contain Four Sections. 
  • These Sections may be placed in Separate code Files.
  • Most popular Compiler systems are UNIX AT & T C++ , Turbo C++ , Microsoft Visual C++.


          Include Files 
       Class Declaration 
 Member Function Definition 
     Main Function Program


Output operator:
  1. This statement  Cout << " c++ is better than c. " ; introduces two new C++ Features i.e Cout and <<
  2. The operator << is called the Insertion or Put to Operator. 
  3. The identifier Cout is a predefined object that represents the standard output stream in c++. 
  4. << Operator is also known as bitwise left-shift operator.
Note: Both Cout << and printf() are used for displaying an Output.

Input operator:
  1. The statement  Cin >> number;  is an input statement. 
  2. The identifier Cin is a predefined object in C++ that represents the standard input stream. 
  3. The operator >> is known as Extraction or get from operator. It extracts the value from the keyboard and assign it to the variable on the right of the identifier Cin.
Note: 
  • Both scanf() and Cin is used for input values.
  • Both << and >> can also be overloaded.
Return Type of main() :
  1. In C++ main() returns an integer type value to the operating system. Thus every main() in C++ should end with a return(0) statement, otherwise a warning or an error Might occur. 
  2. The default return type for all functions in C++ is int.
Example:
     main()
     {
     ...........
     ...........
    return(0);
     }
Manipulators:
  1. Manipulators are the Operators that are used to Format the data display. 
  2. The most commonly used manipulators are endl and setw.
  3. " endl " manipulator when used in an output statement, it causes a linefeed to be inserted. It has same effect as that of newline character " \n ".

Cascading of I/O Opertors:
  • Cout<< "Sum=" << sum<<"\n";
The above Statement first sends the string "Sum=" to Cout and then sends the value of sum.

  • Cin>> a >> b;
    The values are assigned from Left to Right. If we press two values i.e 10 and 5 from the keyboard then 10 will be assigned to "a" and "5" to b.

    • This is one statement and provides one lines of output.
                               Cout<< "Sum=" << sum<<" , "
                                      << "Average="<< average<< "\n";
    Output:
     Sum=30 , Average=7

    • This is one statement but provides two lines of output.
                                   Cout<< "Sum=" << sum<<" \n "
                                          << "Average="<< average<< "\n";

    Output:
     Sum=30 
     Average=7


    0 Response to "Tutorial on Basic Concepts of C++ Program Part 1"

    Post a Comment

    Popular Posts

    Label

    1 Sidebar 2 Columns 3 Columns Footer 3rdball 4 Columns Footer Alex Alvaro Antsasia Arlinadesign Averie Barry BASIC CONCEPTS Basil Bayna Fast BeautyPress BeautyTemplates Beckel Best Best - Clean Beyonce Pro BioMag BlackMag Blanter Nova Blogger Card Bloggertheme9 Blogish Bpress Brakt C LANGUAGE C PROGRAMS C++ LANGUAGE C++ PROGRAMS Carella Cellar Charlotte Chooko Lite Clara Clean Combo One Cooperate Crusade Darry Dorman Dreamway Dunia Blanter eCars EduAcademy EducationPress Elise Elvan Eva Everyday FabNews Fashion Fashion Blogger Template Fashion Gossip FastCars Fedo FlashNews Fredy Portfolio Gaming Globus GoodTime Goomsite HTML LANGUAGE iGaming Indicate Innove Insomnia InspiredNews iSoft Jasmine Kalem Landscaping Lashira Lavelle Lily Fashion Limax Linea Lionex Luminescence Lite Lumix Luxury Magazine MagazinePro MAJOR DIFFERENCES MarketingBlog Martin MaxiMag Medica Mega Melissa Mercury MeshMag Minimag Minimalist MiniNews MovieKhor msdesignbd MusicLand Neko NetZine New Spread News16 Newsflash NewsForce NewsIdea Newspaper News NewsPro Nubie Fast Odd Themes Optima PaperMag PaperMag blog Parhlo Perfection Personal Personal Blog Photosout PixelZ Power Blog Premium Themes ProfileMag Purez Rano ReadNews Real estate Remito Grid Responsive Revo Robusta Rotario Saara SeoBoost Settle Shouters Simple Catch SimpleClean Sketchly SNews SolidMag Someo Sophie Sora Sora Bank Sora Home Sora News Responsive Sora One Sora Ribbon Spido Sticko Stucco Sure Mag Swift Tech Tech Pro Techia Techmax TechSpot TemplateClue Templateism Templatesilk Templatesyard Templatezy The Freelancer TheBlogger TheFocus Themeforest Themexpose TIPS AND TRICKS Topside TravelMag Trendy Trendy Travel Tumblr Under Construction Uong Jowo Veethemes Vertox VideoPlay Vigo Waverly way2themes WebBiz Wedding X-Mag Zealer ZetaMag