Array and Strings – Algebra – Problem #9

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

Difficulty: hard

Problem Statement

Write a C Program to read in n (assume 0 < n <=20) positive integers and then find out all non-duplicate pairs whose sum of odd valued digits have a difference between 5 and 20 but that difference is not divisible by 3. For example, if n = 4 and the numbers are 3456, 1237, 8888, 77777, then the sum of odd valued digits are 8 (for3456), 11 (for 1237), 0 (for 8888) and 35 (for 77777) and the pairs are (3456, 8888) and (1237, 8888). The otherpairs do not satisfy the condition. [You may print the pairs in any order]. Save the file as A07_<Roll Number>.c (example A07_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 in a positive integer n (0 < n <= 20) and print it. Create a new line. 2. Read in n positive integers and store them in an array. Print them in a single line followed by commas. Then create a new line. 3. Store the sum of odd-valued digits of every number in a separate array. Print each number along with the sum of odd digits of that number appropriately. 4. Print all pairs of numbers whose sum of odd valued digits have a difference between 5 and 20 but that difference is not divisible by 3. Do not print duplicate pairs. If there is no such pair, print “No Such Pair” Test Data: a) n = 5, numbers are 3456, 1237, 8888, 77777, 7321 b) n = 5, numbers are 11111, 23456, 1134, 99999, 77777 c) n = 4, numbers are 351, 531, 1345, 68153

Back to Lab Problems
Array and Strings/Algebra/Problem #9

Lab Problem Statement

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

Interactive C Compiler · Problem #9

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.