Assignment 1 CS
Assignment 1 CS
Assignment # 1
Q 1: Write a C++ program which accepts two complex numbers and perform arithmetic
operations on the provided numbers. For example.
Input:
“Enter the first complex number: 2 + 3j”
“Enter the second complex number: 4 – 5j”
“Choose the operation (+, -, *, /): + ”
Output:
“The result is: 6 – 2j”
Q 2: Write a program which accepts amount as integer and display total number of Notes of
Rs. 1000,500, 100, 50, 20, 10, 5 and 1. For example, when user enter a number, 1575, the results
would be like this...
1000: 1
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
Q.3
a) In this exercise, you create a program that uses two for statements to display the pattern of
asterisks shown in the figure below.(Do not print asterisks using multiple cout statements rather
use a single cout <<”*”)
b) Modify the program and replace the for statements with while.
Q.4 Write the code to display a table consisting of four rows and 11 columns. The first column
should contain the numbers 1 through 4. The second and subsequent columns should contain the
result of multiplying the number in the first column by the numbers 0 through 9.The table will
look similar to the one shown in Figure below.
Use two for statements
1 0 1 2 3 4 5 6 7 8 9
2 0 2 4 6 8 10 12 14 16 18
3 0 3 6 9 12 15 18 21 24 27
4 0 4 8 12 16 20 24 28 32 36
Q.5 In this exercise, you create a program that displays the number of daily calories needed to
maintain your current weight. The number of calories is based on your gender, activity level, and
weight. The formulas for calculating the daily calories are shown in Figure below. Make sure
you ask the user for another operation if required.
Formulas
Moderately active female: total daily calories = weight multiplied by 12 calories per pound
Moderately inactive female: total daily calories = weight multiplied by 10 calories per pound
Moderately active male: total daily calories = weight multiplied by 15 calories per pound
Moderately inactive male: total daily calories = weight multiplied by 13 calories per pound
Test Data
Gender Activity Weight
F I 150
F A 120
M I 180
M A 200
Instructions:
1. Your code must contain proper commenting.
2. You are required to submit the assignment in hard form.
3. Copied assignments will earn negative marks for all the involved individuals.
4. Late assignments will not be accepted..
5. Submission deadline is Friday, 20th November, 2015.