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

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;

Posted Date: 9/20/2012 7:38:53 AM | Location : United States







Related Discussions:- Expression and their types in cpp, Assignment Help, Ask Question on Expression and their types in cpp, Get Answer, Expert's Help, Expression and their types in cpp Discussions

Write discussion on Expression and their types in cpp
Your posts are moderated
Related Questions
write a c++ program for minimum shelf downloads

Want an EA project for Jack Bsher Project Description: New EA game Skills required   Android, C++ Programming, PHP, Metatrader, SQL

Develop G-code generating software Project Description: I'm presently using Slicer on a polymer jetting 3d printer. The toolpaths were thought out for FDM printers and thus a

Write a Program for Calculating Value of an Integer? For a clear understanding of recursive function we shall see an illustration for calculating value of an integer. main() {

(a) client server or multithreaded client-server, where server will create pool of worker threads (say 5) to provide services to pool of clients (say 5 ).Server should be behaving

C Program for REVERSE THE STRING #include stdio.h> #include conio.h> #include string.h> void main() {           char name[30];           char *s;

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Project Description: 1) Develop banking software 2) Payment Gateway System There is some other system available for development. I'm willing to show long-term opportunity

Each function has its own stack frame between %fp and %sp. Let Caller calls Callee. Then Caller's %sp becomes callee's %fp, and callee's %sp set to be a new value (a smaller one be

Problem : (a) What do you understand by the term ‘constructor' in Java? Explain with an appropriate example. (b) Describe the differences between an object and a class usi