1 / 7

Sample Theoretical Question

Sample Theoretical Question. What’s printed on the screen when the following programs are run? printing.c change_val.c And what does this function do? secret.c. Parentheses checking. Implement a function such that – Input – A string s that contains (among other things) parentheses

calla
Télécharger la présentation

Sample Theoretical Question

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sample Theoretical Question • What’s printed on the screen when the following programs are run? • printing.c • change_val.c • And what does this function do? • secret.c

  2. Parentheses checking • Implement a function such that – • Input – A string s that contains (among other things) parentheses • Output – 1 if the parentheses’ nesting is legal, 0 otherwise • For example – (()())() is legal, while ())() and (()(()) are not. • Write a program that accepts a string from the user and checks etc’.

  3. Dynamic structures • Write a structure of a point in 2-D space and a distance function between two points • Write a program that gets an array of points from the user and calculates the largest distance between a pair of points in the array • The size of the array is given by the user before the points are read in • Solution – max_distance.c

  4. Split list • Implement a linked list where each item simply contains an integer • Input a number n from the user, and split the original list into two lists such that the first contains all the elements smaller than n, and the other contains all the others • Display both linked lists on the screen

  5. String alignment • Implement a function such that – • Input – two strings, s1 and s2 • Output – 1 if s2 is a substring-with-insertions of s1 • For example, if s1 = “abcde” and s2 = “abe”, then the function should return 1 • Solution – string_align.c

  6. Printing maximum 20 • Write a program that accepts integers from the user until a -1 is entered • The program then prints the maximum 20 numbers • Not necessarily sorted! • Solution – maximum_20.c

  7. Printing maximum n • Change the previous program so that the first number the user enters is the number of numbers she wants printed • So if the first number is 5, the top 5 numbers will be printed • Solution – maximum_n.c

More Related