Skip to main content

C++ Programming World

C++ Tutorial

C- Stuctured Programming Language/ procedural programming
C++ :

  • Object oriend Programming Language developed by  Bjarne Stroustrup in 1980 at AT&bell Labs
  • C++ is also an case sensitive Language.

Object Oriented Programming:

It works on real time objects.
And provide the modules to develope our code easily and we can maintain our code using OOP.

OOP Concepts:

1. Object:

Object is a real world Entity. We can Identify any object by identifying it's characterstics and Behaviour.


Characterstics Behaviour
Attributes Action
Properties Function or Method

EX: CAR
Model No Drive()
Color brake()
Price stop()


2. Class: 

               Class is a group of Similar kinds of Objects  which have same attributes and actions.

3. Abstraction:

                   It is process of hiding the functionality/ Implementation and showing the essentioal things.

Ex: ATM, MEtro stations Entry/exit gate

4. Encapsulation: 

                      Wrapping up of data and it's behaviour into a single unit.
Ex: class


5. Inheritance: 

                       It is the process of adopting the features of Base class into Derived class.
Super Class --------------- Parent Class ---------Base class
Sub Class ------------------ Child Class ---------Derived Class

6. Polymorphism:

It is a greek word where Poly -Many
Morohism ---- forms
i.e. one thing many forms.



Basic Structure of C++ program:

#include<header file>
using namespace std;
int main()
{
Statements;
}

#include :                        preprocessor
header File:                     iostream.h : input output Stream
cin>> --------Used for Data input
cout<< ------- Used for Output

int main(): starting function of any program with return type int.

Statements: statements inclludes following:
variable declaration;
variable initialization;
computational statements;
other statements;

Variable : Variable is a named memory location. Which stores the value at a particular memory location.

EX: a = 10;

Where a  ======== varibale
      10 ======== Value

Data Types:
1. Pre define : int, char, float,double, long,
2. Reference   : class, struct,enum,....

1.WAP to print the Message "Welcome to C++ World!!".

#include <iostream>

using namespace std;

int main()
{
    cout<<"Welcome to C++ World";

    return 0;
}

2. WAP to add two numbers by taking input from user

#include <iostream>
using namespace std;
int main()
{
        int n1,n2, res;
        cout<<"Enter the number 1:";
        cin>>n1;
        cout<<"Enter the number 2:";
        cin>>n2;
     
        res = n1+ n2;
        cout<<"Addition = "<<res;
    return 0;
}

Escape Sequence

Escape Sequence Meaning
\n New Line
\r Carrige Return or Enter
\t Horizontal Tab Space
\v Vertical Tab Space
\\ To Print BackSlash
\? To Print Question Mark
\' To Print Single Quote
\" To Print Double Quote

Operators:

An operator is a symbol that defines the actionperformed on operands.

EX:  a + b
where a, b are Operands
+ is an Operators used to perform the task.

Types of Operators in C++ are as Follows:

1. Assignment Operators
[=,+=,-=,*=,/=,%=]

2. Arithmetic
[+,*,-,/,%]

3. Relational/ Comparision
[>,<,>=,<=,==,!=]

4. Logical
[And (&&), OR(||), Not(!)]

5. increment/ decrement
inc  dec
pre ++a --a
post a++ a--

6. Bitwise: works for Binary Data only
    [And (&), OR(|), Not(~),XOR(^)]
7 .sizeof


These Operators falls into three categories.
a) Unary  : Where we can use single operand
b) Binary : Where we can use two operands.
c) Ternary: Where we can use Three Operands. It is also known as Conditional Operator.
Syntax: (condition):true:false;

Table of Operators

Operators Symbols Type Example
Assignment =, +=, -=, /= ,*= ,%= Unary a=10
Arithmetic +,-,/,*,% Binary a+b
a-b
a*b
a/b
a%b
Relational > , <, >=, <=, ==, !=(Not Equal) Binary It gives Result in Boolen value True/False
a > b
a< b
a>=b
a<=b
a==b
a!=b
Logical && (AND), ||(OR), !(Not) Binary It gives Result in Boolen value True/False
a>b a>c
a>b || a>c
a!=b
Increment/ Decrement ++,--
 
     inc   dec
  pre  ++a  --a
 post  a++  a--
Unary a++, a--
Bitwise And (&), OR(|), Not(~),XOR(^) Binary except Not is a Unary Operator Works on Binary Data only.
a&b, a^b, a|b, ~a

Write a Program to implement the use of Operators.



Output











Comments

Popular posts from this blog

Programming Basics

Logic Building Data_Types Operators Algorithms Pseudo_Code Hello Guys, Let's Play with Logic.........but wait, before that you must know that how to build Logic in Programming as you all know that programming is all about Logic..... So Let's start the game... If you are new Here that means you are absolutely right Place, Or If you already know, than you will learn new things here! If we Talk about the Programming we should be familiar with  these terms..... 1. Variable 2. Data Types 3.Keywords Variable: Variable is something which holds the value.                  Like:      a=10;                 Here,                 a---------------------->  Variable                  10 ---------------------> Value * The Value of Variable can be changed , *  ...

FAQs

Basic Questions on Programming Languages 1. What is the meaning of Programming? Ans: Programming is the process of Scheduling the task to perform step by step to Execute a specific Task. 2. Types of Programming Languages? Ans: Types:             Procedural Programming Language            Object Oriented Programming Language            Object Based Language            Scripting Language Procedural Programming Language   C Programming  Object Oriented Programming Language     C++     Java     C#     VB.Net Object Based Language     JavaScript Scripting Language     Python     VBScript     PHP     Perl     Ruby     R 3. Types Of Operators in Programming Languages. Ans:      Operators Symbols Type Example Assignment = U...