COM1002-COMPUTER PROGRAMMING 2 (Solution)

$ 20.99
Category:

Description

LAB7 Quiz
Assoc. Prof. Dr. Hacer Yalım Keleş

DuraRon: 90 minutes

Write a program that reads a set of dic1onary words and their scores from the standart input and stops reading a6er it reads “END” keyword. What you will then do is to read the following query strings (one or more) un#l the EOF and print the scores associated with the query strings if it is included in the dic1onary.
Look at the example to understand beEer.
For example: Assume that the input is given as:
> book 30 pencil 20 desk 80 END pencil ball desk cup
* You will search the query strings: {“pencil”, “ball”, “desk”, “cup”} within your dic1onary. When you find them in your dic1onary (with an exact match), print the corresponding score of that item. Then you will print a newline (‘ ’).
* You will not print anything for a query string if the query string is not in your dic1onary.
The output will be: >pencil 20 desk 80
Input Format:
{<word>[white-space]<score>[white-space]}1 or more END [white-space]{<query-string>}1 or more
Output Format:
{<word>[SPACE]<score>[NEWLINE]}1 or more
*You can assume that the number of words in your dic1onay (reference word list) will not exceed 20. The words (strings) will not exceed 30 characters.
*You can use <string.h> library func1ons if you like.
Hint:
Reading un1l the EOF:
while(scanf(..) != EOF)
{
// do something here
}
Test your program using input redirec1on! Prepare an input file to test your program and run it as follows, assuming that your executable is named as lab7:
>./lab7<input1.txt
Submission: Your source code will be named using your student ID: <student-id>.c Ex: if your id is 1123456 than you should name your source code like this: 1123456.c
Please test your program thoroughly before submission.
Good luck ☺

Reviews

There are no reviews yet.

Be the first to review “COM1002-COMPUTER PROGRAMMING 2 (Solution)”

Your email address will not be published. Required fields are marked *