Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

1.structure of C++ Program:: A. Linkage

The document discusses the structure of a C++ program and the differences between C and C++. The structure of a C++ program includes: 1) Linkage using header files 2) Declaration of functions and global variables 3) Definition of already declared functions 4) The main() program which calls other functions The key differences between C and C++ are: 1) C++ is object-oriented while C is procedural 2) C++ introduces namespaces while C does not 3) C++ has strict type checking while C does not 4) C++ allows using C functions and declaring variables anywhere in a program.

Uploaded by

kranthi633
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

1.structure of C++ Program:: A. Linkage

The document discusses the structure of a C++ program and the differences between C and C++. The structure of a C++ program includes: 1) Linkage using header files 2) Declaration of functions and global variables 3) Definition of already declared functions 4) The main() program which calls other functions The key differences between C and C++ are: 1) C++ is object-oriented while C is procedural 2) C++ introduces namespaces while C does not 3) C++ has strict type checking while C does not 4) C++ allows using C functions and declaring variables anywhere in a program.

Uploaded by

kranthi633
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Structure Of C++ Program:


Programming Structure:
#include <header_file_name.h> #define constants_name <global variable declaration part> <int>or<void> main(args...) { local_variable_declaration; executable_part; } //sub programs or functions part. <data_type>function_name(args...) { function_coding; }

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); }

2.Difference Between C And C++


C and C++ are the magic spells of many programmers and software developers.Though C programming language is orgin of C++ there are many concepts which are include in C++ and very useful and easier to write programs.

Difference Between C and 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.

You might also like