C Language

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Introduction to C Language Programming

Language
 Language: Language is the source of
communication between two parties.
 Communication: Exchange/ transfer of
ideas between two parties is called
Communication.
 Computer Language: Computer Language
is the source of communication between
computer and its user.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Types of Computer Language / Language /
Programming Language

 Low Level Language.


 High Level Language.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Low Level Language
 Low Level Language: A computer language
that deals with hardware registers by name
also known as assembly language. A
program written in a low-level language can
be used only on a computer system that
uses one type of main processor low level
language is very near to Processor “or”
Machine it contains on binary numbers like
0,1 that is called low level language.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


High Level Language
 High Level Language: high level language
is very easy to understand become it
contains instructions in English language.
It is a human understandable language “or”
it is very near to the human. High level
language was compiler translate English
instructions into machine language
That is called high level language.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Programming
 Programming is a sequence of steps to
solve specific problem.
 Telling computer what to do.
Capabilities of Software

 User Friendly.
 Think Reusability

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Languages
 FORTRAN
C
 Pascal
 High Level Language
 Assembly Language
 Machine Language
 Hardware

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Translators
 Translators are used to convert source
code into object code.
Types of Translators
 Assembler.
 Interpreter.
 Compiler.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


C - Language
 C – Language is a high level language. C
is a powerful programming language, it
was developed by “Dennis Ritchie” in 1972
at AT & T Bell Laboratory of USA.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


{IDE}
 An Integrated Development Environment (IDE) also
known as Integrated Design Environment or
Integrated Debugging Environment is a software
application that provides comprehensive facilities
to computer programmers for software
development. An IDE normally consists on:
 - a source code editor.
 - a compiler or / an interpreter.
 - Build automation tools.
 - A debugger.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


First Code of C - Language
 #include<stdio.h>
 #include<conio.h>
 void main()
{
 Clrscr();
 Printf(“Islamic IIT”);
 Getch();
}

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Basic Structure of C - Program

 Void main()=>=> void mean one any


argument will be passed and return
function.
 Main()=>=> Main function is the gate of C
Language program. Compiler first of all
compile the program from main function.
All the instructions are must be within
main function.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


{ => Opening Brace.
} => Closing Brace.
 These curly braces are called body of main
function. All the main instructions are must
be written within these braces.
 Clrscr(); => With the Clrscr function
computer will clear the previous Message
of dos screen.
 Printf(); => This function is used to display
Messages and variable values on dos
screen.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Getch();
 It is used to stop the execution of program
until user press any key.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Escape sequences
 Backslash character constant are special
characters used in output functions.
Although they contain two characters they
represent only one character. Given below
is the table of escape sequence and their
meanings.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


List of Escape Sequence
Constant Meanings
‘\a’ Audible Alert (Bell)
‘\b’ Backspace
‘\n’ New Line
‘\r’ Carriage Return
‘\t’ Horizontal tab
‘\” Single Quote
‘\”’ Double Quote
‘\?’ Question Mark
‘\\’ Back Slash
( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]
The Gotoxy Function
 This function is used to move the text
cursor to a different location on dos
screen.
 Syntax: gotoxy(14,20);
printf(“Islamic IIT”);

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Example of Gotoxy Function
 #include<stdio.h>
 #include<conio.h>
 Void main()
{
 Gotoxy(10,4);
 Printf(“This is first line”);
 Getch();
}

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Keyword
 Every word in C are keyword or an
identifier. Keywords in C language con not
be used as a variable name. they are
specificially used by the compiler for its
own purpose and they server as building
blocks of program.

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


List of Keywords
.Auto .else .register .union
.break .enum .return .unsigned
.case .extern .short .void
.char .float .singed .volatile
.const .for .size of .while
.continue .goto .static
.default .if .struct
.do .int .switch
.double .long .typedef
( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]
Variable
 Variables in C are memory locations that
are given names and can be assigned
values. We use variables to store data in
memory for later use. There are 02 basic
kinds of variables in C which are:

 Numeric
 Character

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Numeric Variable
 Numeric variables can either be integer
values or they can be Real values. Integer
values are whole numbers without a
fraction part or decimal point in them. Real
numbers can have a decimal point in them.
 23 (Whole Numbers)
 23.466 (Real Numbers)

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Character Variables
 Character variables are letters of the
alphabet as well as all characters on the
ASCII chart and even the numbers 0-9.
Characters must always be put between
single quotes. A number put between
single quotes in not the same thing as a
number without them.
 ‘I’
 “IIIT”

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Data Types
 Data type is a concept and are used to how much
type of data store in variable.

Short Full Name Format Description


Name Specifier
Int Integer %d Data Type
Char Character %c Data Type
Char Character %s Data Type
Float Float %F Data Type

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Declaring a Variable
 To declare a variable we first put the types
of variable and then give the variable
name.
 int a;

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Rules for Declaring Variables
 1. They must always begin with a letter, although
some systems permit underscore as the first
character.
 2. The length of a variable must not be more
than 8 characters.
 3. White space is not allowed.
 4. A variable should not be a keyword.
 5. it should not contain any special characters.
 Examples of Invalid Variable names are
123 (area)
6th %abc
( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]
OPERATORS
 There are four types of operators which are:

 Arithmetic Operators: +, -, *, /, %.
 Logical Operators: <, >, &, <=, >=, !=, ==.
 Assignment Operators: ++, --, =,+=.
 Bitwise Operators:

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


Types of Instructions
 Declaration Instructions.
 Arithmetic Instructions.
 Control Instructions / Loop / Conditions.
 Comments (un-Executive Instructions).

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]


BEST OF LUCK

( KamranMahar ) [ PaNoAkiLiaNs ] ( WhatsApp ) [ O 3 O 4 1 7 9 7 6 3 3 ]

You might also like