Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Variables and Keywords in C
Variables
In C language, variables are the storage place where some form of data is stored. Different variables require different amount of memory on which a set of operations is applied.
A variable name cannot start with a number. It can consist of alphabets, number, underscore “_”.
Here is the syntax of declaring variables in C language,
type variable_name;
Here is the syntax of multiple variables declaration in C language,
type variable_name1, variable_name2,variable_name3;
The following is an example of variables in C language,
Example
#include <stdio.h>
int main() {
char a1 = 'H';
int b = 90, c = 150;
float _d = 3.4;
printf("Character value : %c
",a1);
printf("Integer value : %d\t%d
",b,c);
printf("Float value : %f",_d);
return 0;
}
Output
Character value : H Integer value : 90150 Float value : 3.400000
Keywords
Keywords are predefined, reserved words in C language and each of which is associated with specific features. These words help us to use the functionality of C language. They have special meaning to the compilers.
There are total 32 keywords in C.
| auto | double | int | struct |
| break | else | long | switch |
| case | enum | register | typedef |
| char | extern | return | union |
| continue | for | signed | void |
| do | if | static | while |
| default | goto | sizeof | volatile |
| const | float | short | unsigned |
Here is an example of keywords in C language,
Example
#include <stdio.h>
int main() {
// char, int and float are keywords and used as datatypes
char c = 'H';
int b = 6, c;
float _d = 7.6;
// if and else is a keyword checking the value of b
if(b<5)
printf("Character Value : %c",a1);
else
printf("Float value : %f",_d);
return 0;
}
Output
Float value : 7.600000
Advertisements