Syntax

C Read Input Syntax

In C, read input: reads formatted input — scanf("%d", &n);

Quick Answer

Syntax
scanf("%d", &n);
CSyntax

Read Input

Code example
scanf("%d", &n);

Reads formatted input.

Learn More

How to read input in C

  1. Open your C file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C Read Input Syntax

Use scanf("%d", &n);.

Related Syntax References

Frequently asked questions

What is the C syntax for read input?

Use this pattern: scanf("%d", &n);

Can I copy this C code example?

Yes. Use Copy code and adapt the example to your program.

Is this C syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify