Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Variables | Data
C Basics

bookVariables

Before you can use a variable in C, you need to declare it. Declaring a variable means telling the compiler what kind of data the variable will hold (its type) and giving it a name (its identifier). The general syntax for declaring a variable is:

<data_type> <variable_name>;
main.c

main.c

copy
1234567891011
#include <stdio.h> int main() { // Store distance using an integer int distance = 12; // Store direction using a character char direction = 'R'; return 0; }
Note
Note

When initializing a char type variable, make sure to use single quotes.

With the data stored in these variables, you can use them in different ways. One option is to display them on the screen, or you can process them further in calculations.

question mark

Now, can you select the correct way to initialize a character-type variable?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 2

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

Can you give examples of variable declarations in C?

What are the common data types used for variables in C?

How do I display the value of a variable in C?

Awesome!

Completion rate improved to 2.63

bookVariables

Veeg om het menu te tonen

Before you can use a variable in C, you need to declare it. Declaring a variable means telling the compiler what kind of data the variable will hold (its type) and giving it a name (its identifier). The general syntax for declaring a variable is:

<data_type> <variable_name>;
main.c

main.c

copy
1234567891011
#include <stdio.h> int main() { // Store distance using an integer int distance = 12; // Store direction using a character char direction = 'R'; return 0; }
Note
Note

When initializing a char type variable, make sure to use single quotes.

With the data stored in these variables, you can use them in different ways. One option is to display them on the screen, or you can process them further in calculations.

question mark

Now, can you select the correct way to initialize a character-type variable?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 2
some-alt