You are on page 1of 3

[EE-163 COMPUTERS & PROGRAMMING]

Instructions:
1) The assignment needs to be completed individually. Collaboration with other
students is not allowed however sharing of ideas is acceptable here ideas
strictly mean ideas and not codes. You also need to provide reference of person
with whom you have shared ideas.
2) The theme of this assignment is DIY (Do It Yourselves), however you can take help
from books, internet, discussion forums etc on one condition only: provide
complete and proper reference at every point where you have used these
resources.
3) Method of referencing:
Put an asterisk [ * ] at the point of reference in the program and at the foot of the
same page provide the reference starting with the asterisk [ * ]. For a second or
third reference use two or three asterisks respectively [ ** , *** ].
The reference at the foot should be complete like:
*www.cprogramming.com/steve_summit/q%27_35%20.htm
**Introduction to C Programming by Paul Wolfowitz, Page 39-40
***Idea taken form Muhammad Ahmed, TE(Electronic), Section A, Roll No.: EL-133
4) The assignment needs to be submitted on print. A template is provided herewith
for this purpose. You are not allowed to change template attributes which are:
a) Document Type: Microsoft Word Document
b) Font: Courier New
c) Size: 12
d) Line Spacing: 1.0
Non-compliance shall lead to rejection of your assignment.
5) Programs made for each question should be tested on the compiler. If any of them
are not running satisfactorily by the end of deadline, do mention it in comments.
6) Sessional marks for this assignment are 05equally divided among all questions.
7) If you are using any technique/function/library not covered in the course to solve
the problems, provide brief documentation and reference for them in comments.
8) Non-compliance with any of these instructions shall lead to deduction of marks.
9) Assignment submission deadline: Announced by respective course teacher
REMEMBER: Assignments shall be compared for similarities and checked for
plagiarism. Remember the rule of prudence: Copying is a Crime punishable by
deduction of marks.
Question 1:
Write a program that asks user to enter a decimal integer and displays its Octal and
Hexadecimal equivalents.
Sample Run:
Enter an integer: 12454 [user presses ENTER]
Octal Equivalent: 30246
Hexadecimal Equivalent: 30A6

[EE-163 COMPUTERS & PROGRAMMING]


Question 2:
Write source code in C++ to convert a decimal integer taken from user into its binary
equivalent. The binary equivalent should be stored in a boolean array. Once converted,
the program displays the binary equivalent on screen.
A problem might arise in this program: the input integer given by user might over-flow.
Make your program defensive against the situation of overflow by using limits header.
Search text/internet on how to use the limits header to detect int overflow and give
reference of the resource you use.
Note: First write the basic conversion then solve the mentioned problem.
Question 3:
The LCM of two integers A and B is the smallest positive integer that is a multiple of both
A and B.
Mathematically,
LCM(A,B)=C
And an important property being:
LCM(A,0)=0
Write a program that calculates the LCM of two (2) positive integers entered by the user.
Note: Take help from math resources (books, internet etc) to clarify your LCM concept
first and write the program later.
Question 4:
Write a program that uses a function to convert an input string from lower-case to
upper-case letters. The function should only convert lower-case letters of the string to
upper-case equivalents and leave the rest un-changed. Following is the prototype for the
function to be made:
string tocapital( string x );
Note: Use string access methods and string class functions inside the function definition
and take help from the ASCII chart.
Question 5:
Using ctime and cstdlib library functions, write a program that simulates the throw of a 6sided dice with faces numbered 1 through 6. The program should allow user to throw the
dice any number of times and record the result of each throw in an integer array. Finally
the program displays consolidated results regarding the number of times each face has
appeared.
Sample Run:
********************** Simulation of 6-sided dice throw********************
Enter the number of times you want to throw the dice: 20

[EE-163 COMPUTERS & PROGRAMMING]


Result:
1 appeared: 2 times
2 appeared: 4times
3 appeared: 3 times
4 appeared: 5times
5 appeared: 3 times
6 appeared: 3 times

You might also like