I dont know what to write when im printing out the first number, the is answer always 0.
but from this statement it's clear that you are not printing the first number entered
printf ("the first number you wrote: %i", number[1]);
as number[1]
refers to the second number you entered, try using number[0]
instead of number[1]
printf ("the first number you wrote: %i", number[0]);
apart from the above one, there is one more problem.you are using the wrong format specifier for float
in your scanf()
and printf
statements
use %f
when scanning or printing float
's, %i
is for int
's
generally using wrong format specifiers results in undefined behavior, have a look at this : What can happen if printf is called with a wrong format string?
additionally, try avoiding the use of printf()
an scanf()
and use std::cout
and std::cin
as others have pointed out.