Variables
Variable is the name of a memory
location which stores some data.
Memory
a b
25 S
Variables
Rules
a. Variables are case sensitive
b. 1st character is alphabet or '_'
c. no comma/blank space
d. No other symbol other than '_'
Variables
Data Types
Constants
Values that don't change(fixed)
Types
Integer Character
Constants Real Constants
1, 2, 3, 0
Constants 'a', 'b', 'A',
, -1, -2 1.0, 2.0, '#', '&'
3.14, -24
Keywords
Reserved words that have special
meaning to the compiler
32 Keywords in C
Keywords
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
Program Structure
#include<stdio.h>
int main() {
printf("Hello World");
return 0;
}
Comments
Lines that are not part of program
Single Line Multiple
Line
/*
//
*/
Output
printf(" Hello World ");
new line
printf(" kuch bhi \n");
Output
CASES
1. integers
printf(" age is %d ", age);
2. real numbers
printf(" value of pi is %f ", pi);
3. characters
printf(" star looks like this %c ", star);
Input
scanf(" %d ", &age);
Compilation
A computer program that translates C code
into machine code
a.exe (windows)
Hello.c C Compiler
a.out (linux & mac)