Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Course instructor :
Prof. Kumar Anand Singh
(Asst. Professor, EC, MEFGI)
Course assistances:
Prof. Hetal Dave
(Asst. Professor, EC, MEFGI)
Mr. Saumil Vora
(Student, PG-VLSI, 1st year)
Topic
Date
Total Hours
TH (hrs.)
PR(hrs.)
1.
Introduction
0.5
2.
C Fundamentals
3..
I/O Functions
4..
Control statements
5.
Arrays
6.
7.
Functions
8.
9.
Pointers
10.
11.
File handling
12.
13.
Introduction to Embedded C
40
20
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Identifiers :
float 7g;
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Keywords :
Keywords are standard identifiers that have standard predefined
meaning in C.
Uppercase & Lower case character have different meaning in C.
void
char
int
float
double
signed
unsigned
short
long
auto
static
register
const
struct
union
if
else
goto
for
continue
switch
case
break
default
do
while
sizeof
volatile
enum
extern
typedef
return
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
1.
2.
3.
4.
Character (char)
Integer (int)
Floating point (float)
Double Floating point (double)
Memory requirements :
Data Type
Meaning
Size (byte)
Minimal Range
char
Character
-128 to +127
int
Integer
-32768 to
+32767
float
Single Precision
real no.
3.4E-38 to
3.4E+38
double
Double Precision
real no.
1.7E-308 to
1.7E+308
void
No Data
-------
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Constants
The term constant means that it does not change during the execution of
program.
Constant and is the data with a constant value that does not change in the
program.
Four basic types of constants in C :
1. Integer Constants
2. Floating point Constants
3. Character Constants
4. String Constants
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Variables :
Variables are means for location in memory used by a program to
store data.
The size of that block depends upon the range over which the
variable is allowed to vary.
The format for declaring a variable in C.
[Storage-class] type data variable name [= initial value];
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Expressions :
An expression is a sequence of operators and operands that specifies
computation of a value.
An expression may consist of single entity or some combination of such
entities interconnected by one or more operators.
All expression represents a logical connection that's either true or false.
Ex :
A+b
3.14*r*r
a*a+2*a*b+b*b
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Statements :
The statements of a C program control the flow of program execution.
if statement
switch statement
goto statement
for statement
while statement
do-while statement
break statement
continue statement
expression statement
compound statement
return statement
null statement
if statement
Switch Statement :
Multiple if statement.
It is an error-prone
statement.
#include<stdio.h>
#include<conio.h>
goto statement:
The goto statement is used to
alter the normal sequence of
program execution by
transferring control to some
other part of the program
unconditionally.
void main()
{
clrscr();
printf(Marwadi );
goto x;
y:
printf(Foundation);
goto z;
x:
printf(Education);
goto y;
z:
printf(Group of Institution);
getch();
}
for loop
Most general looping construct
loop header contains three parts:
initialization
continuation condition
increment/decrement
Syntax:
for (initialization, condition, step)
{
Statement 1;
Statement 2;
...
Statement n;
}
while loop
Another looping construct
It evaluates the test expression
before every loop.
it can execute zero times if the
condition is initially false.
Syntax:
while (expression)
{
Statement 1;
Statement 2;
...
Statement n;
}
do while loop
Loop condition is tested at the end
of the body of the loop.
loop is executed at least one.
unpopular loop statement.
do
Statement 1;
Statement 2;
...
Statement n;
while(expression);
break statement
It is a jump instruction.
used inside a switch construct,
for loop, while loop and do-while
loop.
break statement causes immediate
exit from the concern construct.
continue statement
It is a jump instruction.
used inside a switch construct,
for loop, while loop and do-while
loop.
Execution of these statement does not
cause an exit from the loop but it
suspend the execution of the loop for
that iteration and transfer control back
to the loop for the next iteration.
A=10;
A+=20;
printf("Hello, Good
morning!\n");
display(a,b);
c=a+b;
;
Expression statements
It consists of an expression followed
by a semicolon.
The execution of an expression
causes the expression to be evaluated.
/*null statement*/
Compound statements
A compound statement (also called a "block").
It appears as the body of another statement.
Used in if statement, for statement, while statement,
etc.
Syntax :
{
pi=3.14;
area=pi*radius*radius;
}
Return statement
A function may or may not return a
value.
A return statement returns a value
to the calling function and assigns
to the variable in the left side of the
calling function.
If a function does not return a value,
the return type in the function
definition and declaration is
specified as void.
Null statement
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
#include<stdio.h>
#include<conio.h>
#define TRUE 1
#define PI 3.141593
void main()
{
float a; float b; float c;
float d=PI;
clrscr();
if(TRUE)
{
a=100;
b=a*10;
c=b-a;
}
printf("\na=%f\nb=%f\nc=%f\nPI=%f",
a,b,c,d);
getch(); }
C Fundamentals
Identifiers
Keywords
Data Types
Constants
Variables
Expressions
Statements
Symbolic Constants
Operators
Comments
Operators
It is an is a symbol that operates on a certain data type.
commonly used operators are :
Arithmetic operator
Relational operator
Logical operator
Assignment operator
Conditional operator
Comma operator
Unary operator
Bitwise operator