# Technology Computer C Programming Codes

Moderator’sApproval: Done PC’sApproval: Approved

HIGHER COLLEGE OF TECHNOLOGY

DEPARTMENT OF ENGINEERING

SECTION: EEE

Final Makeup Assignment

Semester: 2 A. Y: 2019 / 2020

Date of Assignment posting: 26thJune 2020 Time: 11:00AM

48 hours

Date of Uploading: 28thJune 2020 Time: 11:00 AM

Student Name

Student ID

Specialization Engineering

Level Diploma First Year

Course Name / Course Code Computer Programming for Engineering EECP1290

Section No.

Page 2 of 7

Question No. Max. Marks Obtained

Marks

Question No. Max. Marks Obtained

Marks

PART- 1 PART- 3

Q1 3 Q6 4

Q2 4 Q7 7

Q3 3 Q3 9

PART- 2

Q4 5

Q5 5

Sub-Total

Marks

20 Sub-Total Marks 20

Grand Total

Marks ____ /40

Course Lecturer: Second Marker:

Assignment instructions from Course Lecturer:

a) Hand writing for programs is not allowed.

b) Hand drawing for flowcharts is not allowed.

c) Write the appropriate input and output messages for all the programs

Student’s Declaration:(to be filled by student)

Student Name: __________________ ID: _________ Signature: _________

(Digital Signature)

Page 3 of 7

PART – 1 (10marks)

Q1 Write a C program that inputs the total selling price of 8 Toyota Corolla cars and the total

profit earned on them. The program finds and prints the manufacturing price of three of these

cars.

Sample Output:

Input the total selling price of eight Corolla cars in OMR: 65900.98

Input the total profit on eight Corolla cars in OMR: 15785.78

The manufacturing price of three Corolla cars in OMR is: 18793.2

[3]

Q2 Write a C program to enter 3 letters and find the largest and smallest letters and display them.

If the difference between the largest and smallest letter is more than 10, the program

increments the smallest letter by 1, otherwise it decrements the largest letter by 1.

Note: Only conditional operator must be used (no if else).

Sample Output:

Enter 3 letters: z r b

The smallest letter is: b

The largest letter is : z

The smallest and largest letters after updating: c z

[4]

Q3 Write a C program that inputs 4 integers A, B, C and D (as 0 or 1). The program calculates

and prints the values of N and M from the following logical equations:

N= A.C.D.(B.C+A)

M= B.A+C.D.B

Hint: In logical equations the symbol ( . ) represents AND logical operation, ( + ) represents

OR logical operation and ( ) represent NOT logical operation.

Sample Output:

Input A, B, C, D as 1 , 0: 1 0 1 1

N= 0

M= 1

[3]

Page 4 of 7

PART – 2 (10 marks)

Q4 Write a C program to input two five digit numbers n1 and n2. From the first number, extract

the first 3 digits and from the second number extract the last three digits and print the new

numbers. Find the maximum of the two new numbers and print the result. Then find the

difference between this maximum number and the greatest possible 3-digit number and print

the result. Also find and display by how much this maximum number is greater than the

smallest possible 3-digit number.

Sample Output:

Enter two five digit numbers: 12345 10234

The two new numbers are 123 234

The maximum is 234

Difference of the maximum number from the greatest 3-digit number:765

Difference of the maximum number from the smallest 3-digit number :134

[5]

Page 5 of 7

Q5 A bank allows maximum of 30 transactions for a customer in a month. Write a C program to

input the bank balance of customer (bal) at the start of the current month, total number of

transactions (t) in the current month, total transactions amount (amt) in the current month

and an integer choice (ch). According to the input choice, the program performs one of the

following operations as shown in the table below.

Value of ch Operation

1 Finding the remaining balance and displaying it. If the remaining

balance is less than 100 OMR, displaying a warning message ”low

balance”

2 Finding the average amount of transactions performed in this month

and displaying it.

3 Finding the number of transactions remaining for the month and

displaying it.

Any other

number

Display “wrong choice”

Sample input output- 1:

Input the bank balance, no. of transactions and amount transferred: 2000 4 1920

Enter the choice: 1

New balance is 80.0 OMR

Low balance

Sample input output- 2:

Input the bank balance, no. of transactions and amount transferred: 2000 4 1920

Enter the choice: 2

Average transaction amount is: 480.0000

Sample input output- 3:

Input the bank balance, no. of transactions and amount transferred: 2000 4 1920

Enter the choice: 3

Remaining transactions for the month: 26

[5]

Page 6 of 7

PART – 3 (20 marks)

Q6 Write a C programusing else if statement to input one letter by the user and input three real

numbers x, k and n. Then the program performs one of the following operations based on the

input letter and prints its result as shown in the following table.

Letter Operation

From A to H 𝑦 =

𝑘. 𝑥

𝑛 + 5

−

𝑥

𝑘. 𝑛

From I to M

y = 8×3 + 20x -100

From N to Z

𝑦 = 12𝑥

2 + 2

𝑥 + √𝑥 + 1

Any other letter Wrong selection

[4]

Q7 Draw the flowchart and write a C program using else if to calculate the salary of a person

according to the following conditions:

Input the basic salary and designation code. Based on both basic salary and designation

code, calculate the total salary.

Total salary= basic salary+ HRA+ DA+ TA+ phone allowance

Basic

Salary

Designation

code

HRA DA TA Phone

allowance

≤600

OMR

M 30% of basic

salary

7% of basic

salary

6% of basic

salary

10 OMR

≤600

OMR

T 20% of basic

salary

5% of basic

salary

4% of basic

salary

8 OMR

601 – 800

OMR

T 40% of basic

salary

10% of

basic salary

10% of basic

salary

15 OMR

For any other basic salary or designation code display “Please enter correct values.”. [3+4]

[7]

Page 7 of 7

Q8 Draw the flowchart and write a C program using switch. The program inputs one character

selector and three integer numbers. Depending on the selector the program performs some

operations on the integer numbers and display the output. [4+5]

Selector Operations on integer numbers

S or s Displaying the sum of the squares of the numbers.

A or a Displaying the average of the numbers.

E or e Displaying the sum of even numbers and their count.

Other characters Wrong Selector

Sample output 1:

Input a character selector : S

Input 3 integers: 14 7 -4

Sum of square of these numbers=261

Sample output 2:

Input a character selector : a

Input 3 integers: 14 7 -4

Average of numbers= 5.666667

Sample output 3:

Input a character selector : E

Input 3 integers: 14 7 -4

Sum of even numbers =10

Count of even numbers=2

Sample output 4:

Input a character selector : K

Input 3 integers: 14 7 -4

Wrong Selector

[9]

__________________ End of the Assignment __________________