You are on page 1of 5

COMSATS Institute of Information Technology, Wah Campus

Department of Computer Science

Program/Class: BSE-2A Instructor:Engr. Shahzad Ahmad Malik


Subject: Programming Fundamentals Marks: 10
Due Date: 09 April 2019 Due Time: 16:00 hrs

Assignment 04

Q. No. 1
Write a program to read a number N from user and find first N primes.
Q. No. 2
Write a program to read your age in years in an integer type of variable. Namaz was not an
obligation on you in your first 7 years. Subtract 7 years from the age and after this subtraction,
display how many Prayers in total you had to pray.

Enter your age: 20


Obligatory Namaz years are: 13
You had to pray 23725 Salats in your 13 years.

Q. No. 3
Write a program to display the following outputs using for, while and do-while.

5 54321 5 54321
54 5432 54 5432
543 543 543 543
5432 54 5432 54
54321 5 54321 5
Pattern 1:

Pattern 2:
Pattern 3:
patt

pattern 4:

Q. No. 4
Write a program to print a multiplication table in the following pattern using nested loops (for,
while and do-while).

1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36

Q. No. 5
Display the sum of digits of a number. For example, number = 245, the sum is 11.

You might also like