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

Area, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

If/else statement, to compute the net pay of an emplyee, given his/her pay ...

to compute the net pay of an emplyee, given his/her pay rate, number of hours and tax rate

Determine the size of operator, The size of () operator This is a pseud...

The size of () operator This is a pseudo-operator given by the language, which returns the number of bytes taken up by a variable or data type. The value returned by this opera

What is an explicit constructor, A conversion constructor declared with the...

A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to execute an implied conversion of types. Its purpose is reserved ex

Pos console cpp unit testing, Pos Console CPP Unit Testing Project Descr...

Pos Console CPP Unit Testing Project Description: Do the CPPUnit Testing for the project. Have all the functions done. Skills required are Android, C Programming, C++ Prog

Need epos programmng and building, Project Description: I have a barber ...

Project Description: I have a barber salon I am seeking someone to build me software for my PARTNER PT6910 touch screen till system. This software must add multiple staff login

Loop, A company needs 200 pencils per year . you cannot simply use this pr...

A company needs 200 pencils per year . you cannot simply use this price as the cost of pencils two years from now. Because of inflation the cost is likely to be higher than it is

Programming Assignment 4, For this program, you are going to modify your pr...

For this program, you are going to modify your previous program (program 3) so that it will now have a menu to see if the user wants to read the input from a file or interactively.

Program, write a class player that contains attributes for player name,avg ...

write a class player that contains attributes for player name,avg and team.write three functions to input,change and display these attributes.also write a constructor that asks for

Program for number game, - Create a program that uses at least two function...

- Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulati

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