## C++ Program to check Armstrong number or not.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

### What is armstrong number?

The Armstrong number n which positive number equal to sum of cube power of individual number.It is also known as Armstrong number,

### Example of armstrong number.

153=[1×1×1+5×5×5+3×3×3]  153
13=[1×1×1+3×3×3]28 is not armstrong

In this programe we must understand programming language and for loop and  if else statement.

### Example 1: Check Armstrong Number (entered by user)

#include<iosteam>
#include <conio.h>
int main ( )
{
int onum,reminder,sum=0,num;
cout<<"please enter the any positive number";

cin>>onum;
num=onum;
//this condition is use to check num not = zero.

while(num!=0)
{
reminder=num%10;
sum=sum+reminder*reminder*reminder;
num=num/10;
}
if(sum==onum)

cout <<onum <<"This number is    armstrong number";

else

cout <<onum<<"This number is not             armstrong";

return 0;
getch ();
}
}

Result
------------------------
Please enter the any positive numer
153
153 This number is Armstrong

In above program ,a positive number enter by the user which value is stored in onum variable.

After that,we copied onum into num variable
num=onum;

Inside the while loop , last digit is different  from num by the operation digit = num % 10;. This digit is cubed and added to the variable sum.

Now, the last digit is removed using the statement num /= 10;.

In the next cycle of while loop, second last digit is different , cubed and add into sum variable.

This simultaneous until no digits are left in num. Now, the total sum sum is compared to the original digit oum.

## C++ Program to check whether number is prime or not.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

### What is prime number?

The prime number mean which postive integer number is divided by 1 or itself.
The prime number such as 13 that is division itself and 1.

In this example we show the prime number is [1,2,3,5,7,11,13,17,19,22]

### Example 1: Program to Check Prime Number given by user.

#include<iosteam>
#include <conio.h>
int main ( )
{
int m,j,flag=0;
cout<<"please enter the any positive number";
cin>>m;
for(j=2;j <=n/2;i++)
{
//this condition is use for non prime
if (m%j==0)
{
flag=1;
break;
}
}

if(flag==0)
cout <<m <<"This number is prime";
else
cout <<m <<"This number is not prime";
return 0;
getch ();
}
}

Result
------------------------
Please enter the any positive numer
8
8 This number is not prime

### Example2: Program to Check Prime Number

#include<iosteam>
#include <conio.h>
int main ( )
{
int m=7,j,flag=0;

for(j=2;j <=n/2;i++)
{
if (m%j==0)
{
flag=1;
break;
}
}

if(flag==0)
cout <<m <<"This number is prime";
else
cout <<m <<"This number is not prime";
return 0;
getch ();
}
}

Output
------------------------

7 This number is prime

## C++ Program to Find Factorial

In this program,we learn to calculate the factorial of num using for loop in this program.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

## Write a program to find the factorial of any number.

We every number is equal to 1*2*3*4*5*..n.You must have basic knowledege of programming language before start program.To understand this program ,you must have the knowledge of c++ programming topics such as for loop and basic syntax.

### For any number ,This is factorial number is given by

[factorial = 1*2*3*4*5*6*..........*n]

## Example 1: Find Factorial of a given number by user

In this factorial program  given value through the user.

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int n=;
int fact;

cout << "Plz enter the any postive number";
cin>>n;

for(i=1;i<=n;i++)
{
fact=fact*i;
}
cout << n<<"Factorial number is="<<fact;

return 0
getch();
}

output
----------------------------------------------
Plz enter the any postive number
5

The greatest number is:120

## Example 2: Find Factorial of a given number

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int n=4;
int fact;

for(i=1;i<=n;i++)
{
fact=fact*i;
}
cout << n<<"Factorial number is="<<fact;

return 0
getch();
}

Result
----------------------------------------------

The greatest number is:120

You should have basic programming knowledege
like syntax and variable and if else statement or for loop that is must learn before starting
the program.

## C++ Program to Find The Largest Number Among Three Numbers.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

