Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 68 pages
Presentation

Presentation C/C++ (Programming)

Document preview thumbnail
Preview 4 out of 68 pages

Hey there! I’m linking my personally made c/c++ language codes in this file. This file contains plenty of codes and their descriptions which is easily understandable and does not involve any errors! Note!!! These codes are only for “embarcadero dev-c++ 6.3” and only supported on this software.

Content preview

; 20TH WEEK(1ST DAY)
What is C++?
C++ is an “object oriented” language created by Bjarne Stroustrup and released in 1985. It
implements “data abstraction” using a concept called “classes”, along with other features to
allow object oriented programming. C++ adds a concept called “operator overloading” not
seen in the earlier OOP languages & it makes the creation of libraries much cleaner.
C++ maintains aspect of the C programming language, yet has features whi9ch simplify
memory management.
C++ could be considered a superset of C.
C programs will run in C++ compiler.
C uses structured programming concepts & techniques while C++ uses object oriented
programming.

Features of C++ Language: -
C++ is an object oriented programming. The main features of C++ language are as follow:-

1. CLASSES:- The classes are user defined data types. A class is a collection of similar
type of data elements or objects.

2. DATA ABSTRACTION:- It means collection of data methods(functions). It refers the
act of representing essential features without including background details. It is also
known as abstracton data type (ADT).

3. DATA HIDING:- In C++ class construct allows to declare data & methods as a public,
private & protected group. The implementation details of a class can be hidden by data
hiding.

4. DATA ENCAPSULATION:- The internal data of a class are separated from outside
world. In other words, encapsulation groups all the pieces of an object into next package.

5. INHERITANCE:- It means the derivation of a class from a base class is called parent
class or basic & derived class is called child class. Inheritance is a property of class to
inherit the basic features of a class .

6. POLYMORPHISM:- Poly means more than one any operation & morphism means
forms. In OOPs a function or a name is used more than one.

7. DYNAMIC BINDING:- The binding refers to the linking of a procedure call to the
code to the executed in response to the call.

8. MESSAGE PASSING:- It is the another feature of OOPs. It consist of a set of objects
that communicate with each other.

,DIFFERENCE BETWEEN C & C++ LANGUAGE:

SR. C LANGUGAE C++ LANGUAGE
1. C is a procedural language. The o/p of one C++ is a object oriented language. It is
line become i/p to other. also called C with Classes.
2. C is a top down approach. C++ is a bottom up approach.

3. C doesn’t have property of polymorphism It includes the polymorphism

4. In C overloading of operators & functions In C++ overloading of operators &
are not possible. functions is possible.
5. It doesn’t support data abstraction, data It includes properties like data
hiding & data encapsulation. abstraction, data hiding & data
encapsulation.
6. C doesn’t include concepts of objects & C++ is purely on object based which
classes. have their own physical existence but
integrated together.
7. In it, printf() & scanf() used for input & In it, cin & cout used for input & output.
output.
8. It doesn’t have concept of inheritance It supports the concept of inheritance

9. It doesn’t have more & strong exception In it, exception handling is don eby the
handling extra
10. The header file for I/O is <stdio.h> The header file for I/O is <iostream>

11. C does not support friends, static methods, C++ provides friends, static methods,
constructors, destructors. constructors, destructors for the object.

VARIABLES:-
It is the name to given to memory location where some data or value is stored. In C++ language
variable must be declared before it can be used. Variables can declared at start of any block of
code. Values of the variables can be change during the execution of the program.

RULES FOR DECLARING VARIABLES:-
1. The name of the variable must be starting an alphabet.
2. The variable name should not have any space in between.
3. All the variable name must be separated by comma (,).
4. It should not be a keyword.
5. The length of variable name should not be normally more than 8 characters.
6. Upper and lower case matter in variable.
Example :- a=2;
B=5; C=a+b;

, KEYWORDS
Keywords are special words where meaning is already defined to the compiler. A valid identifier
is a sequence of one or more letters, digits or underscore characters(_) Keywords cannot be used
as variables or identifiers. Some keywords are the following:-
Break while Char continue
Default do Else float
Goto if Int return
Inline private Class delete
For friend Public protected


DATA TYPES:-
C++ language becomes powerful with the help of data types. Data types describe the type or
characteristics of variables or data.
SPECIFIC DATA TYPE VALUES:-

Data type Bytes of Range Value
memory

Int 2 -32768-32767 843

Float 4 -3.4e38-3.4e38 45.758

Char 1 -128-127 A

Bool 1 True or false 0 or 1


PROGRAM TO PRINT HELLO

#include<iostream>
using namespace std;
int main()
{
clrscr();
cout<<”hello”;
cout<<”welcome in c++”;
return 0;
}
PROGRAM TO SET FILL BLANK SPACES WITH DIFFERENT SYMBOLS

#include<iostream>
using namespace std;
int main()
{cout.fill(‘/’);
cout.width(20);
cout<<”wel”<<endl;

, cout.fill(‘_’);
cout.width(10);
cout<<”DONE”;
return 0;}
2nd DAY
PROGRAM TO ADD, SUBTRACT, MULTIPLY & DIVISION OF 2 NUMBERS

#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e,f;
clrscr();
cout<<”enter 2 numbers:-”;
cin>>a>>b;
C=a+b;
Cout<<”Addition is :-”<<c;
d=a-b;
cout<<”Subtraction is :-”<<d;
e=a*b;
cout<<”Multiplication is :-”<<e;
f=a/b;
cout<<”Division is :-”<<f;
return 0;
}

OPERATORS:-
Once we know of the existence of variables & constants, we can begin to operate with them. For
that purpose, C++ integrates operators. The operators makes C++ code shorter & more
international, since it relies less on English words, but requires a little of learning effort in the
beginning.
Following are the operators used in C++ language:-


OPERATOR NAME TYPES SYMBOL EXAMPLE

1. Addition + 2+1=3
2. Subtraction - 20-10=10
AIRTHMETIC 3. Multiplication * 5*4=20
OPERATORS 4. Division / 4/2=2
5. Modulo % 5%2=1

1. AND && x>y && x>z
LOGICAL OPERATOR 2. OR || a<b || b>c
3. NOT ! a==b ! a==c


ASSIGNMENT OPERATOR = a=5

1. INCREMENT ++ a++ / ++a

Document information

Uploaded on
December 5, 2022
Number of pages
68
Written in
2022/2023
Type
Presentation
Person
Unknown
CA$22.85

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
2
Last sold
-


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions