Sie sind auf Seite 1von 18

Vocational crash course on

C with introduction to embedded C

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)

Time table chart


S.No.

Topic

Date

Total Hours
TH (hrs.)

PR(hrs.)

1.

Introduction & Basic Structure

2.

C Fundamentals

3.

I/O Functions

4.

Control statements

5.

Arrays

6.

String handling function

7.

Functions

8.

Structure & Unions

9.

Pointers

10.

Dynamic Memory Allocation

11.

File handling

12.

General Interview Questions

13.

Introduction to Embedded C

40

20

TOTAL (12 days,10th Dec 2014 to 23rd Dec 2014)

Designed & Written


By
Dennis Ritchie
Reliable & Simple to use
Basic Language

Procedural & Structural


Programming

Faster & work in limited


memory

Used in Operating system


&
Device driver programming

Structure, Union &


Exceptional handling are
Its characteristics

Alphabets, Digits & Special Symbol


Constants, Variables & Keywords
Instructions
Writing Program

Alphabets

Digits

Special Symbol

A to Z
a to z

0 to 9

All the other symbols


In you keyboard
~`!@#$%^&*
()_-+={} []\
|;:,./<>?

Variables

C
Constants

Primary

Integer
Real
Character

Secondary

Array
Pointer
Structure
Union
Enum

It is an entity which varies


during program execution.
It denotes the name of
memory location.
Types
Integer
Real
Character
Particular type of variable
can hold same type of
constants.

C Keywords
Inbuilt variables with specific
meaning.
Also known as Reserved
Words

Constant is anInteger
Entity that
doesnt change
Constants
Must Have
Must Not Have
One digit.
The allowable range for
decimal point.
integer constants is commas or blanks.
32768 to 32767.
Real/Floating Constants
Must Have
One digit.
Decimal Point
The allowable range for
Real constants is 4 times
more than Integer

Must Not Have


commas or blanks.

Character Constants

Must Have
Single character, digit or Symbol
Maximum length is 1

Must Not Have


Multiple character
Decimal point

Words whose meaning has already


Keywords
been explained to the C compiler
Cannot be used as variable name.

Basic C Program
Content :
1. C Basic program with output & explanation
2. Steps to write C Program
3. Creation, Compilation & Execution
4. Basic Structure of C Program

Some Basic Commands :


S.No
1.

Command

Explanation

This is a preprocessor command that


includes standard input output header
#include <stdio.h>
file(stdio.h) from the C library before
compiling a C program
Main Modular function where execution of
any C Program begins

2.

int main()

3.

Beginning of the main function

4.

/* comments */

Wont be compiled by compiler

5.

printf(Hello_World!
Prints the information under .
);

6.

getch();

Waits for any character input from keyboard

7.

return 0;

It returns 0(Integer) to compiler

My First Program

This is a preprocessor
command that includes
standard input output
header file(stdio.h) from
the C library before
compiling a C program

#include <stdio.h>
int main()
{
/* Our first simple C basic program */

Main Modular Function

printf(Hello World! );
getch();

Wont be compiled
By compiler (hidden)

return 0;
}

Waits for the


Character input

Prints the information


In between

And for Successful Compilation


Create

Think & Write on Paper before Create


CompilePerform Dry Run then Compile
ExecuteororRun
Run
Execute
Give
inputs for
Getproper
the output
getting desired output
Debug

Documentation section
/* Author : Kumar Anand Singh */

#include <stdio.h> /* Link section */


int total = 0; /* Global declaration and definition section */
int sum (int, int); /* Function declaration section */
int main () /* Main function */
{
printf (This is a C basic program \n);
total = sum (1, 1);
printf (Sum of two numbers : %d \n, total);
return 0;
}
int sum (int a, int b) /* User defined function */
{
/* definition section */
return a + b;
}

Link Section

Definition Section

Global declaration
Function prototype
declaration
Main function
User defined function

Mostly used Inbuilt Functions Under stdio.h


fprintf

Formatted File Write

fscanf

Formatted File Read

printf

Formatted Write

scanf

Formatted Read

fclose

Close File

fopen

Open File

remove

Remove File

rename

Rename File

getc

Read Characters from File

getchar

Read Character

gets

Read String

putc

Write Character to File

putchar

Write Character

puts

Write String

Mostly used Inbuilt Functions Under conio.h

Function

Description

clrscr()

This function is used to clear the output screen.

getch()

It reads character from keyboard

getche()

It reads character from keyboard and echoes to o/p


screen

textcolor()

This function is used to change the text color

textbackgr
ound()

This function is used to change text background

Dont use any function


Before any initialization

Size of memory is
allocated at Run Time

/* Program to Get String, Integer & Character using printf() &


Scanf() function under stdio.h */
which stores 2 byte of Data
#include<stdio.h> Int is a data type
8
1 = 2 , 2 = 216 = 65536 32768 32767
#include<conio.h>
Char is a data type which stores 1 byte of Data
int main()
Stores 19 different characters where 20th
{
character is NULL
int i;
char ch1,ch2;
char str1[20],str2[20];
clrscr();
printf(Enter String Integer & character\t );
scanf(%s %d %c ,str1,&i,&ch1);

getch();
return(0);

&(ampersand) represent address of variable


String self represent address so it doesnt requires
this assignment. str==&str[0]

Das könnte Ihnen auch gefallen