Professional Documents
Culture Documents
variable
Memory
NESO ACADEMY
DECLARATION
Declaration:announcingthe properties of
variable tothe compiler
Properties:
NESO ACADEMY
DEFINITION
NESO ACADEMY
int var;
Name of variable
NESO ACADEMY
INITIALIZATION
int var = 3;
NESO ACADEMY
Variable :
vary- able
NESO ACADEMY
initialization.c- Code-Blocks 16.01
File Edit View Search Project Build Debug Fortran wSmith Tools Tools Plugins DoxyBlocks Settings Help
Management
Start here xinitialization.c
x
Projects Symbols
#include <stdio. h>
CUsers\jaspr\ Downloads\C programs of dennis ritchie\initialization.exe"
OWorkspace
3 int main () 4
4 Process returned e (exe) execution time : e.5es s
5 int var 3: Press any key to continue.
6 var,, 4:
7 pritf("$d", var):
return 0;
10
File L...Message
= Build
Build
file:
finished:
"no targe
0 err
initialization.c - Code:-Blocks 16.01
File Edit View Search Project Build Debug Fortran wSmith Tools Tools+ Plugins DoxyBlocks Settings Help
Management
Start here initialization.c x
Projects Symbols
#include <stdio.h>
O Workspace 2
3 int main ()
CUsers\jaspr\ Downloads\C programs of dennis ritchie\initialization.exe"
4
5 int varl 3:
6 int var2: Press returned e (exe) execution time : e.569 s
var2 varl; - Press any key to continue.
8 printf ("&d", var2) :
9 return 0;
10
11
File Edit View Search Project Build Debug Fortran wSmith ools Toolst Plugins DoxyBlocks Settings Help
Management
Start here initialization.c x
Projects Symbols
4include <stdio.h>
OWorkspace 2
3 int main () CAUsers\jasp\Downloads\C programs of dennis ritchie
444
int varl, var2, var3: Rpcess returned e
(ex0) execution time :€
varl = var2 = var3 4: = Press any key to continue.
printf ("$d",varl)
printf ("%d",var2) ;
printf ("%d",var3) ;
10 return
0;
11
12
PROGRAMMING AND
(DATASTRUCTURES
Naming conventions of
variables
Variable name: composed of letters or combination
of letters (both upercase and lowercase) and digits.
Rule #1: don't start variable name with digit.
globe 2globe
X
Rule #2:begining with underscore is valid but not
recommended.
Are they
together ?
int my variable
Compiler
Rule #5: Blanks or white spaces not allowed.
int my_variable
Rule #5:Blanks or white spaces not allowed.
They are
together
int my_variable
Compiler
Rule #6: Don't use keywords to name your variables.
PROGRAMMING AND
DATA STRUCTURES
Basic output function -printf.
NESOACADEMY
FILL IN THE BOX
int Switch
369
int
@go while
Switch
NESO ACADEMY
RECALL THESE CODE SNIPPETS
NESO ACADEMY
RECALL THESE CODE SNIPPETS
NESO ACADEMY
View Search Project Buld Debug Fortran wmith Tools Tocls+ Plugins DosyBiods Settings Help
xprintf.c X
include <stdio.h>
int main ()
printf ("I am new to programming but I know how to write aríthmetic expressions like this: (%d + td) * td / td ", two, three, six, three) :
printf ("and the result of this expression is: td", result)
I am new to programming but I know how to write arithmetic expressions like this: (2 + 3)6/3 and the result of this expression is: 1e
Process returned e (exe) execution time : 1.356 s
Press any key to continue.
Blocks x
ACADEMY
C
PROGRAMMING AND
(DATA|STRUCTURES
Fundamental Data Types
-
(part 1) integer
NESO ACADEMY
SIZE OF INTEGER
NESO ACADEMY
WANNA KNOW SIZE PROGRAMMATICALLY?
#include <stdio.h>
Note: sizeof is a unary operator
and not a function.
int main()
{
printf("%d", sizeof (int)); Output:
return 0;
Range: 0 to 4
NESO ACADEMY
PREREQUISITES
10 10 10
S 6 8
NESO ACADEMY
PREREQUISITES
Range: 0 to 1
3 2 1
222 2
110 0
3 2 1
2x 1 + 2 x 1 + 2x 0 +2 x 0 = 8 + 4 +0 + 0 =12
NESO ACADEMY
RANGE OF 4 BIT DATA?
3 2 1
22 2 2
4 bit data: Minimum Value =O
Formula. 2 - 1
NESO ACADEMY
RANGE OF INTEGER
n
2 bytes
[16 bits]
2's complement range: -(2
n-1
) to +(2
n-1
- )
n
4 bytes
[32 bits]
NESO ACADEMY