Sunday 22 July 2012

How to write my first c c++ Program?

New to Programming language?
Don't Know how write a c or c++ Program?
This post will teach how to write you own c or c++ Program.

There is not so much difference between c & c++
c++ was initially called as c with classes.
Requirements

  • Almost Every computer Supports  C++ Programming tools
  • C/C++ Program compiler, Eg. Turbo C++ there are various compiler available for free on INTERNET
  • Basic Computer knowledge
Steps to write First computer program 

  • Install any C++ compiler on your computer eg. turbo C++
  • If you installed Turbo c++ open c:\tc\bin\tc.exe , otherwise open your compiler.
  • Type the programming code. (explained Below)
For c ++ program

#include<iostream.h>
#include<stdio.h>
#include<conio.h>

void main()
{
  cout<<"Yeeepeee I made My First c++ Program";
  getch();
}

For c program

#include<stdio.h>
#include<conio.h>

void main()
  {
    printf("Yeepeee I made My First C Program");
  
    getch();
  }

Explanation
"//" is use to comment within  c or c++ program, it dose not effect other coding, it is one line comment

#include<headerfile.h>  // used to include header file. header file is a predefined file.
void function ( )       // is use to declared a function with no return values.

main()   // main is a predefined function in c/c++ programming, use to start main part of program. 
              compiler after checking to header files, search main, and runs the main

{                          //  opening braces is used to start a function,

 cout<<"Your comment on output  screen";   // used to print output i.e. displays output on output 
                                                                     screen

getch(); // is used to hold the screen , i.e. when program is run, it complete its process and teminate 
              and output screen is lost , so getch( ) is used to hold that output screen

}  // closing braces is use to close the function (completes function)

  • now save this program in by pressing f2 (function key)  (.cpp format for c++ and default format for c)
  • press Ctrl + f9 to compile or run the program
this will show your output of your first c/ c++ program

Congrats :) :)


If it shows any error contact us. we will try to sort your problem.


No comments:

Post a Comment

This Blog is not managed by anyone, If you are interested then Contact me avinashkgec@gmail.com

Related Post