You don't have to save a copy of the value if you don't want to.
Because of the way you are using incValue, I'm guessing that you don't want to return the value of "val".
Also, you can use getNumber to initialise your "number" variable.
You should also consider what you want done for the inputs 1 and 101 - Did you want to use ">=" instead of ">"? I've offered and alternative way of checking the input numbers.
When looking at your code I've also added a fflush after your printf, because you don't end it with \n.
Another thing I added is a little error checking on scanf - It returns the amount of successful conversions. This is just in case the user accidently types something else by accident. You could also check things like input range/positive inputs/...
I've used EXIT_SUCCESS as defined in stdlib.h - It just looks neater.
10, 20, and 25 are "magic numbers" - So I've made a define that gives it some meaning... You'll need to come up with names that actually say why those numbers are there.
Code:
#include <stdio.h>
#include <stdlib.h>
#define LT_100_INCVALUE 10
#define LT_1000_INCVALUE 20
#define DEFAULT_INCVALUE 25
int getNumber(void)
{
int input = 0, iResult = 0;
do
{
printf("Enter an integer number:");
// Added because the printf doesn't end with \n
// See: https://cboard.cprogramming.com/c-programming/98138-fflush-stdout.html#post708567
fflush(stdout);
iResult = scanf("%d", &input);
if (iResult != 1)
{
puts("*** Error: Could not read number ***");
//Try to get all the bad inputs off stdin
//See https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392
int ch;
while ((ch = getchar())!='\n' && ch!=EOF)
continue;
}
}
while (iResult != 1);
return input;
}
void incValue(int *val)
{
if ( *val < 1)
{
// 0 and under...
// Anything required here?
// Are you letting the input be 0 or negative?
}
else if( *val < 100 )
{
*val += LT_100_INCVALUE;
}
else if (*val < 1000)
{
*val += LT_1000_INCVALUE;
}
else
{
*val += DEFAULT_INCVALUE;
}
}
void doubleValue(int *val)
{
*val *= 2;
}
// FAQ on void/main
// https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044841143&id=1043284376
int main(void)
{
int number = getNumber();
doubleValue(&number);
printf("That value doubled is %d\n", number);
incValue(&number);
printf("That value incremented is %d\n", number);
return EXIT_SUCCESS;
}