You are on page 1of 91

C LANGUAGE SYLLABUS

1)Introduction to C
2)Data types
3)Operators
4)Escape sequences
5)II condition
6)For loop
7)While
8)Do Whe
9)goto
10) Breaks**
11) Continue**
12)Gotoxy Concept*
12) Switch**
13) Array
14) String Iunction**
15) Pointer
16) Function
17) Input Output Function
18) File
19) Structure
20) Scope variable declaration
C LANGUAGE
1
What is program?
A program is set oI instruction or commands used to solve any task or problem`s
program is stored in Iile.
Introduction oI C language:
1) C is a structure programming language
2) "C" seems a strange name Ior a programming language was an oIIspring oI
Basic Combined Programming Language. (BCPL) called B.
3) Developed in 1960`s at Cambridge University. Dennis Ritchie modiIied 'B
language.
4) It was implemented at Telephone Bell Laboratories in
1972. The new language name C. Since it was developed along with the Unix
Operating System.
5) FORTRAN used Ior Engineering and ScientiIic Applications.
6) COBOL used Ior commercial application
7) Easily interact with hardware
8) C is a case sensitive
9) BCPL -~ basic combined programming language is called
B language.
FEATURES OF C LANGUAGE:
1) C is a middle level Language
2) C is highly portable. That means C program written Ior one computer can be run
on another.
3) C is also support Ior both high and low level languages.
4) C has an ability to extend itselI. A "C" program is basically a collection oI
Iunction that is supported by the library (Header Iiles).
5) Extension oI C Iile is Iile name~.C
Compiler and Interpreter:
1) Computer can understand only machine level coding. Computer can`t
understand our high level programming. So must translate our high level coding
into machine level coding.
2) Both compiler and interpreter convert our high level program into machine low
level code.
3) It also help to us debug the error in our program.
4) The only diIIerence is compiler compiles entire program at a time and Iinally list
all the errors whereas the execution oI an interpreter is line by line.
5) The compiler is Iaster than the interpreter.
C TOKENS:
In a passage oI text, Individual words and punctuation marks are called tokens.
Similarly in c language the smallest individual units are known as TOKENS.
1) Keywords
2) IdentiIier
3) Constants
4) Strings
5) Operators
6) Special Symbols.
To Enter into C language:
Start ! Programs ! Turbo C IDE !Click
3
Or
Click the icon (Turbo C IDE) on the desktop.
Or
Click the My Computer icon ! C Colon !TC Folder ! Bin Folder ! Tc File !
click.
Shortcut Keys:
Meaning Shortcut key
Window Full screen ALTEnter
Working area Iull screen F5
Close old program ALTF3
Close C soItware window ALTX
Compile Alt F9 (Error Checking)
Run Ctrl F9
Output Alt F5
Save F2
Open F3
Trace F7
Structure of C program:
Comment Line~
Directives~
main( )

Statements~;
.
.
.
}
Comment Line:
* User understandable code
* They are two types
1) Single line
2) Multi line
Single line:
* Your program titles have single line that time we use single
Line comment line.
Syntax:
//Statements~
EG:
//Addition oI two numbers
2) Multiline:
* Your program titles have more than one line that time
We can use multi line.
Syntax:
/* Statements~....
...................
.........................*/
5
EG:
/* Addition oI two numbers
Created by saranya*/
Directives:
* Directive means all header Iiles.
1) #includestdio.h~
standard input output .header
2) #includeconio.h~
Conson input output.header
3) #includemath.h~
Mathematical.header
4) #includegraphics.h~
Graphical.header
5) #includestring.h~
String.header
here string means more than one character.
main( )
* main is one oI the Iunctions.
* used to display program output result.
2It doesn`t end with semicolon.
Statements:
3All statements are end with semicolon.
printf():-
* It prints the message or output
scanf():-
* Gets the data Irom user at run time.

Program: 1
//To display some text
#includestdio.h~
#includeconio.h~
void main( )

clrscr();
printI("Welcome to C language ");
getch();
}
Execution of c program:
1) Write a c program in c soItware
2) Compile a program --~ ALTF9
3) Link to library or Run -~ CTRLF9
4) To see output --~ ALTF5
4To see output with out using ALT F9 that time we can use one header Iile
that name is #includeconio.h~
5clrscr( ) ! is used to clear previous output .
6getch( ) ! is used to see output without using ALTF5
Data types
8 bits !1 byte
7
Data type Byte and Range
Int 2 byte |-32,768 to 32,769|
Float 4 byte
Char 1 byte -128 to 127
Long int 4 byte
Double 10 byte
Short int 2 byte
Unsigned int 2 byte
VARIABLE:
7The combination oI operand and operator is called variable.
Data types:
8Data types are types oI data.
9Data means collection oI inIormation.
10They are several types oI data types
1) Integer
2) Floating points
3) Character
4) Double
Integer:
11It accepts only integer or decimal values only.
Syntax:
int variable name~;
Eg:
int a;
a2345;
Float:
12It accepts only Iloating or point numbers.
Syntax:
Iloat variable name~;
Eg:
Iloat a;
Eg:
a45.56;
Character:
13Used to accept only single character only.
Syntax:
char variable name~;
Eg:
char a;
c'z';
9
Double:
14Used to accept both integer and also Iloating points.
Syntax:
double variable name~;
Eg:
double a;
a10.45;
(or)
a123;
Printf ( ):
15Used to display output to user.
a 15;
Data type Printf types
Integer printI("d",a); 10
Float printI("I",a); 10.00
Char printI("c",a); c
Double printI("d",a); 10.00
String printI("s",a); s
Hexa printI("x",a);
Octal printI("o",a);
Scanf( ):
16Used to get some value or text Irom user at run time.
& !AddressoI or ampersand
Data type ScanI types
Integer scanI("d ",&a);
Float scanI("I ",&a);
Char scanI("c ",&a);
Double scanI("d ",&a);
String scanI("s ",&a);
Hexa scanI("x ",&a);
Octal scanI("o ",&a);
Program: 2
//Eg Ior data types(printI)
#includestdio.h~
#includeconio.h~
void main()

int i32000;
Iloat I32.89;
double d10.5;
char c'z';
unsigned int u65000;
signed int s-100;
clrscr();
printI("int value is:d",i);
printI("\nIloat value is:I",I);
11
printI("\ndouble value is:d",d);
printI("\nchar value is:c",c);
printI("\nunsigned int is:u",u);
printI("\nsigned int is:d",s);
getch();
}
Program: 3
//program Ior data types(scanI)
#includestdio.h~
#includeconio.h~
void main()

int a;
char n|100|;
clrscr();
printI("enter the a value:");
scanI("d",&a);
printI("enter any name:");
scanI("s",&n);
printI("hexa number is:x",a);
printI("\noctal number is:o",a);
printI("\ngiven name is:s",n);
getch();
}
OPERATOR:
Operator is a Symbol, Which is used to do some arithmetic Operations.
1)Arithmetic Operator:
Operator Meaning
Addition
- Subtraction
* Multiplication
/ Division
Modulus
2)Relational Operator:
Operator Meaning
~ Greater Than
Lesser than
~ Greater than or equal to
Less than or equal to
Equal to
~, ! Not Equal to
3)Logical Operator:
Operator Meaning
&& AND (Both condition True)
,, OR (Any one condition True)
! NOT
4)Assignment Operator:
Operator Meaning

-
*
13
/

5)Unary Operator:
Operator Meaning
A Post increment
a
Pre increment
a-- Post Decrement
--a Pre Decrement
6)Conditional Operator:
*Conditional operator is used to check condition.
Syntax:
(condition)? true statement~ : Ialse statement~;
7)Special Operator:
Operator Meaning
LeIt Brace
}
!"#$% '()*+
( LeIt Parenthesis
) Right Parenthesis
| LeIt Square Bracket
| Right Square Bracket
8) Conversion function:
Conversion type Meaning
d Integer
I Float
c Single Character
bakiya String
9) Escape Sequence:
\n Next line
\t Horizontal tab
\a Bell Alert
\r Carriage return
\b Back space
\\ Front slash
\ / Back slash
\" Double Quote
\' Single Quote
15
Program: 4
//eg Ior escape sequence
#includestdio.h~
#includeconio.h~
void main()

clrscr();
printI("New line isdavid\nbakthakumar");
printI("\nHorizontal tab isdavid\tbakthakumar");
printI("\nBellalert isdavid\abakthakumar");
getch();
}
Program: 5
//eg Ior arithmetic operator
#includestdio.h~
#includeconio.h~
void main()

.int a,b;
clrscr();
printI("enter the a value:");
scanI("d",&a);
printI("enter the b value:");
scanI("d",&b);
printI("\naddition is:d",(ab));
printI("\nsubtraction is:d",(a-b));
printI("\nmultiplication is:d:",(a*b));
printI("\ndivision is:d",(a/b));
printI("\nmodulus is:d",(ab));
getch();
}
Program:6
//eg Ior arithmetic operator
#includestdio.h~
#includeconio.h~
void main()

int days,month;
printI('Enter the number oI days);
scanI('d,&days);
monthdays/30;
daysdays30;
printI('monthdivya,daysdivya,month,days);
getch();
}
,(-#()./0
//eg Ior Relational Logical operator
#includestdio.h~
#includeconio.h~
void main()

int mon;
clrscr();
printrI('Enter the value oI month);
scanI('d,&mon);
iI(mon12,,mon1,,mon2)

printI('Winter);
}
else iI(mon3,,mon4,,mon5)

17
pirntI('Summer);
}
else iI(mon6,,mon7,,mon8)

printI('Spring);
}
else iI(mon9,,mon10,,mon11)

printI('Autumn);
}
else

printI('Please enter the no between 1 to 12);


}
getch();
}
CONDITIONS STATEMENTS:
1II is one oI the condition statements.
2In II statements iI condition is true then true statements are executed else Ialse
statements executed
2At a time only one statements are executed either true or Ialse
3Types oI II condition
1. II condition
2. Else iI condition
3. Ladder II condition
4. Nested II condition
SYNTAX FOR lF CONDlTlON:
II (condition~)

True statements~;
}
SYNTAX FOR ELSE lF CONDlTlON:
II (condition~)

True statements~;
}
else

False statements~;
}
SYNTAX FOR LADDER lF CONDlTlON:
II (condition~)

True statements~;
}
else iI (condition~)

True statements~;
}
else iI(condition~)

True statements~;
}
.
.
.
else

False statements~;
}
SYNTAX FOR NESTED lF CONDlTlON:
19
II (condition~)

True statements~;
iI (condition~)

True statements~;
}
else

False statements~;
}
}
else

False statements~;
}
,!12!34/ 5
//To check given number is odd or even
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
printI("Enter any value:");
scanI("d",&a);
iI((a2)0)

printI("Even number");
}
else

printI("Odd number");
}
getch();
}
,!12!34/ 6
//To check given year is leap year or not
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
printI("Enter any year:");
scanI("d",&a);
iI((a4)0)

printI("leap year");
}
else

printI("not leap year");


}
getch();
}
PROGRAM: 10
//To check given number positive or negative
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
21
printI("Enter the a value:");
scanI("d",&a);
iI(a0)

printI("Negative");
}
else iI(a0)

printI("Zero");
}
else

printI("Positive");
}
getch();
}
,!12!34/ 77
//To check which number is greater a or b
#includestdio.h~
#includeconio.h~
void main()

int a,b;
clrscr();
printI("Enter the a value:");
scanI("d",&a);
printI("Enter the b value:");
scanI("d",&b);
iI(a~b)

printI("A is greater");
}
else

printI("B is greater");
}
getch();
}
PROGRAM:12
//To check which number Pass or Iail#includestdio.h~
#includeconio.h~
void main()

int mark;
clrscr();
printI('Enter the mark);
scanI('d,&mark);
iI(mark~80)

printI('Honour);
}
else iI(mark80 && mark~70)

printI('First class);
}
else iI(mark60 && mark~50);

printI('Second class);
}
else

pirntI('Fail);
}
getch();
}
,!12!34/ 78
//To check given number is single or double or triple or Iour digits
23
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
printI("Enter the a value:");
scanI("d",&a);
iI(a10)

printI("single digit");
}
else iI(a100)

printI("double digit");
}
else iI(a1000)

printI("Triple digit");
}
else iI(a10000)

printI("Iour digit");
}
else

printI("Above Iour digit");


}
getch();
}
,!12!34/ 79
//To check given two number are equal or not
#includestdio.h~
#includeconio.h~
void main()

int a,b;
clrscr();
printI("Enter the a value:");
scanI("d",&a);
printI("Enter the b value:");
scanI("d",&b);
iI(ab)

printI("Equal");
}
else

printI("Not Equal");
}
getch();
}
PROGRAM: 15
//Eg Ior military selection
#includestdio.h~
#includeconio.h~
void main()

char n|100|;
int h,w;
clrscr();
printI("Enter the name:");
scanI("s",&n);
printI("Enter the height:");
scanI("d",&h);
printI("Enter the weight:");
scanI("d",&w);
25
iI((h~175)&&(w~75))

printI("s is selected",n);
}
else

printI("s is rejected",n);
}
getch();
}
,!12!34/ 7:
//To prepare student mark sheet
#includestdio.h~
#includeconio.h~
void main()

char n|100|;
Iloat e,t,m,s,so,tot,avg;
clrscr();
printI("Enter the name:");
scanI("s",&n);
printI("Enter the English mark:");
scanI("I",&e);
printI("Enter the Tamil mark:");
scanI("I",&t);
printI("Enter the Maths mark:");
scanI("I",&m);
printI("Enter the Social science mark:");
scanI("I",&so);
printI("Enter the science mark:");
scanI("I",&s);
totetmsso;
printI("\nTotal is:I",tot);
avgtot/5;
printI("\nAvg is:I",avg);
iI(e~40&&t~40&&m~40&&s~40&&so~40)

printI("\ns is pass",n);
iI(avg~75)

printI("\nGrade is:Dist");
}
else iI(avg~60)

printI("\nGrade is:First");
}
else iI(avg~50)

printI("\nGrade is:Second");
}
else

printI("\nGrade is:Third");
}
}
else

printI("\ns is Iail",n);
printI("\nGrade is:Nil");
}
getch();
}
FOR LOOP:
4Loop is used to execute block oI statements continuously until the condition is
true.
5It is mainly used to avoid the reputation oI coding.
6For is one oI the loop statements.
7In Ior loop they have three Iunctions.
27
1) Assign Starting value
2) Condition
3) Increment or Decrement
8They are two types
4) Normal For loop
5) Nested For loop
SYNTAX FOR NORMAL FOR LOOP:
For (variable name~starting ~; condition~; Inc / Dec ~)

Statements~;
}
SYNTAX FOR NESTED FOR LOOP:
For (variable name~starting ~; condition~; Inc / Dec~)

Statements~;
For (variable name~starting ~; condition~; Inc / Dec~)

Statements~;
}
}
Program: 17
//To display 1 to 10 by using Ior loop
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
Ior(a1;a10;a)

printI("d\n",a);
}
getch();
}
Program: 18
//To display my name as 100 times
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
Ior(a1;a100;a)

printI("saranya\t",a);
}
getch();
}
Program: 19
//To display
#includestdio.h~
#includeconio.h~
void main()

int i,j;
clrscr();
Ior(i10,j1;i~1,j10;i--,j)

printI("d,d,",i,j);
}
getch();
}
29
Program: 20
//To Iind the Iactorial oI given n number
#includestdio.h~
#includeconio.h~
void main()

int n,i,s0;
clrscr();
printI("Enter the n value:");
scanI("d",&n);
Ior(i0;in;i)

ssi;
}
printI("\nsum oI n number is:d",s);
getch();
}
/*
N5
s0 i1
s1 i2
s3 i3
s6 i4
s10 i5
s15
*/
Program: 21
//To Iind the Iactorial oI given n number
#includestdio.h~
#includeconio.h~
void main()

int n,i,s1;
clrscr();
printI("Enter the n value:");
scanI("d",&n);
Ior(i1;in;i)

ss*i;
}
printI("\nsum oI n number is:d",s);
getch();
}
N5
i1
s1 i2
s2 i3
s6 i4
s24 i5
s120 i6
*/
WHILE:
9While is one oI the condition statements.
10In while Iirst they check condition aIter given true statements are executed.
SYNTAX FOR WHILE CONDITION:
While (condition~)

True statements~;
}
31
Program: 22
//To display odd number only 0 to 50
#includestdio.h~
#includeconio.h~
void main()

int i1;
clrscr();
while(i50)

printI("d\t",i);
ii2;
}
getch();
}
Program: 23
//to check how many odd and even numbers
#includestdio.h~
#includeconio.h~
void main()

int i0,n,e0,od0;
clrscr();
printI("Enter the n value:");
scanI("d",&n);
while(in)

iI((i2)0)

ee1;
}
else

odod1;
}
i;
}
printI("\ntotal even number is:d",e);
printI("\ntotal odd number is:d",od);
getch();
}
Program: 24
//To check given number is prime or not
#includestdio.h~
#includeconio.h~
void main()

int n,i,p0;
clrscr();
printI("Enter the n value:");
scanI("d",&n);
Ior(i2;in;i)

iI((in)0)

p1;
}
}
iI(p1)

printI("Given number is Not prime number");


}
else

printI("given number is prime number");


}
getch();
33
}
DO WHILE:
11DO While is one oI the Loop statements.
12In Do While Iirst given statements are executed aIter they check condition.
13Do while brace end with semicolon.
SYNTAX FOR DO WHILE CONDITION:
do

True statements~;
}
While (condition~);
GOTO STATEMENTS:
14To transIer our execution program Irom one place to another place by using
GOTO statements
15They are two types
6) BeIore GOTO
7) AIter GOTO
SYNTAX FOR BEFORE GOTO:
goto label~;
statements~;
label~:
Program:25
//Eg Ior beIore goto
#includestdio.h~
#includeconio.h~
void main()

clrscr();
I:
printI("\nsaranya");
goto I;
getch();
}
SYNTAX FOR AFTER GOTO:
label~:
statements~;
goto label~;
Program:26
//Eg Ior aIter goto
#includestdio.h~
#includeconio.h~
void main()

clrscr();
goto I;
printI("saranya");
35
I:
printI("\nnandhini");
getch();
}

Gotoxy:
It is used to move the cursor to particular position, which is given, by row and
column at execution time.
Syntax:
gotoxy( column ~, row ~ );
Program:27
//EG Ior gotoxy concept
#include dos.h~
#include stdio.h~
#includeconio.h~
struct date d;
struct time t;
void main()

clrscr();
getdate(&d);
gettime(&t);
printI("\nNow date is:d/d/d",d.daday,d.damon,d.dayear);
printI("\nNow time is:d:d:d",t.tihour,t.timin,t.tisec);
getch();
}
BREAK STATEMENTS:
16Break is one oI the statements.
17Used to break the loop.
SYNTAX FOR BREAK STATEMENTS:
break;
Program:28
//EG Ior break statements
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
Ior(a1;a10;a)

iI(a5)

break;
}
printI("d\n",a);
}
getch();
}
CONTINUE STATEMENTS:
18Continue is one oI the statements.
19Used to continue the loop
SYNTAX FOR CONTINUE STATEMENTS:
37
continue;
Program:29
//EG Ior continue statements
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
Ior(a1;a10;a)

iI(a5)

continue;
}
printI("d\n",a);
}
getch();
}
SWITCH:
20Switch also one oI the condition statement
21In can check a condition by case Iormat
SYNTAX FOR SWITCH:
switch( Exp~)

case Exp1~:
statements~;
break;
case Exp2~:
statements~;
break;
case Exp3~:
statements~;
break;
.
.
.
deIault:
deIault statements~;
}
Program:30
//TO DISPLAY SWITCH CASE
#includestdio.h~
#includeconio.h~
void main()

int nday;
clrscr();
printI("Enter the number between 1 to 7");
scanI("d",&nday);
switch(nday)

case 1: printI("\nSunday"); break;


case 2: printI("\nMonday"); break;
case 3: printI("\nTuesday"); break;
case 4: printI("\nWednesday"); break;
case 5: printI("\nThursday");break;
case 6: printI("\Friday"); break;
case 7: printI("\nSaturday"); break;
deIault: printI("Invalid input");
}
getch();
39
}
Array :
22Array means set oI homogeneous Iunction.
23Declare one variable store more than one value in it.
24Data type as in same variable name is called array.
25Here array start with zero.
26End with beIore the number.
27Array can classiIied into two types
1) single dimensional array
2) double dimensional array
Syntax for single dimensional array:
data type~ variable name~|size~|;
Eg:
int a|5|;
Eg:
int a|5|;
Values:
int a|0|;
int a|1|;
int a|2|;
int a|3|;
int a|4|;
Syntax for initialization single dimensional array:
data type~ variable name~|size~|values~};
Eg:
int a|5|34,46,2,23,56};
2) Double dimensional array
Syntax for double dimensional array:
Data type~ variable name~|size~||size~|;
Eg:
int a|3||3|;
Syntax for initialization double dimensional array:
data type~ variable name~|size~||size~|values~}values~};
Eg:
41
int a|3||3|34,46,2}35,23,56};
Eg:
int arr|3||4|;
VALUE:
arr|0||0|;
arr|0||1|;
arr|0||2|;
arr|0||3|;
arr|1||0|;
arr|1||1|;
arr|1||2|;
arr|1||3|;
arr|2||0|;
arr|2||1|;
arr|2||2|;
arr|2||3|;
Transpose of matrix:
Matrix order row * col
1 2 3
A 4 5 6
7 8 9
T 1 4 7
A 2 5 8
3 6 9
1
2
3
4
5
6
7
8
9
1
4
7
2
5
8
3
6
9
2 2 2
A 2 2 2
2 2 2
2 2 2
B 2 2 2
2 2 2
CAB
4 4 4
C 4 4 4
4 4 4
CA-B
0 0 0
C 0 0 0
0 0 0
43
Program:31
\\Sum oI array
#includestdio.h~
#includeconio.h~
void main()

int i;
int a|5|;
int sum0;
clrscr();
printI("Enter Array elements");
Ior(i0;i5;i)

scanI("d",&a|i|);
}
printI("Array elements are:");
Ior(i0;i5;i)

sumsuma|i|;
}
printI("sum is:d",sum);
getch();
}
Program:32
//Example Ior Matrix multiplication using double dimension array
#includestdio.h~
#includeconio.h~
void main()

int a|3||3|,b|3||3|,c|3||3|;
int i,j,k;
clrscr();
printI("\n Enter values Ior Array A:");
Ior(i0;i3;i)

Ior(j0;j3;j)

scanI("d",&a|i||j|);
}
}
printI("\n Enter values Ior Array B:");
Ior(i0;i3;i)

Ior(j0;j3;j)

scanI("d",&b|i||j|);
}
}
printI("\n Multiplication Result is ");
Ior(i0;i3;i)

Ior(j0;j3;j)

c|i||j|0;
Ior(k0;k3;k)

c|i||j|c|i||j|(a|i||k|*b|k||j|);
}
}
}
Ior(i0;i3;i)

Ior(j0;j3;j)

printI("\n C|d||d| value is d",i,j,c|i||j|);


}
}
getch();
45
}
Program:33
//Matrix subtraction
#includestdio.h~
#includeconio.h~
void main()

int a|3||3|,b|3||3|,c|3||3|,i,j;
clrscr();
printI("Enter the A matrix value:");
Ior(i0;i3;i)
Ior(j0;j3;j)

printI("\nEnter the value Ior a|d||d|:",i,j);


scanI("d",&a|i||j|);
}
printI("Enter the B matrix value:");
Ior(i0;i3;i)
Ior(j0;j3;j)

printI("\nEnter the value Ior b|d||d|:",i,j);


scanI("d",&b|i||j|);
}
Ior(i0;i3;i)
Ior(j0;j3;j)

c|i||j|a|i||j|-b|i||j|;
}
printI("Matrix subtraction is:\n");
Ior(i0;i3;i)

printI("\n\n");
Ior(j0;j3;j)

printI("\t\t");
printI("d",c|i||j|);
}
}
getch();
}
Program:34
//Transpose oI matrix
#includestdio.h~
#includeconio.h~
void main()

int i,j,a|3||3|;
clrscr();
printI("Enter the matrix values:");
Ior(i0;i3;i)
Ior(j0;j3;j)

printI("\nEnter the values Ior a|d||d|:",i,j);


scanI("d",&a|i||j|);
}
printI("Given A matrix values are:\n");
Ior(i0;i3;i)

printI("\n\n");
Ior(j0;j3;j)

printI("\t\t");
printI("d",a|j||i|);
}
}
getch();
}
47
Program:35
//to display one diemsional array:
#include stdio.h~
#includeconio.h~
void main()

int a|5|,sum0;
clrscr();
printI("Enter teh Iice number");
Ior(i1;i5;i)

scanI("d",&a|i|);
sumsuma|i|;
}
printI("The sum oI given number d\n",sum);
getch();
}
Program:36
//Eg Ior array concept
#includestdio.h~
void main()

int n|5|,i;
printI("Enter the Iive values:\n");
Ior(i0;i5;i)

scanI("d",&n|i|);
}
printI("Given Iive values are:\n");
Ior(i0;i5;i)

printI("d\n",n|i|);
}
}
Program:37
//To display Ascending order
//bubble sort
#includestdio.h~
#includeconio.h~
void main()

int n,a|100|,i,j,t;
clrscr();
printI("Enter how many number you check:");
scanI("d",&n);
printI("Enter the d values\n",n);
Ior(i0;in;i)

scanI("d",&a|i|);
}
Ior(i0;in;i)
Ior(j0;jn;j)

iI(a|i|a|j|)

ta|i|;
a|i|a|j|;
a|j|t;
}
}
printI("\nAscending values are:\n");
Ior(i0;in;i)

printI("d\n",a|i|);
}
getch();
}
49
Program:38
//To display Descending order
#includestdio.h~
#includeconio.h~
void main()

int n,a|100|,i,j,t;
clrscr();
printI("Enter how many number you check:");
scanI("d",&n);
printI("Enter the d values\n",n);
Ior(i0;in;i)

scanI("d",&a|i|);
}
Ior(i0;in;i)
Ior(j0;jn;j)

iI(a|i|~a|j|)

ta|i|;
a|i|a|j|;
a|j|t;
}
}
printI("\nDescending values are:\n");
Ior(i0;in;i)

printI("d\n",a|i|);
}
getch();
}
Program:39
\\Array rows oI columns:-
#includestdio.h~
#includeconio.h~
void main()

int a|10|||10|,n,m,i,j;
clrscr();
printI("\nEnter rows");
scanI("d",&n);
printI("\nEnter columns");
scanI("d",&m);
printI("Get the input array");
Ior(i0;in;i)

Ior(j0;jm;j)

scanI("d",&a|i||j|);
}
}
printI("\nDisplay array\n");
Ior(i0;in;i)

Ior(j0;jm;j)

printI("d\t",a|i||j|);
}
printI("\n");
}
getch();
}
51
Program:40
\\String oI array:
#includestdio.h~
#includeconio.h~
void main()

char a|5||20|"kkk","hhh","III","uuu","ddd"};
int i,j;
clrscr();
printI("\nEnter name");
Ior(i0;i5;i)

printI("s",a|i||j|);
}
getch();
}
Program:41
//TO display Two diemsional array:
#includestido.h~
#includeconio.h~
void main()

int i,j,arr|3||4|;
clrscr();
Ior(i0;i3;i)
Ior(j0;j4;i)
arr|i||j|(i*4)j1;
printI("printing the array contents");
Ior(i0;i3;i)

Ior(j0;j4;i)
printI("4d",arr|i||j|);
printI("\n");
}
getch();
}
D
STRING FUNCTIONS:
28String means more than one character or set oI character or bulk oI character.
29It has one header Iile
#includestring.h~
30They are several types oI Iunctions.
1)Strlen (String Length)
2) Strupr (String Upper)
3) Strlwr (String Lower)
4) Strrev (String Reverse)
5) Strcpy (String Copy)
6) Strcat (String Concatenation)
7) Strcmp(String Compare)
8) Stricmp(String Compare Ignore case)
1) Strlen ( ):
31It is used to Iind out the length oI the string.
Syntax:

int variable ~strlen(str1~);


Program:42
//To Iind the length oI the string
#includestdio.h~
53
#includeconio.h~
#includestring.h~
void main()

char n|100|;
int i;
clrscr();
printI("\nEnter any string:");
scanI("s",&n);
istrlen(n);
printI("\nLength oI the string is:d",i);
getch();
}

2) Strlwr ( ):
5Used to convert a given string as upper case to lower case.
Syntax:
Strlwr(str1~);
Program:43
//To convert lower case to upper case
#includestdio.h~
#includeconio.h~
#includestring.h~
void main()

char n|100|;
clrscr();
printI("Enter any string as lower case:");
scanI("s",&n);
strupr(n);
printI("upper case string is:s",n);
getch();
}
3) Strupr():
6Used to convert a given string as lower case to upper case.
Syntax:
Strupr(str1~);
Program:44
//To convert upper case to lower case
#includestdio.h~
#includeconio.h~
#includestring.h~
void main()

char n|100|;
clrscr();
printI("Enter any string as upper case:");
scanI("s",&n);
strlwr(n);
printI("Lower case string is:s",n);
55
getch();
}
Program:45
//Eg Ior string reverse
#includestdio.h~
#includeconio.h~
#includestring.h~
void main()

char n|100|;
clrscr();
printI("Enter any string:");
scanI("s",&n);
strrev(n);
printI("String reverse is:s",n);
getch();
}
5) Strcpy():
7Used to copy a string Irom last variable to Iront variable.
Syntax:
strcpy(str1~,str2~);
Eg:
strcpy(b,a);
Program:46
//EG Ior string copy
#includestdio.h~
#includeconio.h~
#includestring.h~
void main()

char a|100|,b|100|;
clrscr();
printI("Enter the string Ior a:");
scanI("s",&a);
strcpy(b,a);
printI("B string is:s",b);
getch();
}
6) Strcat():
8strcat() is used to join two strings and store in the Iirst character variable.
Syntax:
Strcat(str1~,str2~);
Program:47
//Eg Ior string cat
#includestring.h~
#includeconio.h~
#includestdio.h~
void main()

char a|100|,b|100|;
clrscr();
printI("Enter the a string:");
57
scanI("s",&a);
printI("Enter the b string:");
scanI("s",&b);
strcat(a,b);
printI("Attach string is:s",a);
getch();
}
7) Strcmp():
9Strcmp() is used to compare two strings with case sensitive.
Program:48
//Eg Ior stringcompare
#includestdio.h~
#includestring.h~
#includeconio.h~
void main()

char a|100|,b|100|;
clrscr();
printI("Enter the string Ior a:");
scanI("s",&a);
printI("Enter the string Ior b:");
scanI("s",&b);
iI(strcmp(a,b)0)

printI("Given two string are equal");


}
else

printI("Given two string are not equal");


}
getch();
}
Syntax:
1) It returns zero when two strings are equal.
2) It returns (-1) when st1 is less than st2.
3) It returns (1) when st1 is greater than st2.
Syntax:
strcmp(Strl~, str2~)
8)Stricmp():
10Stricmp() is used to compare two strings without case sensitive.
Syntax:
Stricmp(str1~,str2~);
Program:49
//Eg Ior stringignorecompare
#includestdio.h~
#includestring.h~
#includeconio.h~
void main()

char a|100|,b|100|;
clrscr();
printI("Enter the string Ior a:");
scanI("s",&a);
printI("Enter the string Ior b:");
59
scanI("s",&b);
iI(stricmp(a,b)0)

printI("Given two string are equal");


}
else

printI("Given two string are not equal");


}
getch();
}
Pointer:
2Pointer is a variable, which is used to store the address oI another variable.
3Pointer is one oI the variables.
4Used to Iind out the address oI another variable value.
5Here & (address oI) Iind the address.
6Here *(Asterisk) display the given value
Advantages oI pointer:
(i) Easy any link oI variable.
(ii) Execution time is less.
* ! Print a value
& ! Print an address.
The liIetime oI a variable will starts when a Iunction is called and it destroys when
the Iunction is completed.
Syntax Ior declaration:
data type~ *variable name~;
Eg:
int *a;
Program:50
#includestdio.h~
#includeconio.h~
void main()

char a;
int x;
Iloat p,q;
clrscr();
a'A';
x125;
p10.25;
q18.75;
printI("c is stored address u\n",a & a);
printI("d is stored address u\n",x, &x);
printI("I I is stored address u\n", p,q,&p,&q);
getch();
}
Program:51
//Pointer connecting with array
#includestdio.h~
#includeconio.h~
void main()

int i,*pt;
int x|5|4,6,7,12,10};
clrscr();
ptx;
Ior(i0;i5;i)

*pt*pt5;
printI("\n Value isd",*pt);
pt;
}
getch();
61
}
Program:52
#includestdio.h~
#includeconio.h~
void main()

int x10,y10;
int a,b,c,d;
int *p1&x, *p2&y;
a(*p1);
b--(*p2);
c*p1(*p2)--;
d(*p2)--;
printI("\n d\n d \n d\n d",a,b,c,d);
getch();
}
Program:53
//to display given value but we use pointer
#includestdio.h~
#includeconio.h~
void main()

int a;
int *p;
clrscr();
printI("Enter the a value:");
scanI("d",&a);
printI("\nA value is:d",a);
p&a;
printI("\nAddress oI a value is:d",*p);
getch();
}
Program:54
//Example Ior pointer with character array
#includestdio.h~
#includeconio.h~
void main()

int i;
char *name|5|;
clrscr();
printI("\n Enter Iive names");
Ior(i0;i5;i)

gets(name|i|);
}
printI("\n Output");
Ior(i0;i5;i)

printI("\n d name is s",i1,name|i|);


}
getch();
}
Program:55
//Example Ior pointer connecting with Iunction
#includestdio.h~
#includeconio.h~
void main()

int x,y;
clrscr();
63
printI("\n Enter value Ior x");
scanI("d",&x);
printI("\n Enter value Ior Y");
scanI("d",&y);
printI("\n BeIore calling Iunction");
printI("\n x value is d",x);
printI("\n y value is d",y);
swap(&x,&y);
printI("\n AIter Calling Function");
printI("\n X value is d",x);
printI("\n Y value is d",y);
getch();
}
swap(int *a,int *b)

int t;
t*a;
*a*b;
*bt;
}
Program:56
//Example Ior Pointer
#includestdio.h~
#includeconio.h~
void main()

int a;
clrscr();
printI("\nEnter a number");
scanI("d",&a);
printI("\n A value isd",a);
printI("\n Address oI A is u",&a);
getch();
}
Program:57
//Example2 Ior pointer
#includestdio.h~
#includeconio.h~
void main()

int a10;
int *p;
clrscr();
printI("\n \n A d",a);
printI("\n \nAddress oI A u",&a);
p&a;
printI("\n \n P addressu",p);
printI("\n \n Value oI Pd",*p);
printI("\n \n A valued",*&a);
*p*p30;
printI("\n \n Value oI Pd",*p);
printI("\n \n A value is d",a);
getch();
}
Program:58
//Example3 Ior pointer to diIIerent datatypes
#includestdio.h~
#includeconio.h~
void main()

int a;
char b;
Iloat c;
int *pt1;
65
char *pt2;
Iloat *pt3;
clrscr();
a10;
b's';
c25.16;
pt1&a;
pt2&b;
pt3&c;
printI("\n value \t Address");
printI("\n d \t u",a,pt1);
printI("\n c \t u",b,pt2);
printI("\n I \t u",c,pt3);
*pt140;
*pt3c20.22;
printI("\n Value oI ad",a);
printI("\n Value oI pt3 is I",*pt3);
getch();
}
Functions:
1Functions are sub programs, which are having repetative statements.
Advantages oI Iunctions:
1Less memories space
2Less execution time
3SimpliIies oI coding
4Easy to display
Types oI Iunction:
5Function declaration
6Function calling
7Function deIinition
Function declaration:
Syntax:
Return type~ Iunction name~( );
Function calling:
Syntax:
Function name~(arguments~);
Function deIinition:
Syntax:
Return type~ Iunction name~(argument~)

Body oI the statement~;


}
Important Iactors when you are using Iunction:
Declaration oI Iunction optional when a Iunction declared with
argument that data type only should be used in calling and
deIinition.
# Functon
shoud
return a
vaue
A Iunction can be any number oI times.
Number oI argument speciIied in calling is equal to the
deIinition.
67
The order in which a Iunction has called in the same way there is
no rule to deIinition the Iunction to same way.
Function should have a return a value. II the return is not
mentioned the deIault deIinition is integer.
The variables, which are used in Iunction, get to be "argument or
parameter.
Program:59
//To Iind the Iibonacci series by using Iunction
#includestdio.h~
#includeconio.h~
void get();
int n,i0,j1,k,c;
void main()

clrscr();
printI("Enter how many Iibonacci series you want:");
scanI("d",&n);
get();
getch();
}
void get()

printI("Fibonacci series value is:\n");


printI("d\n",i);
printI("d\n",j);
Ior(c1;cn-2;c)

kij;
printI("d\n",k);
ij;
jk;
}
}
Program:60
//To Iind the address oI another variable value
#includestdio.h~
#includeconio.h~
void main()

int a;
int *p;
clrscr();
printI("Enter the a value:");
scanI("d",&a);
printI("\nA value is:d",a);
p&a;
printI("\nAddress oI a value is:d",p);
getch();
}
Program:61
//To swapping three numbers by using Iunction
#includestdio.h~
#includeconio.h~
69
void main()

void disp();//Function declaration


clrscr();
disp();//To invoke or call Iunction
getch();
}
void disp()//Function deIinition

