Array and Strings – Strings – Problem #3

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

Difficulty: medium

Problem Statement

1. Two distinct numbers are said to be sum of digit preserving pair, if the sum of sum of their digits is the same as the sum of digits of their sum. Example 1: 13 and 14 form a sum of digit preserving pair since sum of sum of the digits is (1+3) + (1+4)=9 and sum of digits of their sum 27 is also 2+7=9. Example 2: 13 and 18 do not form a sum of digit preserving pair since sum of sum of the digits is (1+3) + (1+8)= 13 and sum of digits of their sum 31 is 3+1=4. Write a C program that displays all sum of digit preserving pairs between 13 and 23 (both included). Also display the total number of sum of digit preserving pairs between 13 and 23 (both included). Example display: Sum of digits of 13 and 14 equals sum of digits of 27 Sum of digits of 13 and 15 equals sum of digits of 28 ** Note 1: If you have printed 13 and 14, you should not print 14 and 13 again. Note 2: The program does not take any input from the user

Back to Lab Problems
Array and Strings/Strings/Problem #3

Lab Problem Statement

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

Interactive C Compiler · Problem #3

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.