الأحد، 13 ديسمبر 2015

Hello World Programm




Hello World Program

To write your first "Hello World" program follow the below instructions

Launch Visual C++
Create a new C++ Solution/Project
1.      Select "File" menu "New" "Project...".
2.      In the "Project types" box select "VC++" and in templates box select "Win32 Console Application".
3.      Check the "Create directory for solution" box.
4.      In the "Name" field, enter "Hello" as the project name.
5.      In the "Location" field, choose your working directory.
6.      Click "OK".
7.      "Win32 Application Wizard" dialog-box appears Click "Next".
8.      In "Application settings", select "Empty project"
9.      Click "Finish".
Step 2: Write a C++ program
1.      In "Solution Explorer" panel, expand the "Hello" project node and right-click on "Sources Files" "Add" "New Item...".
2.      In the "Categories" box, select "Code".
3.      In the "Templates" box, select "VC++ File(.cpp)".
4.      In the "Name" field, enter "Hello" as the filename
5.      Click "Add".
6.      In the editor panel for "Hello.cpp", type the following C++ codes.
7.      #include <iostream>
8.      using namespace std;
9.         
10.  int main() {
11.      cout << "Hello, world!" << endl;
}



#include <iostream>
using namespace std;
  
int main() {
       int age;
           cout << "Enter your age" << endl;
              cin >> age;
              if (age > 50)
                     cout << " You are old" << endl;
              else
                     cout << "You are young";
                     return 0;
}


#include <iostream>
using namespace std;
  
int main() {
       int count=0, num;

       while (count<5)
       {
           cout << "Enter number" << endl;
              cin >> num;
              count=count+1;
       }
       return 0;
}



....


LAB 1 – EX 1

#include<iostream>
usingnamespacestd;
int main() {
int count=0, num , sum=0 ;
while (count<5)
{
cout<<"Enter number"<<endl;
cin>>num;
sum+=num;
count++;
}

cout<< sum <<endl;
return 0;
}


---------------------------------------------------------------------------------


LAB 1 – EX 2



#include<iostream>
usingnamespacestd;
int main() {
int count=0, num , sum=0 ;


for (int i = 0; i<5 ; i++){
cout<<"Enter number"<<endl;
cin>>num;
sum+=num;
}


cout<< sum <<endl;
return 0;
}



---------------------------------------------------------------------------------



LAB 1 – EX 3


#include<iostream>
usingnamespacestd;
int main() {


for (int i = 1; i<10 ; i++){


for (int j = 0; j<9 ; j++){
       cout<< i <<"";
      

}
cout<<endl;
}

return 0;

}

---------------------------------------------------------------------------------


LAB 1 – EX 4


#include<iostream>
usingnamespacestd;
int main() {


for (int i = 0; i<10 ; i++){

for (int j = 1; j<=i ; j++){
       cout<< j <<"";
      
      

}
cout<<endl;
}

}


---------------------------------------------------------------------------------




ليست هناك تعليقات:

إرسال تعليق