How to make a program that output the position of an integer when you input the position using C language? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make a program that output the position of an integer when you input the position using C language?

Example output: Input any number: 12345 Input position: 3 Answer is: 3

26th Nov 2018, 11:12 AM
Dan Mark Imus
Dan Mark Imus - avatar
1 Answer
0
hmm represent them as an array of digits like arr = [1, 2, 3, 4, 5] ... then if you get an input position n = 3, print arr[n-1] Use modulo(%) and division(/) operators to get the digits from the number.
26th Nov 2018, 11:16 AM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar