Search Header Logo
Problem-solving

Problem-solving

Assessment

Presentation

Computers, Mathematics

University

Practice Problem

Hard

Created by

Alaa AlChalabi

Used 14+ times

FREE Resource

10 Slides • 6 Questions

1

Review

GNG 1106

Slide image

2

Reminder

Deliverable 1 of the project is due Nov 29, 2020 at 11:59 pm.

3

Slide image

Problem Solving Method - An Example

4

Problem

A train leaves city A travelling towards city B at some given speed (km/h). At the same time a train leaves city B going to city A at some given speed (km/h). Write a program that will compute the distance from city A where the trains will pass each other.

Slide image

5

Multiple Choice

What is the first step of problem solving?

1

Identification

2

I/O Information Gathering

3

Test Cases and Design

4

Implementation

5

Testing and Verification

6

Step 1: Identification

  • In this case the problem is rather simple and unambiguously defined so step 1 is simply a re-statement of the problem described:

  • –A train leaves city A travelling towards city B at some given speed (km/h). At the same time a train leaves city B going to city A at some given speed (km/h). Write a program that will compute the distance from city A where the trains will pass each other.

Slide image

7

Multiple Choice

In which step of problem-solving do we start coding/programming?

1

1

2

2

3

3

4

4

5

5

8

Step 4: Implementation

It is actually step 4 where the coding should start after identifying the problem, analyzing its parameters, and designing the solution.

Slide image

9

Multiple Select

In plotting using PLPLOT library, which of the following is the correct order of the functions that needs to be used for plotting?

1

plinit, plstring, plssub, plline, plend

2

plstar, plenv, plend, pllab, plline

3

plinit, plenv, plcol0, plpoin, plend

4

plstar, plenv, plcol0, plline, plenv, plpoin, plend

10

Plplot library

  • plinit to initialize the plot.

  • plenv to define the range and scale of the graph, axes, etc. (pllab can be used to set the labels on the graph).

  • One or more calls (can draw more than one curve on the set of axes) to plline or plpoin to draw lines or points.

  • plend, to close the plot.

11

Fill in the Blank

In File I/O, if we would like to open the file “test.dat” for reading and writing, without changing the content and having the initial position at the end, we use the line:


filePtr = fopen(“test.dat”, "___" );

12

Slide image

Flow chart – Open file modes

13

Open Ended

Why is the null check important in this following code? And what is the exact type of errors does it handle?


FILE *filePtr;

filePtr = fopen(“test.dat”, “r”);

if(filePtr == NULL)

__printf(“Error encountered opening file.\n”);

14

NULL Check in File I/O

If there was an error opening the file then fopen returns the NULL address which helps in avoiding Run-time errors.


 E.g.: FILE *filePtr;

  filePtr = fopen(“test.dat”, “r”);

  if(filePtr == NULL)

       printf(“Error encountered opening file.\n”);

15

Poll

Question image

Did you guys have fun reviewing the material?

Yes

No

16

Review

GNG 1106

Slide image

Show answer

Auto Play

Slide 1 / 16

SLIDE