C Programming/Flow Control/Assignments
Appearance
(Redirected from Introduction to C programming/Quizes/BooleanLogic)
Question 1
[edit | edit source]Assume that w=6, x=10, y=6 and z=3. What are the truth values of the following statements?
- w<9
- w!=y
- z>x
- z<=y
- x-6>y*2
Question 2
[edit | edit source]With the same values of w,x,y and z, what are the values of the following combinations?
- w<9 && w!=y
- x+7>2 || x==6
- !(x-9>1)
- !((x>y) && (x<z))
- (x>7) && !(x>7)
- (x>7) || !(x>7)
Question 3
[edit | edit source]Under what values of x, y, and z do the following numbered statements get executed? Give the answers in forms like x>y>z.
if(x==y){ statement 1; statement 2; } else if(y>z){ statement 3; if(x==z){ statement 4; if(y<z){ statement 5; } } } else{ statment 6; }
Question 4
[edit | edit source]Under what values of x do the following numbered statements get executed?
switch (x){ case 0: statement 1; break; case 1: statement 2; case 2: statement 3; case 4: statement 4; break; case 5: case 6: statement 5; default: statement 6; }
Draw a rectangle with dots
[edit | edit source]column *** * * row * * ***
Draw a rectangle with dots with column = 3 and row = 4
Draw a staircase
[edit | edit source]# ## ### #### ##### ######
Draw a staircase of 6 steps
Sum of all integer numbers from 1 to n
[edit | edit source]Use loop to calculate the sum of all integer numbers from 1 to n, where the value of n is passed from the command line while running the program.