Write a C code to read one integer (M) followed by another two integers (i, j). Display the ith through the jth digits of M. For example if the input is 1234567 1 4 Display digits 1 through for of the integer 1298567 Integer 1 29 8 5 6 7 Digit number 6 5 4 3 2 1 0 So you must display digits 1 through 4, i.e. display 9856 Hint:

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.3: Nested If Statements
Problem 7E
icon
Related questions
Question
Write a C code to read one integer (M) followed by another two integers (i, j).
Display the ith through the jth digits of M.
For example if the input is
1234567 1 4
Display digits 1 through for of the integer 1298567
Integer
1 29 8 5 6 7
Digit
number
6 5 4 3 2 1 0
So you must display digits 1 through 4, i.e. display 9856
Hint:
Read as integer, not string
Use a combination of integer division and mod to get the result
For example in the above case first you divide the number by 10%, in that case x=1
to get 129856
Then get the number above (129856) mod 10% (y = 4) you get 9856
Your job is to calculate what should be the value of x and y and their relation to i and j;
use a loop that multiply by 10 to get the power of 10 you need.
Transcribed Image Text:Write a C code to read one integer (M) followed by another two integers (i, j). Display the ith through the jth digits of M. For example if the input is 1234567 1 4 Display digits 1 through for of the integer 1298567 Integer 1 29 8 5 6 7 Digit number 6 5 4 3 2 1 0 So you must display digits 1 through 4, i.e. display 9856 Hint: Read as integer, not string Use a combination of integer division and mod to get the result For example in the above case first you divide the number by 10%, in that case x=1 to get 129856 Then get the number above (129856) mod 10% (y = 4) you get 9856 Your job is to calculate what should be the value of x and y and their relation to i and j; use a loop that multiply by 10 to get the power of 10 you need.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning