Anda di halaman 1dari 4

Program

#include <iostream> using namespace std; void main() { int choice; cout<<"This program will display a help message."<<endl; cout<<endl<<"Please choose between 1-3 :"<<endl; cout<<endl<<"1.FOR"; cout<<endl<<"2.IF"; cout<<endl<<"3. SWITCH"; cout<<endl<<"Please enter your choice : "; cin>>choice; cin.get(); switch (choice) { case 1: cout<<endl<<"FOR is C++ most versatile loop."<<endl; cout<<endl<<"Thank You!"<<endl; break; case 2: cout<<endl<<"IF is C++ condition branch statement."<<endl; cout<<endl<<"That's all."<<endl; break; case 3: cout<<endl<<"SWITCH is C++ multiway branch statement."<<endl; break; default: cout<<endl<<"You must enter a choice between 1 to 3.\n"; } }

Output: 1. FOR

Output: 2. IF

Output: 3. SWITCH

Explanation For The Source Code


#include <iostream>>//This is a preprocessor directive & include the iostream standard file using namespace std;;// this means that the compiler will look in the "std" namespace if it can't find a definition for something void main()//write the program,The main function {//begin block int choice; cout<<"This program will display a help message."<<endl;//to produce your display cout<<endl<<"Please choose between 1-3 :"<<endl; cout<<endl<<"1.FOR";//to produce your FOR cout<<endl<<"2.IF";//to produce your IF cout<<endl<<"3. SWITCH";//to produce your SWITCH cout<<endl<<"Please enter your choice : "; cin>>choice; cin.get(); switch (choice) {//begin block case 1: cout<<endl<<"FOR is C++ most versatile loop."<<endl;//to produce your FOR cout<<endl<<"Thank You!"<<endl; break; case 2: cout<<endl<<"IF is C++ condition branch statement."<<endl;//to produce your IF cout<<endl<<"That's all."<<endl; break; case 3: cout<<endl<<"SWITCH is C++ multiway branch statement."<<endl;//to produce your SWITCH break; default: cout<<endl<<"You must enter a choice between 1 to 3.\n"; }//end block }//end of the main function

Break Produces a default summary at a break (a change in the value of a group or order variable). The information in a summary applies to a set of observations. The observations share a unique combination of values for the break variable and all other group or order variables to the left of the break variable in the report.

Default constructors A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values. If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameterless constructor A::A(). This constructor is an inline public member of its class. The compiler will implicitly define A::A() when the compiler uses this constructor to create an object of type A. The constructor will have no constructor initializer and a null body. The compiler first implicitly defines the implicitly declared constructors of the base classes and nonstatic data members of a class A before defining the implicitly declared constructor of A. No default constructor is created for a class that has any constant or reference type members.

Anda mungkin juga menyukai