You are on page 1of 9

Lecture - 5

Agenda
• Group work (Sample programs)
• In class quiz review
Programs
• Input 3 numbers a, b, c to your program.
Compare them and find the largest number
between them. Declare an integer and a float
number. Can you compare both of them?
• Read two numbers from the console and print all
the odd numbers between them.
• Read the radius of a circle from your console as
input and print the area of a circle.
• Input a number to your program and print out the
multiplication table until num * 10.
Ex : 2 * 1 = 2
2*2=4
…. 2 * 10 = 20
• Print the following output on screen
1 ****
22 ***
8 **
444 *

• Input 2 numbers a,b and calculate a power b.


• What is the difference between the
following:-
if(isLeapYear == true)
and
if(isLeapYear) ?
Sample questions
• What is the o/p of the foll. Code:-
int a = 10;
int b = 5;
if(a>b)
{
if(b > 5)
S.O.P(“b is” +b);
}
Else S.O.P (“a is:”+a);
Int m = 100;
While(true)
{
if(m < 10)
break;
m = m – 10;
}
s.o.p(“m is”+m);
• Consider foll. Code
Int x, y, z;
Y = 1;
Z = 5;
X = 0 – (++y) + z++ ; What are the values of x, y
and z after execution?
6) X = -7, y = 1, z = 5
7) X = 4, y = 1, z = 5
8) X = 4, y = 2, z = 6
9) X = 3, y = 2, z = 6
• What will be the result of the expression a
% b when a and b are of type int and their
values are a = 10 and b = 6
1) 4
2) 1.66
3) None
4) 1
• a%b when a = -17 and b = -6 ?

You might also like