Difference between revisions of "C and Cpp"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 11: Line 11:
  
 
==Basic Level==                                                                           
 
==Basic Level==                                                                           
#First C Program
 
#*Header Files <br>
 
#**example:<nowiki> #include <stdio.h> </nowiki>
 
#*main()
 
#*Curly braces { }
 
#*printf()
 
#*semicolon ;
 
#*Compiling a C program
 
#**example: gcc filename.c -o output parameter
 
#*Executing a C program
 
#**example: ./output parameter
 
#*Errors
 
# First C++ Program
 
#*Header files
 
#**example: <nowiki>#include <iostream> </nowiki>
 
#*main()
 
#*Curly braces { }
 
#*<nowiki>-cout<< </nowiki>
 
#*semicolon ;
 
#*Compiling a C++ program
 
#**example: g++ filename.cpp -o output parameter
 
#*Executing a C program
 
#**example: ./output parameter
 
# Tokens in C and C++
 
#*Data types, constants, identifiers
 
#*Keywords
 
#**example: if, break, else
 
#*Constants
 
#*Data types
 
#**example: int, float, char, double
 
#*Format specifiers
 
#**example: %d, %f, %c, %lf
 
#*Range of data types
 
#*Variables
 
#*Identifier
 
#*Errors
 
#Functions in C and C++
 
#*What is a function
 
#*Syntax for declaration of a function
 
#*Function with arguments
 
#**example: return-type function-name(parameter);
 
#*Function without arguments
 
#**example: return-type function-name;
 
#*Calling a function
 
#*Errors
 
#Scope of Variables in C and C++
 
#*Introduction
 
#*Syntax of declaring a variable
 
#**example: data-type var-name;
 
#*Syntax for initializing a variable
 
#**example: data-type var-name = value;
 
#*Scope of variables
 
#*Global variable
 
#*Local variable
 
#*Error
 
  
 +
1) First C Program (Script) (Spoken-Tutorial)
  
6) Check the conditions in a program in C and C++ <br>
 
  
-What are Statements.<br>
+
-Header Files
-Syntax for if and <br>
+
-If-else Statement<br>
+
-Errors<br>
+
  
 +
<nowiki>--example: #include <stdio.h> </nowiki>
  
7) Nested if and switch statement in C and C++ <br>
+
-main()  
  
-Nested if statement.<br>
+
-Curly braces { }
-Switch statement.<br>
+
-Syntax for nested-if statement<br>
+
-Syntax for switch statement<br>
+
-break statement<br>
+
-Comparison between nested if-else and switch statement<br>
+
-Errors<br>
+
  
 +
-printf()
  
8) Increment and Decrement Operators in C and C++ <br>
+
-semicolon ;
  
-Increment Operator<br>
+
-Compiling a C program
--example: ++<br>
+
-Postfix increment<br>
+
--example: a++<br>
+
-Prefix increment<br>
+
--example: ++a<br>
+
-Decrement Operator<br>
+
--example: --<br>
+
-Postfix decrement<br>
+
--example: a--<br>
+
-Prefix decrement<br>
+
--example: --a<br>
+
-Typecasting<br>
+
-Errors<br>
+
  
 +
--example: gcc filename.c -o output parameter
  
9) Arithmetic Operators in C and C++ <br>
+
-Executing a C program
  
-Arithmetic Operators<br>
+
--example: ./output parameter
-Addition Operator<br>
+
--example: a + b<br>
+
-Subtraction Operator<br>
+
--example: a - b<br>
+
-Multiplication Operator<br>
+
--example: a * b <br>
+
-Division Operator<br>
+
--example: a \ b<br>
+
-Modulus Operator <br>
+
--example: a % b<br>
+
-Errors<br>
+
  
 +
-Errors
  
10) Relational Operators in C and C++ <br>
 
-Double Equal to <br>
 
--example: a == b<br>
 
-Not Equal to <br>
 
--example: a != b <br>
 
-Greater Than <br>
 
--example: a > b<br>
 
-Less Than <br>
 
<nowiki>--example: a < b
 
</nowiki><br>
 
-Greater than Equal To <br>
 
--example: a >= b<br>
 
-Less Than Equal To <br>
 
<nowiki>--example: a <= b
 
</nowiki><br>
 
-Errors<br>
 
  
 +
2) First C++ Program (Script) (Spoken-Tutorial)
  
11) Logical Operators in C and C++ <br>
 
  
-And && <br>
+
-Header files
-Or ||<br>
+
-Not !<br>
+
-Errors<br> http://www.spoken-tutorial.iitb.ac.in/search_videos
+
  
 +
<nowiki>--example: #include <iostream> </nowiki>
  
12) Loops in C and C++ <br>
+
-main()  
  
-Loops<br>
+
-Curly braces { }
-Syntax for while and do-while loop<br>
+
-Comparison of while and do-while loop<br>
+
-Syntax for<br>
+
-for loop<br>
+
-Errors<br>
+
  
 +
<nowiki>-cout<< </nowiki>
  
13) Arrays in C and C++ <br>
+
-semicolon ;
  
-What are arrays<br>
+
-Compiling a C++ program
-1-D Arrays <br>
+
-Syntax for Declaration of arrays<br>
+
<nowiki>--example: data type array_name [size];
+
</nowiki><br>
+
-Syntax for Initialization of arrays<br>
+
<nowiki>--example: data type array_name [size]=value;
+
</nowiki><br>
+
-Accepting values from the user<br>
+
-Errors<br>
+
  
 +
--example: g++ filename.cpp -o output parameter
  
14) Working with 2-D Arrays in C and C++ <br>
+
-Executing a C program
  
-What are 2-D Arrays.<br>
+
--example: ./output parameter
-Range of arrays<br>
+
-Syntax for Declaration of 2-D arrays<br>
+
<nowiki>--example: data type array_name[row][column];
+
</nowiki><br>
+
-Syntax for initialization of 2-D arrays<br>
+
<nowiki>--example: data type array_name[row][column]=
+
</nowiki><br>
+
{ <br>
+
{row-val},{col-val} <br>
+
};<br>
+
-Errors<br>
+
  
 +
 +
3) Tokens in C and C++
 +
 +
 +
 +
-Data types, constants, identifiers
 +
 +
-Keywords
 +
 +
--example: if, break, else
 +
 +
-Constants
 +
 +
-Data types
 +
 +
--example: int, float, char, double
 +
 +
-Format specifiers
 +
 +
--example: %d, %f, %c, %lf
 +
 +
-Range of data types
 +
 +
-Variables
 +
 +
-Identifier
 +
 +
-Errors
 +
 +
 +
4) Functions in C and C++
 +
 +
 +
-What is a function
 +
 +
-Syntax for declaration of a function
 +
 +
-Function with arguments
 +
 +
--example: return-type function-name(parameter);
 +
 +
-Function without arguments
 +
 +
--example: return-type function-name; 
 +
 +
-Calling a function
 +
 +
-Errors
 +
 +
 +
5) Scope of Variables in C and C++
 +
 +
 +
-Introduction
 +
 +
-Syntax of declaring a variable
 +
 +
--example: data-type var-name;
 +
 +
-Syntax for initializing a variable
 +
 +
--example: data-type var-name = value;
 +
 +
-Scope of variables
 +
 +
-Global variable
 +
 +
-Local variable
 +
 +
-Error
 +
 +
 +
6) Check the conditions in a program in C and C++
 +
 +
 +
-What are Statements.
 +
 +
-Syntax for if and
 +
 +
-If-else Statement
 +
 +
-Errors
 +
 +
 +
7) Nested if and switch statement in C and C++
 +
 +
 +
-Nested if statement.
 +
 +
-Switch statement.
 +
 +
-Syntax for nested-if statement
 +
 +
-Syntax for switch statement
 +
 +
-break statement
 +
 +
