Expression and their types in cpp, C/C++ Programming

Assignment Help:

Expression and their types:

An expression will be in form of mathematical expression with C++ syntax embedded

with it. Expressions are of following types which may be used in any combination.

Constant Expression:

int x;

x = 12 * (5 +7);

Integral Expression:

It is the expression used to create integer result.

int x;

x = 5.34 + int(4.23);

Float Expression:

It is the expression used to create floating point result.

float x;

x = 5.23 + float(4);

Pointer Expression:

It is the expression used to create address of a variable result. int x, *p;       p =&x;

 

Relational Expression:

It is the expression used to compare two variables or values. int x,y;

bool b;

b = true; b will be 1

b = false; b will be 0

b = x < y; //If x is less than y b =1 else 0

b = x ==y; // if x is equal to y than b =1 else 0 if (x

{ true block;

}

else

{false block;

 

}

Logical Expression:

It is the expression used to match up to two or more relational expression.

int x,y,z;

if (x

{ true block;

}

else

{false block;

}

Bitwise Expression:

It is the expression used to manipulate data at bit level.   It is used to multiply and divide x2

powers of 2.

x << 3;

y >> 2;

 

Special Assignment Expression: Chain Assignment:

int x = y =z =10; is wrong statement.

int x=y=z; is invalid statement Cannot assign as chain at declaration. int x, y, z =10;

x= y =z; The value of x and y is 10. x=y=z=20; This is valid statement. Embedded Assignment:

int x, y;

x = (y=10)+20;  The value of x will be 30 and y will be 10.

 

Compound Assignment:

It is similar to short hand operator expression in C.

x = x +y;

x +=y;

 

Implicit Expression:

Implicit mean hidden or clear or implied.  It is like to casting with little change.  The

conversion is done automatically without calling the cast.    The conversion will be from lower end to higher end, that integer can be change in to float.  To convert float to integer cast should be used. The variable must be casted independently i = float(a)/float(b);

x = 10 + 12.45;


Related Discussions:- Expression and their types in cpp

What is memory allocation, What is memory allocation? Memory Allocation...

What is memory allocation? Memory Allocation : It is the method of allocating memory storage to program in such that the program can be run.

Write a program to calculate the timetable, Write a program to calculate th...

Write a program to calculate the timetable for numbers 1 -> 10 and display them as follows. Your solution should use for do loops      #include stdio.h void main() {    char p

C language, in a program for what purpose print f and scan f is used

in a program for what purpose print f and scan f is used

Define the modulo division operator in c language, Define the Modulo Divisi...

Define the Modulo Division Operator in c language? The C provides one more arithmetic operator % called as modulo division operator and this operator yields the remainder of an

C program to search for a given character in a string, Program is to search...

Program is to search for a given character in a string: Program is to search for a given character in a string and print point of match char *stsearch(char *string, char sea

Program that predicts users age, Program: Write a program that predicts...

Program: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an

COMPUTER, THEORY OF COMPUTER PROGRAMMING

THEORY OF COMPUTER PROGRAMMING

Random searching, write aprogram for random -search to implement if a[i]=x;...

write aprogram for random -search to implement if a[i]=x;then terminate other wise continue the search by picking new randon inex into a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd