Array and Strings – Arithmetic – Problem #5

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

Difficulty: medium

Problem Statement

Write a program that reads a scale factor s (S is a number between 1 and 8) and number of lines n (n is a number between I and 10). Based on the scale factor, it will display the digits between 1 to (3+s) repeatedly with (2+s) digits in each line. The remaining digits will be printed at the start of the next line and this will continue. A total of n lines will be printed. Explanation: If s=1 and n=6, we have to repeatedly print the digits between 1 to (3+1), i.e., the digits 1, 2, 3 and 4. In each line, (2+1), 1.e., only 3 digits will be printed. The remaining digits will be printed at the start of the next line. A total of 6 lines will be printed since n=6. Example 1: Input Enter scale factor: 1 Enter number of lines: 6 Output 123 412 341 234 412 Example 2: Input Enter scale factor: 2 Enter number of lines: 5 Output 1234 5123 4512 3451 2345 Example 3: Input Enter scale factor: 3 Enter number of lines: 3 Output 12345 61234 56123

Back to Lab Problems
Array and Strings/Arithmetic/Problem #5

Lab Problem Statement

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

Interactive C Compiler · Problem #5

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.