-Comparison between nested if-else and switch statement
 +
 +
-Errors
 +
 +
 +
8) Increment and Decrement Operators in C and C++
 +
 +
 +
-Increment Operator
 +
 +
--example: ++
 +
 +
-Postfix increment
 +
 +
--example: a++
 +
 +
-Prefix increment
 +
 +
--example: ++a
 +
 +
-Decrement Operator
 +
 +
--example: --
 +
 +
-Postfix decrement
 +
 +
--example: a--
 +
 +
-Prefix decrement
 +
 +
--example: --a
 +
 +
-Typecasting
 +
 +
-Errors
 +
 +
 +
9) Arithmetic Operators in C and C++
 +
 +
 +
-Arithmetic Operators
 +
 +
-Addition Operator
 +
 +
--example: a + b
 +
 +
-Subtraction Operator
 +
 +
--example: a - b
 +
 +
-Multiplication Operator
 +
 +
--example: a * b
 +
 +
-Division Operator
 +
 +
--example: a \ b
 +
 +
-Modulus Operator
 +
 +
--example: a % b
 +
 +
-Errors
 +
 +
 +
10) Relational Operators in C and C++
 +
 +
 +
-Double Equal to
 +
 +
--example: a == b
 +
 +
-Not Equal to
 +
 +
--example: a != b
 +
 +
-Greater Than
 +
 +
--example: a > b
 +
 +
-Less Than
 +
 +
<nowiki>--example: a < b </nowiki>
 +
 +
-Greater than Equal To
 +
 +
--example: a >= b
 +
 +
-Less Than Equal To
 +
 +
<nowiki>--example: a <= b </nowiki>
 +
 +
-Errors
 +
 +
 +
11) Logical Operators in C and C++
 +
 +
 +
-And &&
 +
 +
-Or ||
 +
 +
-Not !
 +
 +
-Errors
 +
 +
 +
12) Loops in C and C++
 +
 +
 +
-Loops
 +
 +
-Syntax for while and do-while loop
 +
 +
-Comparison of while and do-while loop
 +
 +
-Syntax for
 +
 +
-for loop
 +
 +
-Errors
  
 
==Intermediate level==   
 
==Intermediate level==   
  
15) Strings in C and C++ <br>
+
13) Arrays in C and C++  
  
-What is a string<br>
 
-Syntax for declaring a string<br>
 
-Syntax for initializing a string<br>
 
-To read a string from keyboard<br>
 
-Errors<br>
 
  
 +
-What are arrays
  
16) String Library Functions in C and C++ <br>
+
-1-D Arrays
-What are string library functions.<br>
+
-Types of string library functions<br>
+
-Strcpy<br>
+
-Strlen<br>
+
-Strcmp<br>
+
-Strcat<br>
+
-Errors<br>
+
  
 +
-Syntax for Declaration of arrays
  
17) Working with Structures in C and C++ <br>
+
<nowiki>--example: data type array_name [size]; </nowiki>
  
-Introduction<br>
+
-Syntax for Initialization of arrays
-Syntax of structures<br>
+
-Declaration and initialization<br>
+
-Declaration of structure variable<br>
+
-Accessing structure variables<br>
+
  
 +
<nowiki>--example: data type array_name [size]=value; </nowiki>
  
18) Understanding Pointers in C and C++ <br>
+
-Accepting values from the user
  
-Introduction<br>
+
-Errors  
-Syntax of Pointer<br>
+
--example: int *iptr;<br>
+
-Declaration<br>
+
--example: int a;<br> 
+
(integer a)<br>
+
int *aptr; <br>
+
(pointer to an integer *aptr)<br>
+
aptr = &a; <br>
+
(aptr set to address of a)<br>
+
Address Pointer<br>
+
-Errors<br>
+
  
  
19) Files in C <br>
+
14) Working with 2-D Arrays in C and C++
 +
 
 +
 
 +
-What are 2-D Arrays.
 +
 
 +
-Range of arrays
 +
 
 +
-Syntax for Declaration of 2-D arrays
 +
 
 +
<nowiki>--example: data type array_name[row][column]; </nowiki>
 +
 
 +
-Syntax for initialization of 2-D arrays
 +
 
 +
<nowiki>--example: data type array_name[row][column]= </nowiki>
 +
 
 +
{
 +
 
 +
{row-val},{col-val}
 +
 
 +
};
 +
 
 +
-Errors
 +
 
 +
 
 +
15) Strings in C and C++
 +
 
 +
 
 +
-What is a string
 +
 
 +
-Syntax for declaring a string
 +
 
 +
-Syntax for initializing a string
 +
 
 +
-To read a string from keyboard
 +
 
 +
-Errors
 +
 
 +
 
 +
16) String Library Functions in C and C++
 +
 
 +
 
 +
-What are string library functions.
 +
 
 +
-Types of string library functions
 +
 
 +
-Strcpy
 +
 
 +
-Strlen
 +
 
 +
-Strcmp
 +
 
 +
-Strcat
 +
 
 +
-Errors
 +
 
 +
 
 +
17) Working with Structures in C and C++
 +
 
 +
 
 +
-Introduction
 +
 
 +
-Syntax of structures
 +
 
 +
-Declaration and initialization
 +
 
 +
-Declaration of structure variable
 +
 
 +
-Accessing structure variables
 +
 
 +
 
 +
18) Understanding Pointers in C and C++
 +
 
 +
 
 +
-Introduction
 +
 
 +
-Syntax of Pointer
 +
 
 +
--example: int *iptr;
 +
 
 +
-Declaration
 +
 
 +
--example: int a;
 +
 
 +
(integer a)
 +
 
 +
int *aptr;
 +
 
 +
(pointer to an integer *aptr)
 +
 
 +
aptr = &a;
 +
 
 +
(aptr set to address of a)
 +
 
 +
Address Pointer
 +
 
 +
-Errors
 +
 
 +
 
 +
19) Function pass by value and pass by reference
 +
 
 +
 
 +
-types of function calls
 +
 
 +
-function pass by value
 +
 
 +
-function pass by reference
 +
 
 +
 
 +
20) Files in C
 +
 
 +
 
 +
-File handling functions
 +
 
 +
-Opening a File closing a file
 +
 
 +
--example: fopen, fclose
 +
 
 +
-Reading data from a File
  
-File handling functions<br>
 
-Opening a File closing a file<br>
 
--example: fopen, fclose<br>
 
-Reading data from a File<br>
 
  
  
 
==Advanced level==   
 
==Advanced level==   
  
20) Classes and Objects in C++ <br>
 
  
-Defining Classes<br>
+
21) Classes and Objects in C++
-create a class<br>
+
 
-Defining Objects<br>
+
 
-create an object of the class<br>
+
-Defining Classes  
-Encapsulation<br>
+
 
-Member Functions<br>
+
-create a class  
-To create a function<br>
+
 
 +
-Defining Objects  
 +
 
 +
-create an object of the class  
 +
 
 +
-Member Functions  
 +
 
 +
-To create a function  
 +
 
 +
-Encapsulation
 +
 
 +
-Data Abstraction
 +
 
 +
 
 +
22) Constructor and Destructor
 +
 
 +
 
 +
-Constructor and Destructor
 +
 
 +
-To create a constructor
 +
 
 +
-Parameterized constructors
 +
 
 +
-Default constructor
 +
 
 +
-Destructor
 +
 
 +
 
 +
23) static members in C++
 +
 
 +
 
 +
-Static Keyword
 +
 
 +
-Static variable
 +
 
 +
-Static member function
 +
 
 +
 
 +
24) Inheritance
 +
 
 +
 
 +
-Inheritance
 +
 
 +
-Concept of subclass and superclass
 +
 
 +
-Types of inheritance
 +
 
 +
-single level inheritance
 +
 
 +
-Multilevel inheritance
 +
 
 +
 
 +
25) Multiple and Hierarchical Inheritance
 +
 
 +
 
 +
-Multuple Inheritance
 +
 
 +
-Hierarchical Inheritnace26) Function Overloading and Overriding-function overloading
 +
 
 +
-function overriding
 +
 
 +
-difference between both
 +
 
 +
27) Polymorphism in C++
  
  
21) Constructor and Destructor <br>
+
-Polymorphism
  
-Constructor and Destructor<br>
+
-Virtual Members
-To create a constructor<br>
+
-Parameterized constructors<br>
+
-Copy Constructors<br>
+
-Destructor<br>
+
  
 +
-Virtual Function
  
22) Operator Overloading  <br>
 
  
-Operator Overloading<br>
+
28) Abstract class in C++
-Static Keyword<br>
+
-Static variable<br>
+
-Static member function<br>
+
-Static Classes<br>
+
  
  
23) Inheritance <br>
+
-Pure virtual function-abstract class
  
-Inheritance<br>
+
-abstract methods
-Concept of subclass and superclass<br>
+
-Types of inheritance<br>
+
  
  
24) Multiple and Hierarchical Inheritance <br>
+
29) Friend Function
  
-Multiple Inheritance <br>
 
-Hierarchical Inheritance <br>
 
--Examples
 
  
 +
-friend function
  
25) Polymorphism  <br>
 
  
-Polymorphism<br> 
+
30) Exception Handling
-Virtual Members<br>
+
-Virtaul Functions
+
  
  
26) Virtual class <br>
+
-Exceptions
-abstract class<br>
+
-abstract methods<br> in C++
+
  
 +
-try
  
27) Exception Handling <br>
+
-throw
  
-Exceptions<br>
+
-catch
-try<br>
+
-throw<br>
+
-catch<br>
+

Revision as of 16:24, 8 April 2013

Introduction to C

Powerful features, simple syntax, and portability make C a preferred language among programmers for business and industrial applications.Portability means that C programs written for a computer with a particular kind of processor, say Intel, can be executed on computers with different processors such as Motorola, Sun Sparc, or IBM with little or no modification.C language is widely used in the development of operating systems.

An Operating System(OS) is a software(collection of programs) that controls the various functions of a computer. Also it makes other programs on your computer work.

For example, you cannot work with a word processor program, such as Microsoft Word, if there is no operating system installed on your computer.Windows, Unix, Linux, Solaris, and MacOS are some of the popular operating systems.

Dennis M. Ritchie, a systems engineer at Bell Laboratories, New Jersey developed C in the early 1970’salthough designed for the Unix operating system, it soon proved itself a powerful, general purpose programming language.

Basic Level

1) First C Program (Script) (Spoken-Tutorial)


-Header Files

--example: #include <stdio.h>

-main()

-Curly braces { }

-printf()

-semicolon ;

-Compiling a C program

--example: gcc filename.c -o output parameter

-Executing a C program

--example: ./output parameter

-Errors


2) First C++ Program (Script) (Spoken-Tutorial)


-Header files

--example: #include <iostream>

-main()

-Curly braces { }

-cout<<

-semicolon ;

-Compiling a C++ program

--example: g++ filename.cpp -o output parameter

-Executing a C program

--example: ./output parameter


3) Tokens in C and C++


-Data types, constants, identifiers

-Keywords

--example: if, break, else

-Constants

-Data types

--example: int, float, char, double

-Format specifiers

--example: %d, %f, %c, %lf

-Range of data types

-Variables

-Identifier

-Errors


4) Functions in C and C++


-What is a function

-Syntax for declaration of a function

-Function with arguments

--example: return-type function-name(parameter);

-Function without arguments

--example: return-type function-name;

-Calling a function

-Errors


5) Scope of Variables in C and C++


-Introduction

-Syntax of declaring a variable

--example: data-type var-name;

-Syntax for initializing a variable

--example: data-type var-name = value;

-Scope of variables

-Global variable

-Local variable

-Error


6) Check the conditions in a program in C and C++


-What are Statements.

-Syntax for if and

-If-else Statement

-Errors


7) Nested if and switch statement in C and C++


-Nested if statement.

-Switch statement.

-Syntax for nested-if statement

-Syntax for switch statement

-break statement

-Comparison between nested if-else and switch statement

-Errors


8) Increment and Decrement Operators in C and C++


-Increment Operator

--example: ++

-Postfix increment

--example: a++

-Prefix increment

--example: ++a

-Decrement Operator

--example: --

-Postfix decrement

--example: a--

-Prefix decrement

--example: --a

-Typecasting

-Errors


9) Arithmetic Operators in C and C++


-Arithmetic Operators

-Addition Operator

--example: a + b

-Subtraction Operator

--example: a - b

-Multiplication Operator

--example: a * b

-Division Operator

--example: a \ b

-Modulus Operator

--example: a % b

-Errors


10) Relational Operators in C and C++


-Double Equal to

--example: a == b

-Not Equal to

--example: a != b

-Greater Than

--example: a > b

-Less Than

--example: a < b

-Greater than Equal To

--example: a >= b

-Less Than Equal To

--example: a <= b

-Errors


11) Logical Operators in C and C++


-And &&

-Or ||

-Not !

-Errors


12) Loops in C and C++


-Loops

-Syntax for while and do-while loop

-Comparison of while and do-while loop

-Syntax for

-for loop

-Errors

Intermediate level

13) Arrays in C and C++


-What are arrays

-1-D Arrays

-Syntax for Declaration of arrays

--example: data type array_name [size];

-Syntax for Initialization of arrays

--example: data type array_name [size]=value;

-Accepting values from the user

-Errors


14) Working with 2-D Arrays in C and C++


-What are 2-D Arrays.

-Range of arrays

-Syntax for Declaration of 2-D arrays

--example: data type array_name[row][column];

-Syntax for initialization of 2-D arrays

--example: data type array_name[row][column]=

{

{row-val},{col-val}

};

-Errors


15) Strings in C and C++


-What is a string

-Syntax for declaring a string

-Syntax for initializing a string

-To read a string from keyboard

-Errors


16) String Library Functions in C and C++


-What are string library functions.

-Types of string library functions

-Strcpy

-Strlen

-Strcmp

-Strcat

-Errors


17) Working with Structures in C and C++


-Introduction

-Syntax of structures

-Declaration and initialization

-Declaration of structure variable

-Accessing structure variables


18) Understanding Pointers in C and C++


-Introduction

-Syntax of Pointer

--example: int *iptr;

-Declaration

--example: int a;

(integer a)

int *aptr;

(pointer to an integer *aptr)

aptr = &a;

(aptr set to address of a)

Address Pointer

-Errors


19) Function pass by value and pass by reference


-types of function calls

-function pass by value

-function pass by reference


20) Files in C


-File handling functions

-Opening a File closing a file

--example: fopen, fclose

-Reading data from a File


Advanced level

21) Classes and Objects in C++


-Defining Classes

-create a class

-Defining Objects

-create an object of the class

-Member Functions

-To create a function

-Encapsulation

-Data Abstraction


22) Constructor and Destructor


-Constructor and Destructor

-To create a constructor

-Parameterized constructors

-Default constructor

-Destructor


23) static members in C++


-Static Keyword

-Static variable

-Static member function


24) Inheritance


-Inheritance

-Concept of subclass and superclass

-Types of inheritance

-single level inheritance

-Multilevel inheritance


25) Multiple and Hierarchical Inheritance


-Multuple Inheritance

-Hierarchical Inheritnace26) Function Overloading and Overriding-function overloading

-function overriding

-difference between both

27) Polymorphism in C++


-Polymorphism

-Virtual Members

-Virtual Function


28) Abstract class in C++


-Pure virtual function-abstract class

-abstract methods


29) Friend Function


-friend function


30) Exception Handling


-Exceptions

-try

-throw

-catch