How to declare char, initialize and display char variable in C (Hands-on) | Declare Character in C

preview_player
Показать описание
In this video, you will learn how to declare a character variable in C. By the end of this video, you should be able to declare a character (char) variable, initialize a char variable with a value, and display it on the screen using printf statement in your C program.

Here is the syntax to declare a variable in C:
data-type variable_name;

If you want to declare a variable named "size" having data-type char, you can do that by typing:
char size;

In order to initialize a variable, here is the syntax:
variable_name = value;

If you want to assign value L to char variable size, you can write the below statement in C:
size = 'L';

Use "%c" format specifier to display value of char variable "size" as follow:
printf("%c", size);

#aptuts #DeclareCharacterVariableInC #CharVariableInC
Рекомендации по теме
Комментарии
Автор

Very useful information .. thanks alot

youssefhany
Автор

can you scanf and assign a new character to a character?

WilsonSum
Автор

There is also an error while declearing multi character variables

singduniyaOfficial