Computer Programming Fundamentals, Exercises of Computer Programming

Algorithm, Traversal, C++ introduction, Event handling solving, Node all in one assignment

Typology: Exercises

2018/2019

Uploaded on 07/17/2019

essa-alfalasi
essa-alfalasi 🇦🇪

4

(1)

1 document

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Computer Programming Fundamentals and more Exercises Computer Programming in PDF only on Docsity!

Signature Date

Lab Exercise Sheet

Student Name: ID:

Course Title: Computer Programming

Fundamentals

Course ID: CPE 201

Instructor Name(s): Dr Riktesh

Srivastava

School: Engineering and Technology

Semester: Summer 1 Academic Year: 2018/

Course Learning Outcomes:

CLO1: Identify the concept and properties of algorithms , problem solving strategies

and problem solving process

CLO2: Writing, compiling, debugging and executing programs using computer

programming fundamentals

CLO3: Utilize and built-in data structures

CLO4: Design, code, test, and debug simple event-driven programs

CLO5: Solve basic problems in engineering through programming assignments and

course projects

Instructions:

1. Students are required to complete all the exercise in Lab.

2. Take the snapshot of the outcomes, wherever it is required.

3. All the result should be printed and attached to the lab exercise sheet before

submission.

4. All the steps are required for the mentioned exercises. Marks will be awarded based

on the steps required to complete the exercise.

Question 1 2 3 4 5 6 7 8 9 10 TOTAL

CLOs CLO 1^ CLO 2^ CLO 3^ CLO 4^ CLO 5

Marks 4 4 4 4 4 20

Marks Awarded

Essa Salah Alfalasi CEE

Question 5 (4 Marks) [CLO 5]

[Debug and Compile code online at https://www.onlinegdb.com/online_c++_compiler]

a) Assume you to be working in an Electronics Company, named XYZ LLC. You are

designing the machine in which you need to convert the Celsius into Fahrenheit

and use it for machine design. Write the C++ code to do the needful.

Formula

Fahrenheit = Celsius * 9/5 + 32

b) For a Banking project, your company needs to design the automatic machine to

calculate the simple interest for Current Account and install the code in the bank

system. There are three parameters that needs to be entered, Principal amount

(P), Rate of Interest (R) and Time Period (T).

Formula

Simple Interest = (PRT)/

1. Question1: A),B),C): Step1: Ask user to enter machine accuracy. Step2: Store machine accuracy in M_A. Step5: If TRUE then print “Average Feedback” else Print “Negative Feedback”.

!"#$:& ;, <=>? "(# 4 $ 2 + 4 " @AB 0 +"+C# D##EF 3 )G #H 0 # '(#) / 13 + 4 +, - ./ + 0 12 # 3 "# 2 "( 34 I 6 34 E HBJ# 2

"( 34 56 7 I 6 K - ./ K 569 L

B).

3. Question 3: a) Linked List: a.a). Traversal: Step 1 : Check if START is not Null Step 2 : Set PTR = START Step 3 : While PTR - > Next != NULL VAL = PTR - > Data PTR = PTR - > Next [End of While] Step 4 : Exit

a.c) Insert Node: First Node: Step1: TempNode - > START Step2: START - > NewNode Step3: START-> Next = TempNode Step4: EXIT Between Nodes: Step1: ptr = START Step2: While ptr != NULL Step3: If ( ptr->Data == ’VAL’) then X=new node Read DATA(X); X->NEXT = ptr-> NEXT ptr->NEXT = X [End of if] Step4: ptr= ptr-> NEXT [End of while] 5.END. Last Node: Step1: Begin with Head Step2: While PTR != NULL If (PTR == NULL) PTR - > Next = A Else PTR = PTR - > NEXT END Of IF END of While Step3: EXIT

a.d) Delete Node: First Node: Step 1: PTR=START Step 2: START = START NEXT Step 3: FREE PTR Step 4: Exit Between Nodes: Step 1: PTR=START Step 2: While (PTR!=NULL) PREPTR=PTR PTR=PTR->NEXT If (PTR->DATA==VAL) PREPTR->NEXT = PTR->NEXT [End of IF] [End of While] Step 3: Exit Last Node: Step 1: PTR=START Step 2: While (PTR!=NULL) PREPTR=PTR PTR=PTRNEXT If (PTR==NULL) Set PREPTRNEXT=NULL FREE PTR End of If End of While Step 3: Exit

c) Queue: Insert: Step1: While (queue != MAX_SIZE ) If (queue == MAX_SIZE) Print “Queue is FULL” Else rear = rear + 1 queue[rear] = data [end of if] [end of while] Step2: Exit Delete: Step1: While (queue != empty) If (queue == empty) Print “Queue is empty” Else Data = queue[front] front = front + 1 [End of If] [End of While] Step2: Exit

!" #$%&'() !+*