Friday, 29 November 2013

Filled Under:

My first program in visual stdio 2012

My first program in visual stdio 2012?

1)open visual stdio 2012 select new project and now chose the visual c++ and console base application and write the name of project and click ok show in figure.


2) and now new window will be open here is thee button one is next 2nd is finish and 3rd is cancel so now click the next button and in next window there will be multiple check boxes and radio button so without interrupt any button just click on finish button.then visual stdio enviroment for c++ in open there will be by default code is 
                                              #include "stdafx.h"


                                int _tmain(int argc, _TCHAR* argv[])
                                  {
                             return 0;
                                      }
 #include "stdafx.h" is by default header file that will be include in every program so now for c++ we include a new header file that will also be include in every c++ program that is #include "iostream"
and in next line write using namespace std; 
Note:
every statment is terminate with ";" in c++ expect header file other wise compiler will show the error it might be syntax error.
3) so in my first program i will just display my name after main() i will write the following code of line 
cout<<"Muhammad umer"; and at the end write a function getchar() ; that will also include in every c++ program .

code of my first program:

#include "stdafx.h"
#include "iostream"
#include <conio.h>
using namespace std;

int main()
{
cout<<"muhammad umer";
getchar();

return 0;
}




screen short of my first program:






so now my first program is ready so my first program is ready . 
4) now i press f5 for run my program so the output show like that 

output screen short:

what is meaning of #include "iostream":

Lines beginning with sign (#) are directives for the preprocessor. In this case the directive #include "iostream" tells the preprocessor to include the iostream standard file. and iostream file the basic standard input-output library for c++.and it include its functionality which is later use in the program.

what is meaning of using namespace std?

Namespaces in C++ are used to define a scope and allows us to use functions and/or objects into one group.When you use using namespace std; you are instructing compiler to use the standard C++ library. If you don't give this instruction, then you will have to use std:: 
every time when you use c++ functionality

int main();

it is main function of c++ programming. it mean that all program execution start form main function.it does not matter you use other function in your program but execution always star form main function 

 cout<<"" in c++?

cout<< is the standard output stream in c++. it takes the sequence of character input within double quotes"" and display it on the screen .
Note:
         every c++ instruction is end with semicolon (;)






0 comments:

Post a Comment