I made a simple program:

#include <stdio.h>

int main()
{
    printf("Please enter a value: ");
    int uservalue;
    scanf("%d", &uservalue);
    printf("The value entered was: %d", uservalue);
    return 0;
}

As you probably already know, this program has many faults. The ones I found are:
1) The program malfunctions weirdly if the user does not enter a number.
2) Large numbers, like 1000000000, are stored as negative numbers.

Why are these problems occurring and how can I overcome them?

Thanks for any suggestions,
popcorn99

1) The program malfunctions weirdly if the user does not enter a number.

its because scanf() is expecting u to enter some integer numbers.
If u want it to work for any input then better take your input as string, validate it and get its' integer value to your variable.

2) Large numbers, like 1000000000, are stored as negative numbers.

it's because u are storing a number greater than the capacity and by default the int data type is signed int hence the most significant bit is the sign bit and the number u are trying to store have that bit as 1 which says its a negative number.
If u want larger numbers u can use unsigned long datatype.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.