Assignment 1
Assignment 1
1 Total Marks: 20
Objectives:
To enable students to understand and practice the concepts of:
Data Types and Variables
Arithmetic and Logical Operators
Expression solving
If-else statements
repetition structure
Lectures: 1 to 6
Assignment
An expression is given here. You are required to write a C++ program that solves the given mathematical
expression.
Z = x2 + 2xy – x/y
set the values of x = 2 and y = 1
After evaluation of above expression, you should add the value of z to last digit of your vu id. As a result,
1. If you get an odd number, then you should print your VU id using while loop. This while loop should run as
many times as odd number you got from (z+ last digit of your vu id).
For example, suppose the value of z is 2 and the student’s id is BC123456781. Then by adding last digit of
vu id 1 to value of z, result will be 3 which is an odd number. In this case, program should print your VU ID
for 3 times using while loop.
1. If you get an even number, then you should print your Name using while loop. This while loop should run
as many times as even number you got from (z+ last digit of your vu id).
For example, suppose the value of z is 2 and the student’s id is BC123456782. Then by adding last digit of
vu id 2 to the value of z, result will be 4 which is an even number. In this case, program should print your
Name for 4 times using while loop.
NOTE: Values of “z” and “student’s id” are arbitrary (not real).