1.structure of C++ Program:: A. Linkage
1.structure of C++ Program:: A. Linkage
a. Linkage: Linkage refers to the linking of the header files.Header Files are nothing but,it contains the functions that we are going to use. Ex: #include <iostream.h> b.Declaration: Declaration refers to the declaration of user defined functions in that programs or global variables.global variables,once declared can be used in any function in that program. Syntax: <data_type> function_name(function arguments); Example: int Add(int,int); Syntax:<data_type> variable_name;
Example: int sum_of_numbers; // sum_of_numbers if the name of the variable declared as an integer type c.Definition: The definition part is used to define that function which we already declared in declaration part. Example: int Add(int x , int y) { return(x+y); } d.Main() Program: Main Program Part is used to write the programs and it is where all the userdefined functions or built-in function are called. syntax: int main(int argc,char *argv[]) Ex: int main() { int a;//variable declaration int b;//variable declaration int c;//variable declaration a=5; b=10; c=a+b; printf("a+b=%d",c); }
C Program
It is a Structural Program It Does not have any 'namespace' Not Strict Type Checking C++ functions cannot be used Declaration of Variables should only be at the beginning.
C++ Program
It is a Object Oriented Program Introduces A new Concept 'namespace' Strict Type Checking C function can also be used Declaration of variables can be done at any part of the program.