### In this programe,you will fimd the largest number between three numbers using if ,if else ,nested if else statement.

In this program,enter three values by user.
This program used more than one way.

## Example1:Find Largest Number Using if Statement

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int num1, num2,num3;

cout << "Plz Enter three numbers";
cin >> num1;
cin >>num2;
cin >>num3;

if(num1>=  num2 &&  num1 >=num3)
{
cout <<  "The greatest number is :"<<n2;
}
if(num2>=  num1 &&  num2 >=num3)
{
cout << "The greatest number is :"<<num2;
}

if(num3>=  num1 &&  num3 >=num2)
{
cout << "The greatest number is :"<<num3;
}

return 0;
getch();
}

output
----------------------------------------------
Plz Enter three number
5
8
9
The greatest number is:9

## Example2:Find Largest Number Using if,else statement

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int num1, num2,num3;

cout << "Plz Enter three numbers";
cin >> num1>>num2 >>num3;

if((num1>=num2) && (num1>=num3))
cout << "The greatest number is:<<num1;
else if((num2 >= num2) && (num2 >= num3)
cout << "The greatest number is:<<num2;
else
cout << "The greatest number is:<<num3;

return 0;
getch();
}

output
----------------------------
Plz Enter three number
5
8
9
The greatest number is:9

## Example3:Find Largest Number Using nested if..else statement

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int num1, num2,num3;

cout << "Plz Enter three numbers";
cin >> num1>>num2 >>num3;

if(num1>=num2)
{
if(num1>=num3)
cout << "The greatest number is:<<num1;
else
cout << "The greatest number is:<<num3;
}
else
{
if(num2 >= num3)

cout << "The greatest number is:<<num2;
else
cout << "The greatest number is:<<num3;

}
return 0;
getch();
}

output
----------------------------
Plz Enter three number
5
8
9
The greatest number is:9

## C++ Program to Check Leap Year

This program check given number is year leap or not.

You must have basic knowledge of  C++ programming language and variable  , while loop and if..ealse and for loop

Leap year that is given number divided by
4.if number is perfectly divided to 4 its also
known as leap year.
leap year such as 2004,2008,2012,2016,2020
2024,2028

## Example: Check given a year is leap year or not

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
int y;

cout << "Plz Enter a year: ";
cin >> y;

if (y % 4 == 0)
{
if (y % 100 == 0)
{
if (y % 400 == 0)
cout << y << " leap year.";
else
cout << y << "not leap year.";
}
else
cout << y << " leap year.";
}
else
cout << y << " not leap year.";

return 0;
}
Output

Plz Enter a year: 2012
2012 leap year.

The  people who want to learn programming language.this website very beneficial for those people.

## C++ Program to Check Whether a Number is Even or Odd.

In this example,we used if...else statement to check given a number even or odd.

Even number. An even number which number is divided by 2 its called odd number.example 2,6,8,10

Odd number.An even number which number is not divided by 2 its called odd number.example 1,3,5,7,11

## Example 1: Check Whether Number is Even or Odd using if or else

#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
int n;

cout <<"plz enter number";
cin>>n;

if (n%2==0)
cout << "Number is even";
else
cout <<"Number is odd";

return 0;
getch();
}

Output
_________________________
Number is even

## Example 2: Check Whether Number is Even or Odd using ternary operators

include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
int n;

cout <<"plz enter number";
cin>>n;

(n%2==0)? cout <<"even":
cout <<number is odd";

return 0;
getch ();
}

output
---------------
Enter the number user
n= 7
number is odd

The people who want to learn programming. this website very beneficial for those peoples.

## Structures

Struture is collection of diffrent data type of variable.Struture is way to create variables and we create member.struture same as class.

Structures are variables which have several types; each type of the object can have different types.
Each type of the structure is called a member of the structure.

## how to declare a sruture in c++ programming

struct keyword through we define struture name (structure name as identifier)

### example...

struct book
{
int bookid;
char title[30];
float price;
};
A structure data type called Book can hold all this information:

