Ask 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.

}

+4
Answers (1)
  1. 23 October, 09:43
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers