0% found this document useful (0 votes)
54 views2 pages

Assignment 1 CS

This document contains instructions for programming assignment #1 which includes 5 questions. Question 1 asks students to write a program that accepts complex numbers as input and performs arithmetic operations on them. Question 2 asks students to write a program that takes an integer as input and displays the number of notes needed to make that amount. Question 3 asks students to write a program that displays a pattern of asterisks using for and while loops. Question 4 asks students to write a program that displays a 4x11 multiplication table using two for loops. Question 5 asks students to write a program that calculates daily calorie needs based on gender, activity level, and weight. The document provides test data and instructions regarding comments, submission format, plagiarism, and deadline

Uploaded by

Muhammad Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

Assignment 1 CS

This document contains instructions for programming assignment #1 which includes 5 questions. Question 1 asks students to write a program that accepts complex numbers as input and performs arithmetic operations on them. Question 2 asks students to write a program that takes an integer as input and displays the number of notes needed to make that amount. Question 3 asks students to write a program that displays a pattern of asterisks using for and while loops. Question 4 asks students to write a program that displays a 4x11 multiplication table using two for loops. Question 5 asks students to write a program that calculates daily calorie needs based on gender, activity level, and weight. The document provides test data and instructions regarding comments, submission format, plagiarism, and deadline

Uploaded by

Muhammad Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

INTRODUCTION TO PROGRAMMING

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.

You might also like