struct book{

int bookid;
char title[30];
float price;

};

before the final semicolon, At the end of the structure's definition, we can define one or more structure variables.

There is also another way of declaring variables given below,
struct student s1;

# Initialization
Structure members can be initialized at declaration. This is same as the initialization of arrays; the values are listed inside braces. The structure declaration is preceded by the keyword static.

static struct book b1 ={11,''java'',20,345.45};

## how to access member of structure?

To access a given member the dot notation is use. The ''dot'' is called the member access operator

struct book b1;
b1.bookid = 11;
b1.title = "java"
b1.price = n345.45

## example c++ structure

#include<iostream.h>
#include<conio.h>
struct book
{

int bookid;
char title[30];
float price;

};
void main()
{
book b1;

cout <<  "Please Enter the book id';
cin >> b1.bookid << endle;
cout <<  "Please Enter the book title';
cin >> b1.title << endle;
cout <<  "Please Enter the book price';
cin >> b1.price << endle;

cout << "\n Display the book record." << endle;
cout << "book id"b1.booidid;
cout << "title"b1.title;
cout << "price"b1.price;

getch();
}

Output
-------------------------------------------------------
Display the book record.

Book id  = 11
Title       = jave
Price      =345.45

## Thursday, 21 September 2017

### What is Pointer in c++

Pointer is a variable that stores the address of another variable. They can make a few things substantially less demanding, help enhance your program's productivity, and even enable you to deal with boundless measures of information.

Pointer is utilized to allot memory powerfully i.e. at run time. The variable may be any of the information sort, for example, int, glide, scorch, twofold, short and so on.

Language structure :

To declare a pointer, we utilize a reference bullet between the information sort and the variable name

Pointers require a touch of new sentence structure since when you have a pointer, you require the capacity to both demand the memory area it stores and the esteem put away at that memory area.

data_type *ptr_name;

example :

int *a; roast *a;

Where, * is utilized to mean that ''an'' is pointer variable and not a typical variable.

In this unique situation, the mark is not an augmentation

Key focuses to recall about pointers:

# Normal variable stores the esteem though pointer variable stores the address of the variable.

# The substance of the pointer dependably be an entire number i.e. address.

# Always pointer is introduced to invalid, i.e. int *p = invalid.

# The estimation of invalid pointer is 0.

# and image is utilized to get the address of the variable.

# * image is utilized to get the estimation of the variable that the pointer is indicating.

# If pointer is alloted to NULL, it implies it is indicating nothing.

# Two pointers can be subtracted to know what number of components are accessible between these two pointers.

# But, Pointer expansion, increase, division are not permitted.

# The measure of any pointer is 2 byte (for 16 bit compiler).

Since pointers just hold addresses, when we dole out an incentive to a pointer, the esteem must be an address. To get the address of a variable, we can utilize the address-of administrator (and)

Illustration program for pointer:

#include

int primary()

{

int *ptr, q;

q = 50;

/* address of q is doled out to ptr */

ptr = &q;

/prints address held in ptr, which is &q

cout << ptr;

/* show q's esteem utilizing ptr variable */

cout << *ptr;

return 0;

}

The invalid pointer

Here and there we have to influence our pointers to point to nothing. This is known as an invalid pointer. We dole out a pointer an invalid an incentive by setting it to address 0: int *ptr;

ptr = 0;

/dole out deliver 0 to ptr

or, on the other hand essentially

int *ptr = 0;

/dole out deliver 0 to ptr

C++ Pointer Arithmetic

As you understand pointer is an address which is a numeric appreciate; in this way, you can perform number-crunching operations on a pointer similarly as you can a numeric esteem. There are four number juggling administrators that can be utilized on pointers: ++, - , +, and - .

Illustration :

ptr++;

ptr- - ;

ptr+21;

ptr-10;

On the off chance that a burn pointer indicating address 100 is augmented (ptr++) at that point it will point to memory address 101

C++ Pointers versus Arrays

