Ask Question
11 October, 10:42

How I get input from the user in C? Here's my code now:

int main (void)

{

int number;

/ / How to read in a number here.

}

+3
Answers (1)
  1. 11 October, 10:59
    0
    You must use "scanf" statement to read the input. You must also include the necessary header file to use all the built-in functions in any programming languages.

    scanf ("%d", &number);

    Since "scanf" is a statement it must end with the semicolon. "scanf" accepts two parameters, first the type of value and second is the address of the variable to store the given input.

    Here "&" represents the address of the given variable. "%d" is used for integer, "%f" is used for float, "%s" is used to receive string inputs, etc.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How I get input from the user in C? Here's my code now: int main (void) { int number; / / How to read in a number here. } ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers