You are on page 1of 7

Assignments BSCS Programming Fundamental

Simple flow control


1. Write a program to print Hello Message. 2. Write a program to print first five natural numbers.
3. Write a program to print 5 * using cout.

4. Write a program that takes two integer values from user and displays their sum. 5. Write a program that takes radius of a circle from user as input and then calculates area of the circle using formulae Area = PI * R * R where R is radius of circle. And PI is a constant defined in the program.

6. Write a program that takes temperature in Fahrenheit and converts it into centigrade using following formulae. C = 5 * (F 32 ) / 9 Where C is centigrade and F is for Fahrenheit.

Use of IF
7. Write a program to take an input, if number is odd then program should print

message Odd number. And if number is even then program should print even number. (Hint : Use Modulus Operator)

8. Write a Program that takes a single digit value from user and then prints whether the

value is an Alphabet or a number or a special character. Hint :(use builtin functions from ctype.h)
9. (Repeat this question with if and switch both) Write a Program that takes marks of a

student and then prints his grade using IF conditionaccording to following criteria a. If marks >= 90 then A+
b. If marks >= 80 and < 90 then Ac. If marks >= 70 and < 80 then B+ d. If marks >= 60 and < 70 then Be. If marks >= 50 and < 60 then C f. If marks >= 40 and < 50 then D

g. Other wise F Grade Switches:


10. repeat assignment no 9 using switch structure.

11.program a simple calculator with at least +, -, *, / , square operations. Hint ( use math.h to use built in mathematical functions. ) 12.write a program that takes date of birth from user as input and then program displays the name of the day (i.e. Monday, Tuesday etc) according to date of birth. For example if your DOB is 10 march 1987, the output should look like this Enter your date of birth: 10 3 1987 You were born on Thursday.

Use of Loops
13.Write a program to print first 10 even numbers using loop.
14. Write a program to print first 10 Odd numbers using loop. 15. Write a program that takes a decimal value from user and converts it in to binary

value. For example binary equivalent of 7 is 00000111 If user enters 7 then program should print 00000111.
16. Write a program that takes a value from user and prints the table of that value using

loop.

OTHER
17. Write a program to swap value of three variables using fourth variable. 18. Write a program that inputs age in years and displays age in days and then age in

months.
19. Write a program that inputs basic salary and calculates 35% allowance and 25%

house rent and then displays Gross Salary.


20. A car can travel 5.3 miles in a liter. Write a program that inputs petrol in liter and

displays how much distance the car can cover using the available petrol.

21. Write a program that inputs a character and displays its corresponding ascii and then

inputs an ascii and displays its corresponding character. (use hint header file stdlib.h and use char(number) to convert ascii to letter , use int(letter) to convert letter to ascii.) 22.write a program that inputs two times in hh:mm:ss format , adds both times and displays total time. 23.write a program that inputs five digit number from keyboard and calculates the sum of its digits. 24.write a program that inputs a letter suppose H and then displays the next three characters. 25.write a program that enters a number and then determines whether it is positive, negative or zero. 26.write a program that enters a character and then determines whether it vowel or not. (do it with two methods if else if and then using switch )
27. write a program that inputs number of month and then displays name of the month.

Practice BSCS Programming Fundamental


28. Write program code to draw the following shapes.

* ** **** ****** * * * * * * ** **** ****** ******** ****** **** ** *

*********************** *********************** *********************** *********************** ***********************

*********************** * * * * * * ***********************

* * * * * * * * * * * * * *

29 . Write a program that inputs a five digit number , separates the number into individual digits and prints the digits separated by space and colon. : (hint use modulus an division) For example Enter number 87359 Out put is 8:7:3:5:9 30 . write a program that prints integer equivalent of the following special symbols % & $ @ ? 31. write a program that inputs two numbers and determines whether 2nd number is a multiple of first number or not. 32. Generating N Random Numbers between two specified numbers.

33. print pyramid of Xs using for loop. Hint (use setw manipulator) X XXX XXXXX XXXXXXX

32. there are 20 racers participating in a car race. Write a program for race manager that help him to register all 20 racers for the competition. Manager need their name, id, sponsor name, address, email, phone no , license no , vehicle no, make and model. (TA will not help in this assignment)
33. Write a program that takes input values from user in an integer array test1 of size 10. and then a. print the array in reverse order. b. find the largest and smallest data values in the array. c. calculates sum and average of all array elements. (TA will not help in this section) d. take any integer input from user in a simple variable and search that value in the array test1. If the value is found print FOUND else print NOT FOUND. (TA will not
help in this section)

e. declare a second array test2 of size 10 and copy all the contents of array test1 to array test2. (TA will not help in this section) 34. Perform operations of addition, subtraction on the following matrices.
5 6 7 44 16 65

99

21

12

29

27

34

45

22

77

55

Also find out the maximum value and its location in the resultant matrix.

35. Write a program then asks you to enter your full name and then prints the length of your name. 36. write a program that enters a string from user and then insert a character into a specified location into the string and then reprint the updated string. 37. Write a program that inputs titles of 10 books and then a. prints the largest title out of all books. b. Inputs a new title and then compares it with all titles if it is found there then print TITLE MATCH else TITLE not Found. 38. Write a program that takes input values from user in an integer array sort of size 10. and then a. write a function bubble to sort the array using bubble sort. b. write a function selection to sort the array using bubble sort. c. sort the array test2 in descending orders using both sorting functions.
d. Write a function sum and average to compute the sum and average of array elements. (TA will not help in this section) e. Write a function product to compute the product of all array elements. (TA will not help in this section) f. Write a function LARGE and SMALL to find the largest and smallest of array elements. g. Write a function SEARCH to find a particular value in the array elements.

You might also like