Functions and Recursions – Algebra – Problem #2

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

Difficulty: medium

Problem Statement

Part-I Submit one (single) C program. Write a C program to perform the following tasks. 1. Take as input 2 positive integers a and b. 2. Write a function digits(. . .) that takes as input a positive integer and returns the number of digits in that integer. 3. Consider a positive integer of at least 3 digits. Let S be the set of digits appearing in the number, in the number multiplied by 2 and the number multiplied by 3. Suppose in S the digits from 1-9 appear exactly once while 0s may appear multiple times. Then such a number is called a Fascinating number. Eg: 192 x 1 = 192, 192 x 2 = 384, 192 x 3 = 576. S = 1,9,2,3,8,4,5,7,6. Therefore, 192 is a Fascinating number. Similarly, 1920 is also a fascinating number. Write a function isFascinating(. . .) that takes as input a positive integer and returns true if it is a Fascinating number, false otherwise. 4. A positive integer of n digits is called an Armstrong number if the sum of the n-th power of each digit adds up to the number itself. Eg: 153 is a 3 digit number; 153 = 13 + 53 + 33 Write a function isArmstrong(. . .) that takes as input a positive integer and returns true if it is an Armstrong number, false otherwise 5. For each integer in the range [p, q], print whether it is a Fascinating number and/or an Armstrong number, or neither.

Back to Lab Problems
Functions and Recursions/Algebra/Problem #2

Lab Problem Statement

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

Interactive C Compiler · Problem #2

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.