Lesson 6: Input/Output Statements in C

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/51

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:11 PM on 7/22/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

52 Terms

1
New cards

What does I/O mean in C programming?

I/O stands for Input/Output, which is the process of reading (input) and writing (output) data in a program.

2
New cards

Which header file contains C input/output functions?

<stdio.h> (standard input/output header file).

3
New cards

What are the two main classifications of I/O functions in C?

Unformatted I/O functions and Formatted I/O functions.

4
New cards

What are the six unformatted I/O functions?

getchar(), putchar(), gets(), puts(), getch(), getche().

5
New cards

What does getchar() do?

Reads a single character from the keyboard (buffered, requires Enter).

6
New cards

What does putchar() do?

Displays a single character on the screen.

7
New cards

What does gets() do?

Reads a string (until Enter is pressed) and adds a null character \0 at the end.

8
New cards

What does puts() do?

Outputs a string or text message, automatically appending a newline.

9
New cards

How does getch() differ from getchar()?

getch() reads a single character without waiting for Enter (non-buffered).

10
New cards

What is the difference between getch() and getche()?

Both are non-buffered, but getche() echoes (displays) the character on screen while getch() does not.

11
New cards

What are the two formatted I/O functions?

scanf() (input) and printf() (output).

12
New cards

How is scanf() used?

scanf("control string", &var1, &var2, …);

13
New cards

What does the & symbol mean in scanf()?

It passes the address of the variable so input can be stored there.

14
New cards

What are some common format specifiers for scanf()?

  • %c → character

  • %d → integer

  • %f → float

  • %lf → double

  • %s → string

  • %x → hexadecimal

  • %o → octal

15
New cards

%c

character

16
New cards

%d

integer

17
New cards

%f

float

18
New cards

%lf

double

19
New cards

%s

string

20
New cards

%x

hexadecimal

21
New cards

%o

octal

22
New cards

How is printf() used?

printf("control string", var1, var2, …);

23
New cards

What are some common format specifiers for printf()?

  • %c → character

  • %s → string

  • %d → integer

  • %f → float

  • %lf → double

  • %x → hexadecimal

  • %o → octal

24
New cards

%c

character

25
New cards

%s

string

26
New cards

%d

integer

27
New cards

%f

float

28
New cards

%lf

double

29
New cards

%x

hexadecimal

30
New cards

%o

octal

31
New cards

Which I/O functions are used for strings in unformatted I/O?

gets() and puts().

32
New cards

Which I/O functions are used for single characters?

getchar(), putchar(), getch(), getche().

33
New cards

Which I/O functions allow formatted input/output with multiple data types?

scanf() and printf().

34
New cards

What’s the main difference between unformatted and formatted I/O?

  • Unformatted I/O → handles raw character/string input/output.

  • Formatted I/O → allows structured input/output with format specifiers.

35
New cards

What does I/O mean in C programming?

Input/Output — reading (input) and writing (output) data in a program.

36
New cards

Which header file is required for I/O in C?

#include <stdio.h>

37
New cards

What are the two main classifications of I/O functions?

Unformatted I/O and Formatted I/O.

38
New cards

What is the syntax of getchar()?

char c;
c = getchar();

Reads a single character from the keyboard (buffered, requires Enter).

39
New cards

What is the syntax of putchar()?

char c = 'A';
putchar(c);

Displays a single character on the screen.

40
New cards

What is the syntax of gets()?

char str[20];
gets(str);

Reads a string (until Enter is pressed). Appends \0 at the end.

41
New cards

What is the syntax of puts()?

puts("Hello");
puts(str);

Outputs a string or text message and automatically adds a newline.

42
New cards

What is the syntax of getch()?

char c;
c = getch();

Reads a single character (non-buffered, no Enter needed). Character is not displayed.

43
New cards
44
New cards

What is the syntax of getche()?

char c;
c = getche();

Reads a single character (non-buffered) and echoes it on the screen.

45
New cards

What is the syntax of scanf()?

scanf("format_specifiers", &var1, &var2, ...);

Reads input in a specific format.

46
New cards

Example of scanf

int age;
float gpa;
scanf("%d %f", &age, &gpa);

47
New cards

What is the syntax of printf()?

printf("format_specifiers", var1, var2, ...);

Displays output in a formatted way.

48
New cards

Example of printf

int age = 20;
float gpa = 1.75;
printf("Age: %d, GPA: %.2f", age, gpa);

49
New cards

Unformatted Input

getchar(), gets(), getch(), getche()

50
New cards

Unformatted Output

putchar(), puts()

51
New cards

Formatted Input

scanf()

52
New cards

Formatted Output

printf()