Pointers and clusters are emphatically related. Actually, pointers and exhibits are tradable by and large. For instance, a pointer that focuses to the start of a cluster can get to that exhibit by utilizing either pointer number juggling or exhibit style ordering.

int primary ()

{

int var[3] = {1, 2, 3};

int *ptr;

cout << *ptr << endl;

ptr++;

cout << *ptr << endl;

return 0;

}

this code will return :

1

2

C++ Pointer to Pointer

A pointer to a pointer is a type of various indirection or a chain of pointers. Ordinarily, a pointer contains the address of a variable. When we characterize a pointer to a pointer, the primary pointer contains the address of the second pointer, which focuses to the area that contains the genuine esteem. int principle ()

{

int var;

int *ptr;

int **pptr;

var = 3000;

ptr = &var;

pptr = &ptr;

cout << "Estimation of var :" << var << endl;

cout << "Esteem accessible at *ptr :" << *ptr << endl;

cout << "Esteem accessible at **pptr :" << **pptr << endl;

return 0;

}

## String

A string is fundamentally an classification of characters which is finished by an invalid character '\0' which show the complete of the string.
Strings are always incase by two fold quotes.

This statement and instatement make a string with "NADI".
To hold the \0 (invalid character) around the complete of the group, the traverse of display is one more than the amount of characters in "NADI".
broil my_name[5] = {'N', 'A', 'D', 'I','\0'};

we can in like manner create the above clarification as takes after:
Sorts of C String limits
To use string limits programming engineer must import String.h header record.
String.h header record reinforces all the string limits in C vernacular.

Types of c++ string function

if programmer write a program then must import string.h header file

There are following of string

strcat () it cocatenates string2 at enf of string1

2 strncat ( )  It add a portion of string to another

3 strcpy ( )  It Copies str2 into str1

4 strncpy ( ) copies given number of characters of one string to another

5 strlen ( ) gives the length of str1.

6 strcmp ( ) Returns 0 if str1 is same as str2. Returns 0 if str1 > str2.

7 strcmpi ( ) Same as strcmp() function. But, this function negotiates case. ''A'' and ''a'' are treated as same.

8 strchr ( ) Returns pointer to first occurrence of char in str1.

9 strrchr ( ) last occurrence of given character in a string is found

10 strstr ( ) Returns pointer to first occurrence of str2 in str1.

11 strrstr ( ) Returns pointer to last occurrence of str2 in str1.

12 strdup ( ) duplicates the string

13 strlwr ( ) converts string to lowercase

14 strupr ( ) converts string to uppercase

15 strrev ( ) reverses the given string

16 strset ( ) sets all character in a string to given character

17 strnset ( ) It sets the portion of characters in a string to given character

18 strtok ( ) tokenizing given string using delimiter

## Arrays

Array is a fixed size collection of similar data type items. Arrays are used to store and access group of data of same data type.
Arrays can of any data type. Arrays must have constant size. Continuous memory locations are used to store array.
It is an aggregate data type that lets you access multiple variables through a single name by use of an index. Array index always starts with 0.

### Example for Arrays:

int a[5]; // integer array
char a[5]; // character(string) array
In the above example, we declare an array named a. When used in an array definition, the subscript operator ([]) is used to tell the compiler how many variables to allocate. In this case, we’re allocating 5 integers/character. Each of these variables in an array is called an element.

### Types of Arrays:

# One Dimensional Array
# Two Dimensional Array
# Multi Dimensional Array

### 1 One Dimensional Array

Array declaration
int age [5];

Array initialization
int age[5]={0, 1, 2, 3, 4, 5};

Accessing array
age[0]; /*0_is_accessed*/
age[1]; /*1_is_accessed*/
age[2]; /*2_is_accessed*/

### 2 Two Dimensional Array

Two dimensional array is combination of rows n columns.
Array declaration
int arr[2][2];

Array initialization
int arr[2][2] = {{1,2}, {3,4}};

Accessing array
arr [0][0] = 1;
arr [0][1] = 2;
arr [1][0] = 3;
arr [1][1] = 4;

