Loops – Arithmetic – Problem #13
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a C Program that reads in a positive integer n, n > 100, and then finds all three digit numbers formed by consecutive digits of n. It then finds the largest prime number among these three digit numbers and prints it. It prints“None is Prime” if no such primes exist. For example, if the number read is 5713271 then the program will print 571, 713, 132, 327, 271 and then say that the largest prime among them is 571. Again if the number read is 668844 then it prints 668, 688, 884, 844 and then prints “None is Prime” Save the file as A06_<Roll Number>.c (example A06_21AG10002.c). Build, Run for and test it for the given 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 an integer n. (Assume a valid input will be given.) Print it. Create a new line after the print statement. 2. Print all three digit numbers of n as required above, one after another, in the same line, each number followed bya comma. After that, when all are printed, make a new line. 3. Print the largest primes number among these three digit numbers or state “None is Prime”. (Write the code for checking for primes in the main program itself and do not write a separate function for detection of primes) Test Data: a) 5713271 b) 6688441 c) 1122335