Structures and Pointers – Arithmetic – Problem #1

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: hard

Problem Statement

You will read in positive integers m and n. Then you will dynamically allocate two strings A and B of sizes m and n, respectively. You will read the two strings A and B, each having lower case alphabets only. You will write three separate functions to find the following: The number of unique characters in their union, intersection, difference. These functions will be called for A and B, and the results returned to the main program, from where they will be printed neatly in a suitably understandable form. Once this is done, you will write another set of three functions to return the respective strings of their union, intersection and difference. For this you will dynamically declare the character arrays of the results based on the sizes of m and n. These functions will be called for A and B and the results returned to the main program. These returned results will be printed neatly in a suitably understandable form in the main program. Save the file as A14_<Roll Number>.c (example A14_21AG10002.c). Build, Run and Test it for the given data as well as your own data. Then upload the .c file for the Assignment. [20 Marks: 5 marks for intermediate submission, 15 marks for final submission] In particular, you will do the following: 1. Read positive integers m and n and dynamically allocate strings A and B of sizes m and n. Take as input strings A and B and print them. Assume valid inputs will be provided. 2. Write functions to find the number of unique letters in union, intersection and difference of two strings and return the same. Call these in the main program for the various combinations of A and B, as respective arguments and print the results suitably from the main program. 3. Write functions to find the actual unique letters in the union, intersection and difference of two strings and return the same as a string pointer. Dynamically allocate the resulting string at the places needed, so that the result can be sent and received through the function calls. Call these functions in the main program for the various combinations of A and B and print the results suitably from the main program. [Do not call any Library Functions other than scanf, printf. You may use your own user defined functions. They may be nonrecursive or recursive, as per your choice] Test Data: Test it with your own data for various cases.

Back to Lab Problems
Structures and Pointers/Arithmetic/Problem #1

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #1

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.