# junaid program assignment

Post on 18-Jul-2015

88 views

Category:

## Education

Embed Size (px)

TRANSCRIPT

Problem Set for Sequential StructureProgramming Assignment

Convert the following mathematical expressions into C++ Expressions.

Algebraic ExpressionC++ Expression

(a*b)-(c*d)(m+n)*(a+b)3*x*x+2(x)+5(a+b+c)/(d+e)[(2*b*y)/(d+1)-(x)/3(z+y)]

Which of the following are invalid variable names and why?

BASICSALARYvalid variable.#MEANis wrong because # is not allowed for variable.2015_DDayinvalid variable.group.Is variable.basic-hra- is not allowed in variable._basicis variable.422numbers are not variables.Plot # 3invalid statement # is not allowed in variable.hELLOis variable.population in 2006spaces are not allowed in variable.over timeis again wrong due space in variable.mindovermatteris variable.queue.. is not is variable.teamsvictory is not allowed in variable.FLOATis variable.

Evaluate the following expressions according to their precedence.

ExpressionEvaluate C++ Expression

(A)g = big / 2 + big * 4 / big - big + abc / 3 ; (abc = 2.5, big = 2, assume g to be a float) (B) on = ink * act / 2 + 3 / 2 * act + 2 + tig ; (ink = 4, act = 1, tig = 3.2, assume on to be an int) (C) s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ; (qui = 4, add = 2, god = 2, assume s to be an int) (D) s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ; (a = 4, g = 3, assume s to be an int)