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

Introduction to c, All languages are divided into six sections: - variables...

All languages are divided into six sections: - variables, I/O maths, conditional expressions, arrays, functions, subroutines and file handlers. Learning a software language is simi

Define variable declaration in c++, Variable Declaration This declarati...

Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

Compute the average of five numbers, Step 1 Define the program headers and ...

Step 1 Define the program headers and the variables      #include   #include   #include   #include void main()   {       char prompt;     float a,b,c,d,e;     floa

What do you mean by a sequential access file, What do you mean by a sequent...

What do you mean by a sequential access file? - When writing programs which store and retrieve data in a file, it's possible to designate that file into various forms. - A s

Compiler design, Compiler Design - Limit In The Method Instructions

Compiler Design - Limit In The Method Instructions

Prepare an ipad application clash of clans like game, Prepare an iPad appli...

Prepare an iPad application Clash of Clans like game I would like to prepare a free city building app with the in app purchase possibility. An example game could be Clash of Cla

Assignment, write a function rise to the power to find the exponent of a nu...

write a function rise to the power to find the exponent of a number whether function is called

Padovan string, padovan string problem program 1 : package test.padovan...

padovan string problem program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n, String str){        if(n >= 40)

I need torrent seeding software throughout multiple proxies, Project Descri...

Project Description: I'm seeking someone who could write me a torrent seeding client which supports multiple proxies. The goal of the project is to make torrents popular by seed

Luminous Jewels - The Polishing Game, plaese tell the full program for the ...

plaese tell the full program for the above given topic with the input and output

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