0% found this document useful (0 votes)
17 views3 pages

Assignment # 1 PF3824723hhh2834

Uploaded by

hdfajkh
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)
17 views3 pages

Assignment # 1 PF3824723hhh2834

Uploaded by

hdfajkh
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/ 3

National University of Computer and Emerging Sciences, Lahore

Campus
Course: Programming Fundamentals Course CS 118
Code:
Program: BSE-1A & BCS-1G Semester: Fall 2021
Due Date 9-OCT-2021 at 11:59 pm Total Marks: 50
Section: 1A & 1G Page(s): 3
Type: Assignment 1
Important Instructions:
1. You have to upload only .cpp file. Assignment in any other format (extension) will not be
accepted and will be awarded with zero marks. You have to make a zip file and upload it onto
the google classroom submission folder. For question 1, name your solution file with your roll
number, i.e., Q1_21L_1111.cpp. Similarly, you can name other questions.
2. You are not allowed to copy solutions from other students. We will check your code for
plagiarism using plagiarism checkers. If any sort of cheating is found, negative marks will be
given to all students involved.
3. For each passing day after deadline, 20% of the marks will be deducted. Three days after the
deadline, no submission will be accepted.
Question 1: [Marks: 5]
Write and run a program that reads a six-digit integer and prints the sum of its six digits.
Sample Input: 153426
Sample output: 21

Question 2: [Marks: 3]
Write and run a program that reads two integers and then uses the conditional expression operator to
print either “multiple” or “not” according to whether one of the integers is a multiple of the other.
Sample Input: 12 6
Output: 12 is the multiple of 6 Sample
Input: 12 13
Output: NON

Question 3: [Marks: 3]
Write a program which takes marks of 5 courses as input, of 5 students and output the students who got
the highest aggregate. Roll# C1 C2 C3 C4 C5
Sample Input: 1391 80 70 60 14 88 1376 70 80 80 88 89 1374 71 82 50 80 79 1372 77 90 90 99 100 1375
73 83 40 81 69
Sample Output: 1372 has highest Aggregate of 456

Question 4: [Marks: 7]
Write a program which takes as input 3 points and tell whether these points are the coordinates of right
angled or scalene triangle.
Sample Input: P1 0 0 P2 1 0 P3 1 1
Sample Output: Right Angle Triangle

Department of Computer Science, FAST School of Computing FAST-NU, Lahore Page 1


Question 5: [Marks: 7]
Write a C++ program that takes three integer numbers from the user. Your program will first print the
integers in ascending order and then in descending order. You cannot use arrays to solve this problem.
Assume all numbers are distinct. For example: if the integers given by the user are 67, -5, 3, then the
ascending order printing will be: -5, 3, 67 and descending order printing will be 67, 3, -5.

Question 6: [Marks: 3]
Write a C++ program that takes two inputs from user; Weight in Kg and Height in meters and calculates
and outputs Body Mass Index(BMI). Formula of BMI in given below.
BMI = weight in Kg /(height in Meters) 2

Question 7: [Marks: 4]
Write a program that takes two integers A and B from the user and swap their values using a third
temporary variable.
Sample Output: Before Swapping: A = 45 B = 32
After Swapping: A = 32 B = 45
BONUS: Solve the same problem, swap the values of two integers A and B but you are not allowed to
use any extra variable other than A and B.

Question 8: [Marks: 4]
Write a C++ program to decide whether the given three numbers are pythagorean triple or not. This
means you will take three numbers as input from the user and check if any order of the number holds
the property c² = a² + b².

Question 9: [Marks: 3]
Write a C++ program to check whether a character is an alphabet, digit or special character.

Question 10: [Marks: 5]


Write a simple C++ Calculator.
You will take two numbers from the user as input.
Then the user will be asked to enter the operator. (Operator will be a single character.)
For now operator can only be one of these {‘+’,’-’,’*’,’/’,’%’}.
After taking that operator you will compute the result and output.
Sample Input: Enter first number 15
Enter second number 10
Enter the operator *
Output: 15*10 = 150.

Question 11: [Marks: 6]


Write a C++ program to print following patterns using only a single cout statement.

Department of Computer Science, FAST School of Computing FAST-NU, Lahore Page 2


BEST OF LUCK

Department of Computer Science, FAST School of Computing FAST-NU, Lahore Page 3

You might also like