int a,b,c,t;
printI("Enter the a value:");
scanI("d",&a);
printI("Enter the b value:");
scanI("d",&b);
printI("Enter the c value:");
scanI("d",&c);
ta;
ac;
ct;
printI("\nA value is:d",a);
printI("\nB value is:d",b);
printI("\nC value is:d",c);
}
Arguments are of two types:
(i) Actual arguments:
15Arguments, which are, Iunction calling.
(ii) Formal arguments:
16Arguments, which are, Iunction deIinition.
Return statement:
17the Iunction return a value through return statement.
18It is Iour ways
(i) return;
(ii) return(variable);
(iii) return(number);
(iv) return(expression);
Parameter passing:
19They are two types:
i)Call by value:
20II a value passed Irom an actual argument, Iormal argument then iI
any change in Iormal argument, will not aIIect in actual argument. iI
concept is called are call by value.
21C permits only "call by value method oI parameter passing.
Program:62
//Eg Ior call by value Iunction
#includestdio.h~
#includeconio.h~
void saran(int *c,int*d);
int a,b;
void main()

clrscr();
printI("Enter the a value:");
71
scanI("d",&a);
printI("Enter the b value:");
scanI("d",&b);
saran(&a,&b);
getch();
}
void saran(int *c,int *d)

printI("\nA value is:d",*c);


printI("\nB value is:d",*d);
}
ii)Call by reference:
22Instead passing a actual argument value to a Iunction. II the address
oI the actual argument is than any change in Iormal argument it also
changes the value in actual argument.
Program:63
//Eg Ior call by reIerence Iunction
#includestdio.h~
#includeconio.h~
void kumar(int *c,int*d);
int a,b;
void main()

clrscr();
printI("Enter the a value:");
scanI("d",&a);
printI("Enter the b value:");
scanI("d",&b);
kumar(&a,&b);
getch();
}
void kumar(int *c,int *d)

printI("\nA value is:d",c);


printI("\nB value is:d",d);
}
3Single character input function:
(i) Getchar ( ):
23It accepts a character value upto you enter but it will store only one
character.
Syntax:
Character variable~getchar();
Program:64
#includestdio.h~
#includeconio.h~
void main()

char ch;
clrscr();
printI('Enter the character\digit);
73
chgetchar();
iI(isalpha(ch)~0);
printI('It is a alpha);
else iI(isdigit(ch)~0)
printI('It is a digit);
else
printI('It is a alphanumeric);
getch();
}
(ii) Getche( ):
24It accepts only one character.
Syntax:
Character variable~getche();
(iii) Getch ( ):
25It accepts one character without display.
Syntax:
Character variable~getch();
single character output function:
(i) putchar():
26It is used to print a single character.
Syntax:
putchar(character variable~);
Program:65
#includestdio.h~
#includeconio.h~
void main()

char ch();
printI('Etner the lowercase\uppercase);
chgetchar();
iI(islower(ch))
putchar(toupper(ch))
else
putchar(tolower(ch))
getch();
}
String input function:
(i)gets():
Gets is used to get string with space (like sentence).
syntax:
string variable~gets();
Program:62
#includestdio.h~
#includeconio.h~
void main()

char s|40|;
printI('Enter the name);
gets(s);
puts('print the name);
puts(s);
getch();
}
Sting output function:
75
(i) puts():
27puts is used to print string value.
Syntax:
puts(string variable~);
Program:63
#includestdio.h~
#includeconio.h~
void main()

int sno,m1,m2,m3;
char name|20|;
Iloat total, avg;
printI('Enter the sno,name,m1,m2,m3);
scanI ('ddd,&sno,name,&m1,&m2,&m3);
totalm1m2m3;
avgtotal/3;
printI('Sno.d,sno);
printI('Name c,Name);
printI('Marks.d\td\td\t,m1,m2,m3);
printI('Total .I,total);
printI('Avg. I,avg);
getch();
}
!"#$
28File is a collection oI data (text & numbers). In order to store the data
permanently, the data should be stored in the hard disk. For that data are
stored in a Iile.
Files are two types:
1) Text Iile
2) Binary Iile
Opening a file:
29The Iunction Iopen() is used to open a Iile.
Syntax:
FILE * Iile pointer name~;
Iile pointer name~Iopen (Iile name~, Iile mode~);
30The Iile, which is opened that, should be assigned to a Iile pointer.
31Using that pointer only we can able to do any process in the Iile.
Closing a file:
32This Iunction Iclose () is used to close a Iile. Every Iile should be closed
which is already opened.
FILE MODES:
33Three major types oI Iile modes are present.
1) r ~ Which is used to open the Iile in read mode.
2) w ~ Which is used to open the Iile in write mode.
3) a ~ Which is used to open the Iile in append mode.( Adding new content to old
Iile)
Reading and Writing the data from a file:
77
1) Igetc ~ Reads a character Irom the Iiles
2) Iputc~ print only
Syntax:
Igetc(File pointer);
Program:64
//To Display Iile Igetc()
#includestdio.h~
#includeconio.h~
void main()

FILE *Ip;
char c;
clrscr();
IpIopen("e.txt","w");
do

scanI("c",&c);
putc(c,Ip);
}
while(c!'q');
Iclose(Ip);
IpIopen("e.txt","r");
do

cgetc(Ip);
printI("c",c);
}
while(c!EOF);
getch();
}
Program:65
//To Display Iile getc()
#includestdio.h~
#includeconio.h~
void main()

FILE * Ip;
char ch;
char In|20|;
clrscr();
printI("Enter the Iile name");
gets(In);
IpIopen(In,"r");
chIgetc(Ip);
while(ch!EOF)

putchar(ch);
chIgetc(Ip);
}
Iclose(Ip);
getch();
}
2) Iputc ~ Writes a single character in the Iile.
Syntax:
Iputc(variable name~,Iile pointer~);
79
Program:66
//To Display Iile Iputc()
#includestdio.h~
#includeconio.h~
void main()

FILE * Ip;
char str;
char In|20|;
clrscr();
printI("Enter the Iile name");
gets(In);
IpIopen(In,"w");
clrscr();
printI("Enter Ior end oI the Iile");
do

strgetchar();
Iputc(str,Ip);
}
while(str!'');
Iclose(Ip);
getch();
}
Program:67
//To write into another Iile
#includestdio.h~
#includeconio.h~
void main()

char c,s|100|;
FILE *I;
clrscr();
printI("Enter the Iile name with directory:");
scanI("s",s);
IIopen(s,"w");
while(c!'')

Iputc(c,I);
scanI("c",&c);
}
}
Program:69
//To Display Iile putc()
#includestdio.h~
#includeconio.h~
void main()

FILE * Ip;
char ch;
clrscr();
printI("Data input");
IpIopen("lakshmi","w");
while((chgetchar())!EOF)
putc(ch,Ip);
Iclose(Ip);
printI("Data output");
IpIopen("lakshmi","r");
while((chgetc(Ip))!EOF)
printI("c",ch);
Iclose(Ip);
getch();
}
81
!"#$ &'#(!"
Program:70
))*" +#,-.'/ 0#.1 1&-23
4#(5.6$17,8$#"9:;
4#(5.6$175"(#"9:;

char name|10|;
char ans'y';
Iloat basic;
int age;
FILE *Ip;
clrscr();
IpIopen("emp.txt","w");
iI(IpNULL)

printI("cannot open a Iile\n");


exti();
}
while((ans'y') ,, (ans'y'))

printI("Enter employee details\n");


scanI("sdI",name,&age,&basic);
IprintI(Ip,"sdI",name,age,basic);
printI("Enter another employee details\n");
IIlush(stdin);
scanI("c",&ans);
}
Iclose(Ip);
getch();
}
Random Access Files:
1) Iseek()
This Iunction is used to move the Iile pointer position to the desired location.
Syntax:
Iseek(Iile pointer~,oIIset~, Position~);
Note:
34OIIset speciIies the number oI position to be moved.
Position Values:
Value Meaning
0 Beginning oI Iile
1 Current position
2 End oI Iile
2) Rewind ( ):
35Rewind() is used to set the Iile pointer to the starting position.
Syntax:
rewind();
3) Itell():
36Itell() is used to know the current position oI the Iile pointer.
83
4) Iwrite():
37Iwrite() is used to write the content in the Iile.
5) Iread():
38Iread() is used to read the content Irom the Iile.
STRUCTURE:
39Structure is a compound data type. Structure is a collection oI diIIerent data
items.
Declaration of structure:
struct structure name~

data type~ variable1~;


data type~ variable1~;
data type~ variable1~;
................
.................
...............
};
40Struct keyword is used to declare a structure.
Eg:
Struct exam

int no;
char na|20|;
Iloat mark;
};
85
Program:72
//Example Ior structure
#includestdio.h~
#includeconio.h~
struct player

int plno;
char plname|20|;
Iloat btavg;
};
void main()

struct player p;
clrscr();
printI("\n Enter player Number:");
scanI("d",&p.plno);
printI("\n Enter player Name:");
scanI("s",&p.plname);
printI("\n Enter Batting Average:");
scanI("I",&p.btavg);
printI("\n Players Details");
printI("\n Player Number :d",p.plno);
printI("\n Player Name :s",p.plname);
printI("\n Batting Average:I",p.btavg);
getch();
}
Program:73
Program:74
//Example Ior Structure with Array
#includestdio.h~
#includeconio.h~
struct product

int pno;
char *pname|20|;
int price;
};
void main()

int no,i;
struct product p1|4|;
clrscr();
Ior(i0;i4;i)

printI("Enter product Number:");


scanI("d",&p1|i|.pno);
printI("Enter product Name:");
scanI("s",&p1|i|.pname);
printI("Enter Product price:");
scanI("d",&p1|i|.price);
}
printI("\nProduct Details");
printI("\nNumber\t Name \t Price\n");
Ior(i0;i4;i)

printI("\nd\ts\td\n",p1|i|.pno,p1|i|.pname,p1|i|.price);
87
}
getch();
}
Structure Variable:
41To access the structure members Irom outside it, we have to create a structure
variable. Using structure variable, we can access the structure members.
Syntax:
Struct Structure name~ var1, var2, var3,...;
Nested Structure:
42A Structure that is declared within another structure is called nested structure.
Lifetime and scope of a variable:
43The liIetime oI a variable will starts when the Iunction is called and it
destroys when the Iunction is completed.
44The scope oI a variable means that where we can able to store the value oI a
variable.
Storage classes:
(i) Automatic (auto)
(ii) External (global)
(iii) Static
(iv) Register
(i) Automatic:
The memory Ior the variable will create when the Iunction is called and it
destroys when it comes out oI Iunction. This type is called automatic variable.
In c, all variables, which are deIined under a Iunction, is said to be automatic
variable. The keyword auto can deIine it.
(ii) External:
45II the variable is declared outside the main Iunction, then the variable is said
to be external variable. The value oI external variable can be used in any oI
the Iunction in the program and any Iunction can change the value oI 1.
(iii ) Static:
46II the variable is declared as static. Its value is persistent that is remains
unchanged. The value oI static variable is 0 by deIault.
(iv) Register:
47Instead oI storing a value. In memory, we can also store it in register. II the
variable is stored in register. It is accessed very Iastly comparing to the
variable present in memory.
Input a
Input b
A10
B5
Cab
Print c
End
//Example Ior structure with Iunction
89
#includestdio.h~
#includeconio.h~
struct emp

int eno;
Iloat bs;
int years;
}e1;
void main()

void get();
clrscr();
printI("\n Enter employee Number:");
scanI("d",&e1.eno);
printI("\n Enter Basic Salary:");
scanI("I",&e1.bs);
printI("\n Enter Number oI years Experiance:");
scanI("d",&e1.years);
get(e1);
getch();
}
void get(struct emp e2)

Iloat netsal;
netsale2.bs*e2.years;
printI("\n Employee Numberd",e2.eno);
printI("\n Basic Salary I",e2.bs);
printI("\n Years oI Experianced",e2.years);
printI("\n Net Salary I",netsal);
}
Lineary
//Eg Ior Linear Search program
#includeconio.h~
#includestdio.h~
void main()

int n,a|100|,i,k,t;
clrscr();
printI("\nEnter How many number checking:");
scanI("d",&n);
Ior(i0;in;i)

printI("\nEnter the value oI d:",i);


scanI("d",&a|i|);
}
printI("\nEnter the Key Position:");
scanI("d",&k);
Ior(i0;in;i)

iI("d",i1k)

printI("\nGiven position is:d oI key value is:d",i1,a|i|);


t0;
getch();
exit(0);
}
else

t1;
}
}
iI(t1)

printI("\nNot Iound in the list");


}
getch();
}
91

You might also like