### 3 Multi Dimensional Array

C++ programming language allows programmer to create arrays of arrays known as multidimensional arrays.
For example:
float a[2][4][3];

### Pointer to an array

Please go through pointers chapter first to understand this
An array name is a constant pointer to the first element of the array. Therefore, in the declaration:
double balance[50];

balance is a pointer to &balance[0], which is the address of the first element of the array balance. Thus, the following program fragment assigns p the address of the first element of balance:
double *p;
double balance[10];
p = balance;

It is legal to use array names as constant pointers, and vice versa. Therefore, *(balance + 4) is a legitimate way of accessing the data at balance[4].

### Passing Array To Function

We can pass entire Arrays to functions as an argument.
For eg.
#include
void display(int a)
{
int i;
for(i=0;i < 4;i++){
cout << a[i];
}
}
int main(){
int c[]={1,2,3,4};
display(c);
//Passing array to display.
return 0;
}

### Return array from functions

C++ does not allow to return an entire array as an argument to a function. However, You can return a pointer to an array by specifying the array's name without an index.
If you want to return a single-dimension array from a function, you would have to declare a function returning a pointer as in the following example:

int * myFunction()
{
int c[]={1,2,3}
.
.
.
return c
}

## Monday, 18 September 2017

### Break and Continue in c++

Break statement

Break clarification is typically used to end a case in the switch explanation.

Break statement in circles to immediately closes the circle and program control goes to the join issue with description after the circle.

In case break declaration is used as a piece of permanent circles, the break clarification will end the execution of the internal circle and Program control retreats to outer circle.

Sentence structure :

break;

continue statements

In C++ programming tongue the continue with description works probablylike the break clarification. The continue restarts the hover with the accompanying estimation of thing. All the line code underneath continue with enunciation is skips.

syntax :

continue;

In the for hover, continue with clarification maintains a strategic distance from the test phase and scope estimation of the variable to execute again and In the while and do...while hovers, continue with skirts each one of the declarations and program control goes to near the complete of circle

## while loop

The while loop calculates the expression before every loop. If the expression is true then block of statements is executed, so it will not execute If the condition is initially false. It needs the parenthesis like the if statement.

while ( expression )
/*while expression is true do following*/

statements...

### Do While loop

This is equivalent to a while loop, but it have test condition at the end of the loop. The Do while loop will always execute at least once.

### do  statements ;

while ( expression );
/* while expression is true do...*/

### For loop

This is very widely held loop.
For loops work like the corresponding while loop shown in the above example. The first expression is treated as a statement and executed, then the second expression is test or condition which is evaluated to see if the body of the loop should be executed. The third expression is increment or decrement which is performed at the end of every iteration/repetition of the loop.

for (expr1; expr2; expr3)
statements...;

In while loop it can happen that the statement will never execute But In the do-while loop, test condition is based at the end of loop therefore the block of statement will always execute at least once. This is the main difference between the while and the do-while loop.

For example, to execute a statement 10 times:

for (i = 0; i < 10; i++)
cout << i << endl;
-----------------------------------
Output;
0 1 2 3 4 5 6 7 8 9

Another way of doing this is:
i = 7;
while (i--)
statements;
--------------------------
Output;
7 6 5 4 3 2 1

While using this method, make sure that value of i is greater than zero, or make the test i-->0.

## Conditional selection - switch

A switch statement is used instead of nested if...else statements. It is multiple branch decision statement of C++. A switch statement tests a variable with list of values for equivalence. Each value is called a case.

The case value must be a constant integer.

### Structure of switch() statement

switch (expression)
{
case value: statements...
case value: statements...
default : statements...
}

Individual case keyword and a semi-colon (:) is used for each constant. Switch tool is used for skipping to particular case, after jumping to that case it will execute all statements from cases beneath that case this is called as ''Fall Through''.

In the example below, for example, if the value 2 is entered, then the program will print two one something else!

int main()
{
int i;
cout << ''Enter an integer: '';
cin>>i;
switch(i)
{
case 4: cout << ''four''; break;
case 3: cout << ''three''; break;
case 2: cout << ''two '';break;
case 1: cout << ''one '';break;
default: cout << ''something else!'';
}
return 0;
}

To avoid fall through, the break statements are necessary to exit the switch. If value 4 is entered, then in case 4 it will just print four and ends the switch.

The default label is non-compulsory, It is used for cases that are not present.

## if statement

An if statement contains a Boolean expression and block of statements enclosed within braces.

Structure of if statement
if (boolean expression )
/* if expression is true */
statements... ; /* Execute statements */

If the Boolean expression is true then statement block is executed otherwise (if false) program directly goes to next statement without executing Statement block.

### if else statement

If statement block with else statement is known as as if...else statement. Else portion is non-compulsory.

### Structure of if...else

if(condition)
{
statements...
}
else
{
statements...
}

If the condition is true, then compiler will execute the if block of statements, if false then else block of statements will be executed.

### Nested if...else statement

We can use multiple if-else for one inside other this is called as Nested if-else.

if(condition)
{
statements...
}
else if
{
statements...
}
else
{
statements...
}

## cout (output stream)

On most program environments, the standard output by default is the screen, and the C++ stream object defined to access it is cout. cout is an instance of iostream class

For formatted output operations, cout is used together with the insertion operator, which is written as << (i.e., two "less than" signs).

cout << "this is Output";
// prints this is Output sentence on screen
cout << 50;
// prints number 50 on screen
cout << x;
// prints the value of x on screen

The << operator inserts the data that follows it into the stream that precedes it. In the examples above, it inserted the literal string Output sentence, the number 120, and the value of variable x into the standard output stream cout. Notice that the sentence in the first statement is enclosed in double quotes (") because it is a string literal, while in the last one, x is not. The double quoting is what makes the difference; when the text is enclosed between them, the text is printed literally; when they are not, the text is interpreted as the identifier of a variable, and its value is printed instead.

For example, these two sentences have very different results:
cout << "Hello"; // prints Hello
cout << Hello; // prints the content of variable Hello

Multiple insertion operations (<<) may be chained in a single statement:
cout << "This " << " is a " << "single C++ statement";

This last statement would print the text This is a single C++ statement. Chaining insertions is especially useful to mix literals and variables in a single statement:
cout << "I am " << age << " years old and my zipcode is " << zipcode;

## cin (input stream)

In most program environments, the standard input by default is the keyboard, and the C++ stream object defined to access it is cin. cin is an instance of iostream class

For formatted input operations, cin is used together with the extraction operator, which is written as >> (i.e., two "greater than" signs). This operator is then followed by the variable where the extracted data is stored. For example:
int age;
//declares a variable of type int called age
cin >> age;
//extracts a value to be stored in it

This operation makes the program wait for input from cin; generally, this means that the program will wait for the user to enter some sequence with the keyboard.

Extractions on cin can also be chained to request more than one datum in a single statement:
cin >> a >> b;

This is equivalent to:
cin >> a;
cin >> b;
In both cases, the user is expected to introduce two values, one for variable a, and another for variable b. Any kind of space is used to separate two consecutive input operations; this may either be a space, a tab, or a new-line character.

## Operators

An operator is a symbol. Compiler identifies Operator and performs specific mathematical or logical operation. C provides following operators :

### Arithmetic Operators

* multiplication
/ division
% remainder after division (modulo arithmetic)
- subtraction and unary minus

### Logical Operators

&& Called Logical AND operator. If both the operands are non-zero, then condition becomes true.

|| Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true.

! Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false.

Increment and Decrement Operators
Increment and decrement operators are used to add or subtract 1 from the current value of oprand.

++ increment
-- decrement

Increment and Decrement operators can be prefix or postfix. In the prefix style the value of oprand is changed before the result of expression and in the postfix style the variable is modified after result.

For eg.
a = 9;
b = a++ + 5; /* a=10 b=14 */
a = 9;
b = ++a + 5; /* a=10 b=15 */

### Relational Operators

== equal.
!= Not equal.
> < Greater than/less than
>= greater than or equal to
<= less than or equal to

### Cast Operators

Cast operators are used to convert a value from one to another type.
(float) sum;   converts type to float
(int) fred;   converts type to int

### Bitwise Operators

Bitwise operators performs operation on actual bits present in each byte of a variable. Each byte contain 8 bits, each bit can store the value 0 or 1

### ~ one's complement

& bitwise AND
^ bitwise XOR
| bitwise OR
<< left shift (binary multiply by 2)
>> right shift (binary divide by 2)

### Assignment Operators

= assign
-= assign with subtract
*= assign with multiply
/= assign with divide
%= assign with remainder
>>= assign with right shift
<<= assign with left shift
&= assign with bitwise AND
^= assign with bitwise XOR
|= assign with bitwise OR

For example,
a = a + 64; is same as
a += 64;

### Miscsizeof

The sizeof operator returns the size, in bytes, of a type or a variable.
You can compile and run the following program to find out how large your data types are:
cout << "bool:\t\t" << sizeof(bool) << " bytes";
bool: 1 bytes

### Condition ? X : Y

Condition operator: If Condition is true ? then it returns value X : otherwise value Y

,
Comma operator causes a sequence of operations to be performed. The value of the entire comma expression is the value of the last expression of the comma-separated list

### . (dot) and -> (arrow)

Member operators are used to reference individual members of classes, structures, and unions.

& Pointer operator: & returns the address of an variable. For example &a; will give actual address of the variable.

* Pointer operator: * is pointer to a variable. For example *var; will pointer to a variable var.

## Variable Storage Classes

### auto

The default class. Automatic variables are local to their block. Their storage space is reclaimed on exit from the block.

### register

If possible, the variable will be stored in a processor register. May give faster access to the variable. If register storage is not possible, then the variable will be of automatic class.
Use of the register class is not recommended, as the compiler should be able to make better judgement about which variables to hold in registers, in fact injudicious use of register variables may slow down the program.

### static

On exit from block, static variables are not reclaimed. They keep their value. On re-entry to the block the variable will have its old value.

### extern

Allows access to external variables. An external variable is either a global variable or a variable defined in another source file. External variables are defined outside of any function.
Note: Variables passed to a function and modified by way of a pointer are not external variables

### static external

External variables can be accessed by any function in any source file which make up the final program. Static external variables can only be accessed by functions in the same file as the variable declaration.

## Variables

A variable in C++ is a name for a piece of memory that can be used to store information.
There are many types of variables, which determines the size and layout of the variable's memory;

### Variable Names

we can use any combination of letters and numbers for Variable and function names but it must start with a letter.
We can use Underscore (_) as a letter in variable name and can begin with an underscore But Identifiers beginning with an underscore are reserved, And identifiers beginning with an underscore followed by a lower case letter are reserved for file scope identifiers Therefore using underscore as starting letter is not desirable.

Dil and dil are different identifiers because upper and lower case letters are treated as different identifiers

### Variable Types

There are many 'built-in' data types in C.

short int -128 to 127 (1 byte)

unsigned short int 0 to 255 (1 byte)

char 0 to 255 or -128 to +127 (1 byte)

unsigned char 0 to 255 (1 byte)

signed char -128 to 127 (1 byte)

int -32,768 to +32,767 (2 bytes)

unsigned int 0 to +65,535 (2 bytes)

long int -2,147,483,648 to +2,147,483,647 (4 bytes)

unsigned long int 0 to 4,294,967,295 (4 bytes)

float single precision floating point (4 bytes)

double double precision floating point (8 bytes)

long double extended precision floating point (10 bytes)

### Definition, Declaration & Initialization

Definition is the place where variable is created (allocated storage).

Declaration is a place where nature (type) of variable is stated, but no storage is allocated.

Initialization means assigning a value to the variable.

Variables can be declared many times, but defined only once. Memory space is not allocated for a variable while declaration. It happens only on variable definition.

### Variable declaration

syntax
data_type variable_name;

example
int a, b, c;
char flag;

### Variable initialization

syntax
data_type variable_name = value;

example
int a = 50;
char flag = 't';

external and static
initialisation done once only.

auto and register
initialisation done each time block is entered.

external and static variables cannot be initialised with a value that is not known until run-time; the initialiser must be a constant expression.

A variable that has not been assigned a value is called an uninitialized variable. Uninitialized variables are very dangerous because they cause intermittent problems (due to having different values each time you run the program). This can make them very hard to debug.

### Variable scope

refers to where variables is declared.

It can be Inside a function or a block which is called local variables, In the definition of function parameters which is called formal parameters or Outside of all functions which is called global variables.

### Global variables

Global variable are declared outside any functions, usually at top of program. they can be used by later blocks of code:
int g; //global
int main(void)
{
g = 0;
}

### Local variables

Variables that are declared inside a function or block are local variables. The scope of local variables will be within the function only. These variables are declared within the function and can't be accessed outside the function.
void main()
{
int g; //local
g=2;
cout << g;
}

# Structure and Syntax of program

#### c++ Program | Syntax

This Program we show prints Hello World on screen

#include <iostream.h>
using namespace std;
int main ()
{
cout << "Hello World! Syntax ";
return 0;
}

1 . /* This program ... */
The symbols/* and*/ used for comment. This Comments are ignored by the compiler, and are used to provide useful information about program to humans who use it.

### 2. #include <iostream.h>

This is a preprocessor command which tells compiler to include iostream.h file.

### 3. using namespace std;

All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. So in order to access its functionality we declare Syntax with this expression that we will be using these entities. This line is very frequent in C++ programs Syntax that use the standard library.

### 4. main()

C++ programs consist of one or more functions. There must be one and only one function called main. The brackets following the word main indicate that it is a function and not a variable .

5. { }
Syntax braces surround the body of the function, which may havee one or more instructions/statements.

### 6. Cout<<

it is a library function that is used to print data on the user screen.

7. ''Hello World'' is a string that will be displayed on user screen

8. ; a semicolon ends a statement Syntax .

9. return 0; return the value zero to the Operating system.

## Introduction of c++

C++ is a general-purpose programming language that supports procedural, and it is object oriented programming language
C++ is consider as a middle-level language,  it comprises a included  of both high-level and low-level language.

C++ was developed by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's, and is based on the C language. The "++" is a syntactic construct used in C (to increment a variable), and C++ is earmarketed as an incremental improvement of C. Most of C is a subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.
C++ is a superset of C, and that virtually any legal C program is a legal C++ program.

### Object-Oriented Programming

C++ fully supports object-oriented programming, including the four pillars of object-oriented development:

1- Encapsulation
2- Data hiding
3- Inheritance
4- Polymorphism

### Use of C++

C++ is used by hundreds of thousands of programmers in essentially every application domain.

- In Adobe Systems All major applications are developed in C++: Photoshop & ImageReady, Illustrator, Acrobat, InDesign, GoLive

C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.

Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++.

Amazon.com, Facebook, Google, HP, IBM, Microsoft, Mozilla, Nokia & many more companies uses C++ language.

1. vendor-neutral: the C++ standard is the same in any platform or compiler
2. industrial (as opposed to academic): evolved to satisfy the needs of software engineers, not computer scientists

3. efficient. Compiles into highly optimized CPU-specific machine code with little or no runtime overhead.

4. multi-paradigm: allows the use and penalty-free mixing of procedural, OOP, generic programming, functional programming, etc

5. strictly statically typed a large amount of logic (and sometimes even calculations) can be proved and performed at compile time, by the type checking/inferring system.

6. has deterministic memory management (as opposed to Java, C#, and other languages with garbage collectors): the life time of every object is known with absolute precision, which makes destructors useful and RAII possible.