Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

PROGRAMMING WITH C AND C ++

SUBMITTED BY:- JAGMOHAN KUMAR SUBMITTED TO:-MR. SHAILENDRA SONI


B.TECH 2ND YEAR 3RD SEM INDUSTRIAL TRAINING AND
2019UCS016 SEMINAR COORDINATOR

ENGINEERING COLLEGE JHALAWAR


(DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING )
Objective

1. How to debug a faulty code ?


2. How to make code look neat and clean ?
3. Elementing fear of programming
Contents
Getting Started With C Fundamental Of
Object Oriented Programming
Using C++

Module 1st Module 2nd Module 3rd Module 4th

Diving Into C Programming Diving Into C ++ Programming


Introduction to c programming
● C was developed in 1972 by Dennis M. Ritchie
● C is the most widely used computer language.

Why Learn C Programming?


Being a middle-level language, C reduces the gap between the low-level and high-level
languages. It can be used for writing operating systems as well as doing application level
programming.languages such as Python, PHP, Perl, and objective-c are made using c.

Uses Of C Programming?
● Operating Systems
● Language Compilers
● Assemblers
Basic Terms In C Programming
Variable
The variable is the container that holds the data. A variable definition tells the compiler where and how
much storage to create for the variable.

Semicolon
In a C program, the semicolon is a statement terminator. That is, each statement must be ended with a
semicolon. It indicates the end of one logical entity.
printf("Hello, World! \n");

Comments
Comments are like helping text in your C program and they are ignored by the compiler. They start
with /* and terminate with the characters */ as shown below −
/* my first program in C *
Basic Data Type In C Programming
Data Type Size Description

int 4 bytes Stores whole numbers, without decimals

float 4 bytes Stores fractional numbers, containing one or more decimals.


Sufficient for storing 7 decimal digits

double 8 bytes Stores fractional numbers, containing one or more decimals.


Sufficient for storing 15 decimal digits

boolean 1 byte Stores true or false values

char 1 byte Stores a single character/letter/number, or ASCII values


C Programming Structure
C program basically consists of the following parts −
● Preprocessor Commands
● Functions
● Variables
● Statements & Expressions
● Comments

Let us look at a simple code that would print the words "Hello World" −
#include <stdio.h>
int main() {
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Function In C
A function is a group of statements that together perform a task.

Defining A Function In C
The general form of a function definition in C programming language is as follows

return_type function_name( parameter list ) {

body of the function

}
Pointers In C
Some C programming tasks are performed more easily with pointers, and other
tasks, such as dynamic memory allocation, cannot be performed without using
pointers. So it becomes necessary to learn pointers to become a perfect C
programmer.

What Is Pointer ?
A pointer is a variable whose value is the address of another variable.
The general form of a pointer variable declaration is −
type *var-name;
Introduction to c ++
● C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs.
● C++ is a cross-platform language that can be used to create high-performance
applications.

Uses Of C++ Programming


● Application Software Development
● Programming Languages Development
● Computation Programming -
● Games Development
● Embedded System
Why Learn C++?
key advantages of learning C++:
● C++ is very close to the hardware
● C++ is the most widely used programming language
● C++ programming gives you a clear understanding of Object-Oriented
Programming.
Basic Data Type In C++ Programming
Data Type Size Description

int 4 bytes Stores whole numbers, without decimals

float 4 bytes Stores fractional numbers, containing one or more decimals.


Sufficient for storing 7 decimal digits

double 8 bytes Stores fractional numbers, containing one or more decimals.


Sufficient for storing 15 decimal digits

boolean 1 byte Stores true or false values

char 1 byte Stores a single character/letter/number, or ASCII values


Function In C++
A function is a set of statements that take inputs, do some specific computation and produces
output.

FUNCTION OVERLOADING
Example
int myFunction(int x)
float myFunction(float x)
double myFunction(double x, double y)
Pointers And Reference Variable In C++
Pointers In C++
A pointer is a variable whose value is the address of another variable.

References In C++

string food = "Pizza"; // food variable


string &meal = food; // reference to food
Classes And Object In C++

C++ is an object-oriented programming language.

Everything in C++ is associated with classes and objects, along with its attributes and
methods.

A class is a blueprint for the object.

Attributes and methods are basically variables and functions that belong to the class. These
are often referred to as "class members"

To use the data and access functions defined in the class, we need to create objects
Constructor
A constructor in C++ is a special method that is automatically called when an object of a class
is created.To create a constructor, use the same name as the class, followed by parentheses ():

Access
In C++, thereSpecifier
are three access specifiers:

● public - members are accessible from outside the class


● private - members cannot be accessed (or viewed) from outside the class
● protected - members cannot be accessed from outside the class
What Is Oop?
● OOP stands for Object-Oriented Programming.
● OOP is faster and easier to execute

Fundamental Features Of Oop


● Encapsulation In C ++
● Inheritance In C ++
● Polymorphism In C ++
Difference Between C And C ++
C is a subset of C++. C++ is a superset of C.

C contains 32 keywords. C++ contains 52 keywords.

C is a function-driven language.  C++ is an object-driven language

C does no support polymorphism, C++ supports polymorphism, encapsulation,


encapsulation, and inheritance which means and inheritance because it is an object
that C does not support object oriented oriented programming language.
programming.
Difference Between C And C ++
Direct support for exception handling is not Exception handling is supported by C++.
supported by C.

C is a function driven language because C C++ is an object driven language because it


is a procedural programming language. is object oriented programming.

C provides malloc() and calloc() functions C++ provides new operator for memory
for dynamic memory allocation, and free() allocation and delete operator for memory
for memory de-allocation. de-alloca
THANK YOU

You might also like