Sharp Tutorial
data type and operator in c++

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

introduction to c++

  • C++ Home
  • Introduction to C++
  • History features
  • Sample Programs
  • cout , cin , endl
  • Data type and Operators
  • if else in c++
  • loop in c++

Oops in C++

  • Object / Class
  • Constructor
  • Function & Constructor Overloading
  • Inheritance
  • Overriding

Advanced C++

  • Strings in C++
  • Exception Handling
  • Special Functions
  • C++ Programs

data type in c++

C++ has basic data type (int ,float,char,string and boolean). Secondary data type like array pointer and structure etc. 

We can also create user  defined data types eg : class type object etc.

Primary or basic data type may be declared as following,

#include<iostream>
using namespace std;
int main()
{
int age=25;
float mrp=45.50;
double pi=3.24;
char vowel='a';
string course="c++";
cout<<"age="<<age<<endl<<"mrp="<<mrp<<endl<<"pi="<<pi<<endl<<"char="<<vowel<<endl<<"course="<<course;
 }

output of all data type is as following.

Operator in c++

1. Unary Operator :- only single operand is required to operate.

eg: increment operator ++
    ( further two types are: pre increment ++a and post increment a++).
    decrement operator – –                                                                                                                                                ( further two types are: pre decrement – –a and post increment a – –). 

 

2. Binary Operators :- require two operands to operate.

a. Arithmetic Operators ( + , – , * , /  etc )                                                                                                                   modules operator % gives the remainder part (eg: 7 % 3 gives 1).

b. Relational Operators ( < , <= , > , >= , == , != )

c. Assignment Operators ( = ) :                                                                                                                                    This operator assigns the right value to the left side operand.

d. Logical Operators:

  • logical and ( && ) used to combine multiple conditions (return true if all conditions are true).
  • logical or ( || ) used to combine multiple conditions (return true if any of the conditions is true).
  • logical not ( ! ) Returns True if condition is False and returns False if it is True.

e.Bitwise Operators ( & , | , ^ , ~ , >> , << )                                                                                                                The bitwise operators are used to perform bit level operations in C++ programming language. When we use the bitwise      operators, the operations are performed based on the binary values. 

eg: if two variables A and B are:
A = 25 (11001) and B = 20 (10100)
then, A & B ⇒ 16 (10000)  

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial