SlideShare a Scribd company logo
C ~ Language
C ~ Language
Introduction
The Language is a software which is used to communicate with the computer for
doing certain process. The language must have a compiler and do an operation.
Origin
 C – Language was created by Denise Ritchie and Brain Kernighan in Bell
Laboratories
 The Language available before the invention of C is B – Language, created by
Ken Thompson.
B leds to the development of C in 1970’s.
The ANSI(American National Standard Institute) C standard was finally
adopted in December 1989.
C is a middle level language, because it combines the best elements of high level
language with control and flexibility of assembly language. It is a case sensitive
language.
C ~ Structure
Documentation Section
Link Section
Definition Section
Global Declaration
return_type main(argumentlist)
{
variable declarations;
Statements;
}
Sub Function
Function 1
Function 2
:
:
Function n
Explanation
 Documentation Section – This is used to provide some
meaningful information about the program.
 Link Section - In this section we include the header files
whose functions are used in the program.
Eg : #include<stdio.h>
 Definition Section – In this section we use the Symbolic
Constants
Eg : # PI 3.14
 Global Declaration – In this section we declare the variable
which is going to used are accessed by any where in the
program.
 Main – This contains the coding (variable, statements)
which are going to be executed. Eg: printf().
 Function 1 … Function n – Sub functions which are used in
the programs.
Steps to do a Program.
Going to the C Editor.
 Click Start Run (Type) Command. Then the
command prompt will be appear. In that
 Type as follows
cd
cd tc
tc
In the Editor
 To create a new file.
Click File  New
 To save a file
Click File  Save(F2)
Type the file name with the extension as .c
Eg:
Test.c
 To open a file
Click File Open(F3)
 To Quit
Click File Quit
 To Compile file to see the errors
Click Compile Compile(Alt+F9)
 To run or execute a file to see the output
Click Run Run(ctrl+F9)
Escape Sequence
The escape sequence are used to format the
statements which are going to be displayed on the
screen. The most frequently used escape sequence
are:
 n – This is used to produce new line while
display
 t – This is used to produce tab while display.
Simple Program
/* Simple Program */ Document section
#include<stdio.h> Link Section
#include<conio.h>
void main()
{
clrscr();
printf("*");
printf("n Hai");
getch();
}
Comment Line
The Comment Line Symbols are used to make
the compiler not to execute. When a line is
declared as comments, It will not be executed by
Compiler. The types of Comments are :
 Single Line Comment – ( //… )
It used to make a single line as a comment
 Multi Line Comment – (/* … */)
It is used to make more than one line as a
comment
Variables & Constants
Variables
 These are the locations in the memory in which
the given values are stored.
 The values which can be changed during the
execution of the program.
Constants:
 The values which cannot be changed during the
execution of the program.
Data types
This will indicate the type of the value which is
going to be stored in the variable.
Data type Delimiter
====== ======
char %s,%c
int %d
long int %ld
float %f
double %lf
boolean --
Operators
These are used to do certain operations. The types
of operators are as follows.
 Arithmetic Operators:
These are used to do arithmetic operations. It consist
of two operands.
+ This is used to do addition operation.
- This is used to do subtraction operation.
* This is used to do Multiplication Operation.
/ This is used to do Division operation and return
“quotient” as result
% This is used to do division operation and return
“Remainder” as result.
 Relational Operators:
These are used to do the relational operation. It
can be the combination of two arithmetic
expression.
> Greater than
< Less than
>= Greater than or Equal to
<= Less than or Equal to
!= Not Equal to
 Logical Operators:
These are used to do the logical operation. It can
contain two relational expression.
& And
|| or
! not
Example Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
a=5;
b=5;
c=a+b;
printf("C is : %d",c);
getch();
}
C_Language_PS&PC_Notes.ppt
Control Statements
These are used to control the execution of the program.
Control Statements
Conditional Unconditional
Two Way Branching Multi Way Branching Go to
Simple … If
If … Else
If … Else If
Switch Case
 Conditional Control Statement:
Based on the given the execution of the program is controlled.
 Uncnditional Control Statement:
It is independent to control the execution. That means, it may or may
not dependent on the condition.
Simple If:
Syntax:
=======
if(Cond)
{
statement;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter the Value For A : ");
scanf("%d",&a);
if(a>=0)
{
printf("The Value is Accepted.");
}
getch();
}
If...Else
Syntax:
========
if(cond)
{
statement 1;
}
else
{
statement 2;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the Value for A : ");
scanf("%d",&a);
printf("Enter the value for B : ");
scanf("%d",&b);
if(a>b)
{
printf("A is Big.");
}
else
{
printf("B is Big.");
}
getch();
}
If … Else If
Syntax:
=======
if(Cond 1)
{
Statement 1;
}
else if(cond 2)
{
statement 2;
}
:
:
else if(cond n)
{
statement n;
}
else
{
else_Statement;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter A,B,C : ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
{
printf("t%d is Big.",a);
}
else if(b>c)
{
printf("t%d is Big.",b);
}
else
{
printf("t%d is Big.",c);
}
getch();
}
Nested If
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter the A,B,C : ");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("A is Big");
}
else
{
printf("C is Big");
}
}
else
{
if(b>c)
{
printf("B is Big");
}
else
{
printf("C is Big");
}
}
getch();
}
Switch Case
Syntax:
======
switch(exp)
{
case value_1:
Statement 1;
break;
case value_2:
Statemnt 2;
break;
case Value_3:
Statement 3;
break;
:
:
case value_n:
Statement n;
break;
default:
default statement;
break;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter the Value for A : ");
scanf("%d",&a);
switch(a)
{
case 1:
printf("One");
break;
case 2:
printf("Two");
break;
case 3:
printf("Three");
break;
default:
printf("The Value is not between 1 and 3.");
break;
}
getch();
}
Nested Case
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
clrscr();
printf("Enter the Character : ");
scanf("%c",&c);
switch(c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("The Vowel in Small Letter.");
break;
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("The Vowel in Capital Letter.");
break;
default:
printf("Invalid Value.");
break;
}
getch();
}
Go to
Syntax:
=======
goto label
#include<stdio.h>
#include<conio.h>
main()
{
int i=0;
clrscr();
st:
i=i+1;
printf("i=%d",i);
if(i<10)
{
goto st;
}
getch();
}
C_Language_PS&PC_Notes.ppt
Loop:
Set of Statements reapeted continously till the given condition is satisfied.
Types
=====
1)Entry Control Loop
2)Exit Control Loop
Entry Control Loop:
===================
In the entry control loop, the given condition is checked first, if the condition is true then only the
statements are executed.
Example:
========
1)For
2)while
Exit Control Loop:
==================
In the exit control loop, the statements are executed once, then the condition is verified.
Example:
========
Do...while
Unary Operators
 These operators are frequently in loops.
++ Increment operator:
eg : i++(i=i+1)
Pre Increment:
At first the value of variable is incremented and then the
action is carried out.
Post Increment:
At first the action is carried out then the value is
Incremented.
-- Increment operator:
eg : i--(i=i-1)
Pre Decrement
At first the value of variable is decremented and then the
action is carried out.
Post Decrement
At first the action is carried out then the value is
decremented.
For
 It is an entry control loop.
Syntax:
=====
for(initialization;test_condition;increment/decrement)
{
Statements;
}
Initialization:
In this part, we initialize the value for the variable.
Test_condition:
In this part, the condition until which the loop is to be executed.
Increment / decrement:
Here, the variable is incremented or decremented to reach the
condition
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("i=%d",i);
}
getch();
}
while
 It is an entry control loop
Syntax:
====
While(condition)
{
Statements;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
i=0;
while(i<5)
{
printf("i=%d",i);
i=i+1;
}
getch();
}
Do … While
 It is an exit control loop
Syntax:
====
do
{
Statements;
}
while(cond);
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
do
{
printf("i=%d",i);
}
while(i<0);
getch();
}
C_Language_PS&PC_Notes.ppt
Arrays
 Group of elements stored under a common
name.
Types:
=====
1)Single Dimensional Array
2)Double Dimensional Array
Single Dimensional Array:
Syntax:
======
datatype variable_Name[Size];
initialization:
===============
1) During Declaration
2)Using Assignment Operator
2) In Runtime Through Scanf using loop
During Declaration
 datatype variable_name[size]={value};
#include<stdio.h>
#include<conio.h>
main()
{
int a[5]={23,43,45,34,23};
char c[5]={‘a’,’e’,’i’,’o’,’u’};
clrscr();
printf(“The value in the cell a[2]=%d",a[2]);
Printf(“nThe Character in the cell c[2]=%c”,c[2]);
getch();
}
Using Assignment(=) Operator
variable_name[cell]=value;
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3];
char c[3];
a[0]=1;
a[1]=2;
a[2]=3;
c[0]='a';
c[1]='b';
c[2]='c';
clrscr();
printf("The Value in the Cell a[2]=%d",a[2]);
printf("The Character in the cell a[2]=%c",a[2]);
getch();
}
In Runtime Through Scanf using loop
#include<stdio.h>
#include<conio.h>
main()
{
int a[5],i;
clrscr();
for(i=0;i<5;i++)
{
printf("nEnter the Value for Cell - %d :",i);
scanf("%d",&a[i]);
}
printf("nOutputn======");
for(i=0;i<5;i++)
{
printf("na[%d]=%d",i,a[i]);
}
printf("na[2]=%d",a[2]);
getch();
}
Practical Example
#include<stdio.h>
#include<conio.h>
main()
{
int reg[10],m1[10],m2[10],n;
int tot[10],i;
float avg[10];
clrscr();
printf("nEnter the No of Students:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("nEnter the Reg.No of Student - %d : ",i+1);
scanf("%d",&reg[i]);
printf("Enter the Mark1 of Student - %d : ",i+1);
scanf("%d",&m1[i]);
printf("Enter the Mark2 of Student - %d : ",i+1);
scanf("%d",&m2[i]);
}
printf("nnOutputn======");
for(i=0;i<n;i++)
{
printf("nnReg.No of Student - %d is : %d",i+1,reg[i]);
printf("nMark 1 of Student - %d is : %d",i+1,m1[i]);
printf("nMark 2 of Student - %d is : %d",i+1,m2[i]);
tot[i]=m1[i]+m2[i];
avg[i]=tot[i]/2;
printf("nTotal of Student - %d is : %d",i+1,tot[i]);
printf("nAvverage of Student - %d is : %f",i+1,avg[i]);
}
getch();
}
Two Dimensional Array
 Syntax:
======
datatype variable_name[size][size];
#include<stdio.h>
#include<conio.h>
main()
{
int a[25][25],b[25][25],c[25][25];
int i,j,row,clm;
clrscr();
printf("ntttMatrix Addition");
printf("nttt====== ========");
printf("nEnter the Number of Rows & Columns : ");
scanf("%d %d",&row,&clm);
printf("nnEnter the Matrix-1 Values.n");
for(i=0;i<row;i++)
{
for(j=0;j<clm;j++)
{
printf("Enter the Value for the Cell a[%d][%d] : ",i,j);
scanf("%d",&a[i][j]);
}
}
printf("nnEnter the Matrix-2 Values.n");
for(i=0;i<row;i++)
{
for(j=0;j<clm;j++)
{
printf("Enter the Value for the Cell b[%d][%d] : ",i,j);
scanf("%d",&b[i][j]);
}
}
printf("nOutputn======");
printf("nMatrix-1n");
for(i=0;i<row;i++)
{
for(j=0;j<clm;j++)
{
printf("t%dt",a[i][j]);
}
printf("n");
}
printf("nMatrix-2n");
for(i=0;i<row;i++)
{
for(j=0;j<clm;j++)
{
printf("t%dt",b[i][j]);
}
printf("n");
}
printf("nMatrix Addition isn");
for(i=0;i<row;i++)
{
for(j=0;j<clm;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("t%dt",c[i][j]);
}
printf("n");
}
getch();
}
C_Language_PS&PC_Notes.ppt
Pointers
 It is a variable which is used to access the
address of other variable.
Syntax:
=====
Datatype *variable_name
Example:
=====
int *ptr;
#include<stdio.h>
#include<conio.h>
void main()
{
int *ptr,a;
clrscr();
printf("Enter value for a :");
scanf("%d",&a);
ptr=&a;
printf("nThe Value of ptr : %u",ptr);
printf("nThe Value of *ptr : %d",*ptr);
getch();
}
Character Pointer
#include<stdio.h>
#include<conio.h>
void main()
{
char nam[]={"hello"};
char *ptr={"hello"};
clrscr();
printf("nName = %s",nam);
printf("n*ptr =%s",*ptr);
getch();
}
Pointer as Array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],*ptr[5],i;
clrscr();
for(i=0;i<5;i++)
{
printf("nEnter the Value for the cell a[%d] : ",i);
scanf("%d",&a[i]);
ptr[i]=&a[i];
}
printf("nOutputn======nn");
for(i=0;i<5;i++)
{
printf("nThe value of ptr : %u the value of *ptr : %d",ptr[i],*ptr[i]);
}
getch();
}
C_Language_PS&PC_Notes.ppt
Functions
It is a sub program in which set of executable statements are stored
under a name.
Whenever the statements are needed, instead of repeating the statements
the 'name' is called. The name in which the set of statements are
stored is called "Function".
Calling Function:
======= =========
The function which calls another function is called "Calling function"
Called Function:
====== =========
The function which is called by another function is called "Called Function"
Arguments:
==========
These are the Values passed to the called function from calling function.
The arguments in calling function is called "Actual Argument". The argument
in called function is caled "Formal Argument".
Return Value:
======= =====
Values return by the called function to the calling function.
Types
 Without Argument Without Return Value
 Without Argument With Return Value
 With Argument Without Return Value
 With Argument With Return Value
Without Argument Without Return Value
#include<stdio.h>
#include<conio.h>
void func()//called function
{
printf("nControl is inside the function, ");
printf("Hai, I am function");
}
void main()
{
clrscr();
printf("nThe Control is going inside the function.");
func(); //calling function
prnitf("nThe Control Came out of the function and Enter
main.");
getch();
}
Without Argument With Return Value
#include<stdio.h>
#include<conio.h>
int func()//called function
{
int x, y;
int z;
printf("Enter the value for x : ");
scanf("%d",&x);
printf("Enter the value for Y : ");
scanf("%d".&y);
z=x+y;
return z;
}
void main()
{
int c;
clrscr();
c=func(); //calling function
prnitf("nThe result is : %d",c);
getch();
}
With Argument Without Return Value
#include<stdio.h>
#include<conio.h>
void func(int x,int y)//called function
{
int z;
z=x+y;
prnitf("nThe result is : %d",z);
}
void main()
{
int a,b,c;
clrscr();
printf("Enter the value for a : ");
scanf("%d",&a);
printf("Enter the value for b : ");
scanf("%d".&b);
c=func(a,b); //calling function
getch();
}
With Argument With Return Value
#include<stdio.h>
#include<conio.h>
int func(int x,int y)//called function
{
int z;
z=x+y;
return z;
}
void main()
{
int a,b,c;
clrscr();
printf("Enter the value for a : ");
scanf("%d",&a);
printf("Enter the value for b : ");
scanf("%d".&b);
c=func(a,b); //calling function
prnitf("nThe result is : %d",c);
getch();
}
Global Variable
It is a variable which is commonly used by all the functions.
#include<stdio.h>
#include<conio.h>
int g=10;
void func()//called function
{
printf("nThe Control is inside functionn");
printf("ng=%d",g);
}
void main()
{
printf("nThe Control is in side the main");
printf("ng=%d",g);
func();
g=g+10;
func();
getch();
}
Recursive Function
When a function calls itself then it is said to be recursive function.
#include<stdio.h>
#include<conio.h>
rec(int n)//Called function
{
if(n>=0)
{
printf(“nn=%d”,n);
rec(n-1);
}
else
return 0;
}
void main()
{
int a=5;
clrscr();
rec(a);//Calling function
getch();
}
String Functions
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s1[20],s2[20];
clrscr();
printf("Enter S1 : ");
scanf("%s",&s1);
printf("Enter S2 : ");
scanf("%s",&s2);
printf("strrev(s1) : %s",strrev(s1)); //To reverse a string
printf("nStrlen(s1) : %d",strlen(s1));//to find the length of the string
printf("nStrupr(s1) : %s",strupr(s1));//to convert the string to upper case
printf("nStrlwr(s1) : %s",strlwr(s1));//to convert the string to lower case
printf("nstrcmp(s1,s2) : %d",strcmp(s1,s2));//to compare the string s2 with s1
and retun the result
printf("nstrcpmi(s1,s2) : %d",strcmpi(s1,s2));//to compare the string s2 with s1
by not taking the case and retun
the result
printf("nstrcat(s1,s2) : %s",strcat(s1,s2));//to join the two strings
getch();
}
C_Language_PS&PC_Notes.ppt
Structure
It is a collection of different items.
Syntax:
=======
struct structure_name
{
datatype 1 member 1;
datatype 2 member 2;
:
:
datatype n member n;
};
struct structure_name structure_variable;
structure_variable.member;
#include<stdio.h>
#include<conio.h>
struct stu
{
int rno;
char name[25];
int eng,tam,mat,sci,cs;
int tot;
float avg;
};
void main()
{
struct stu s;
clrscr();
printf("Enter the Rno :");
scanf("%d",&s.rno);
printf("Enter the Name : ");
scanf("%s",&s.name);
printf("Enter the English Mark : ");
scanf("%d",&s.eng);
printf("Enter the Tamil Mark : ");
scanf("%d",&s.tam);
printf("Enter the maths Mark : ");
scanf("%d",&s.mat);
printf("Enter the Science Mark : ");
scanf("%d",&s.sci);
printf("Enter the CS Mark :");
scanf("%d",&s.cs);
s.tot=s.eng+s.tam+s.mat+s.sci+s.cs;
s.avg=(float)s.tot/5;
clrscr();
printf("nOutputn======");
printf("nRno is : %d",s.rno);
printf("nName is : %s",s.name);
printf("nEnglish : %d",s.eng);
printf("nTamil : %d",s.tam);
printf("nMaths : %d",s.mat);
printf("nSCience : %d",s.sci);
printf("nCS : %d",s.cs);
printf("nTotal : %d",s.tot);
printf("nAverage : %f",s.avg);
getch();
}
Structure as array
#include<stdio.h>
#include<conio.h>
struct stu
{
int rno;
char name[25];
int eng,tam,mat,sci,cs;
int tot;
float avg;
};
void main()
{
struct stu s[3];
int i;
clrscr();
for(i=0;i<2;i++)
{
printf("nnEnter the Details of Student - %dn",i+1)
printf("Enter the Rno :");
scanf("%d",&s[i].rno);
printf("Enter the Name : ");
scanf("%s",&s[i].name);
printf("Enter the English Mark : ");
scanf("%d",&s[i].eng);
printf("Enter the Tamil Mark : ");
scanf("%d",&s[i].tam);
printf("Enter the maths Mark : ");
scanf("%d",&s[i].mat);
printf("Enter the Science Mark : ");
scanf("%d",&s[i].sci);
printf("Enter the CS Mark :");
scanf("%d",&s[i].cs);
s[i].tot=s[i].eng+s[i].tam+s[i].mat+s[i].sci+s[i].cs;
s[i].avg=(float)s[i].tot/5;
}
clrscr();
printf("nOutputn======");
for(i=0;i<3;i++)
{
printf("nnThe Details of student - %d",i+1)
printf("nRno is : %d",s[i].rno);
printf("nName is : %s",s[i].name);
printf("nEnglish : %d",s[i].eng);
printf("nTamil : %d",s[i].tam);
printf("nMaths : %d",s[i].mat);
printf("nSCience : %d",s[i].sci);
printf("nCS : %d",s[i].cs);
printf("nTotal : %d",s[i].tot);
printf("nAverage : %f",s[i].avg);
}
getch();
}
C_Language_PS&PC_Notes.ppt
File Handlings
 File is a place where we can store the data
permanently
 There are many ways to handle a file, in that we
are going to see about
1) How to write the data to the file
2) How to read the data from the file
Writing to File
#include<stdio.h>
#include<conio.h>
void main()
{
char str;
FILE *fptr;
clrscr();
fptr=fopen("test1.txt","w");
printf("Enter The Text and Press ^ to stop.");
do
{
str=getchar();
putc(str,fptr);
}
while(str!='^');
getch();
}
Reading From File
#include<stdio.h>
#include<conio.h>
void main()
{
char str;
FILE *fptr;
clrscr();
fptr=fopen("arun.txt","r");
str=getc(fptr);
while(str!=EOF)
{
putchar(str);
str=getc(fptr);
}
getch();
}

More Related Content

Similar to C_Language_PS&PC_Notes.ppt (20)

PPT
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
yatakonakiran2
 
PPTX
C programming language
Abin Rimal
 
PDF
C programing Tutorial
Mahira Banu
 
PPT
c-programming
Zulhazmi Harith
 
PDF
Workbook_2_Problem_Solving_and_programming.pdf
DrDineshenScientist
 
PPT
The smartpath information systems c pro
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
PPTX
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
PPTX
C Programming - Basics of c -history of c
DHIVYAB17
 
ODP
Programming basics
Bipin Adhikari
 
PPTX
Review of C programming language.pptx...
SthitaprajnaLenka1
 
PDF
Introduction of c language
farishah
 
PPTX
1 introduction to c program
NishmaNJ
 
PPTX
C Programming with oops Concept and Pointer
Jeyarajs7
 
DOCX
UNIT-II CP DOC.docx
JavvajiVenkat
 
PDF
C programming session3
Keroles karam khalil
 
PDF
C programming session3
Keroles karam khalil
 
PPTX
Overview of C Mrs Sowmya Jyothi
Sowmya Jyothi
 
PPT
Introduction to C Programming
MOHAMAD NOH AHMAD
 
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
yatakonakiran2
 
C programming language
Abin Rimal
 
C programing Tutorial
Mahira Banu
 
c-programming
Zulhazmi Harith
 
Workbook_2_Problem_Solving_and_programming.pdf
DrDineshenScientist
 
The smartpath information systems c pro
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
C Programming - Basics of c -history of c
DHIVYAB17
 
Programming basics
Bipin Adhikari
 
Review of C programming language.pptx...
SthitaprajnaLenka1
 
Introduction of c language
farishah
 
1 introduction to c program
NishmaNJ
 
C Programming with oops Concept and Pointer
Jeyarajs7
 
UNIT-II CP DOC.docx
JavvajiVenkat
 
C programming session3
Keroles karam khalil
 
C programming session3
Keroles karam khalil
 
Overview of C Mrs Sowmya Jyothi
Sowmya Jyothi
 
Introduction to C Programming
MOHAMAD NOH AHMAD
 

More from ganeshkarthy (15)

PPT
Java ppt-class_basic data types methods definitions
ganeshkarthy
 
PPT
Basic coding skills_python and its applications
ganeshkarthy
 
PPTX
Lecture-5-Linear Regression-Tutorials.PPTX
ganeshkarthy
 
PPTX
Lecture-5-Linear Regression-Tutorials.PPTX
ganeshkarthy
 
PPTX
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
ganeshkarthy
 
PPTX
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
ganeshkarthy
 
PDF
CLOUD_COMPUTING_UNIT_2.pdf
ganeshkarthy
 
PDF
CLOUD_COMPUTING_UNIT_1.pdf
ganeshkarthy
 
PPTX
S16_Notes_CC.pptx
ganeshkarthy
 
PPTX
Asynchronous Frameworks.pptx
ganeshkarthy
 
PPT
Green computing PPT Notes.ppt
ganeshkarthy
 
PPT
OOPS(CS8392)_Unit-I_Notes.ppt
ganeshkarthy
 
PPT
Unit-II(STATIC UML DIAGRAMS).ppt
ganeshkarthy
 
DOCX
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
ganeshkarthy
 
PDF
Unit-1_Notes(OOAD).pdf
ganeshkarthy
 
Java ppt-class_basic data types methods definitions
ganeshkarthy
 
Basic coding skills_python and its applications
ganeshkarthy
 
Lecture-5-Linear Regression-Tutorials.PPTX
ganeshkarthy
 
Lecture-5-Linear Regression-Tutorials.PPTX
ganeshkarthy
 
Lecture-6-Linear Regression-Gradient Descent-Tutorials.PPTX
ganeshkarthy
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
ganeshkarthy
 
CLOUD_COMPUTING_UNIT_2.pdf
ganeshkarthy
 
CLOUD_COMPUTING_UNIT_1.pdf
ganeshkarthy
 
S16_Notes_CC.pptx
ganeshkarthy
 
Asynchronous Frameworks.pptx
ganeshkarthy
 
Green computing PPT Notes.ppt
ganeshkarthy
 
OOPS(CS8392)_Unit-I_Notes.ppt
ganeshkarthy
 
Unit-II(STATIC UML DIAGRAMS).ppt
ganeshkarthy
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.docx
ganeshkarthy
 
Unit-1_Notes(OOAD).pdf
ganeshkarthy
 

Recently uploaded (20)

PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Design Thinking basics for Engineers.pdf
CMR University
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 

C_Language_PS&PC_Notes.ppt

  • 2. C ~ Language Introduction The Language is a software which is used to communicate with the computer for doing certain process. The language must have a compiler and do an operation. Origin  C – Language was created by Denise Ritchie and Brain Kernighan in Bell Laboratories  The Language available before the invention of C is B – Language, created by Ken Thompson. B leds to the development of C in 1970’s. The ANSI(American National Standard Institute) C standard was finally adopted in December 1989. C is a middle level language, because it combines the best elements of high level language with control and flexibility of assembly language. It is a case sensitive language.
  • 3. C ~ Structure Documentation Section Link Section Definition Section Global Declaration return_type main(argumentlist) { variable declarations; Statements; } Sub Function Function 1 Function 2 : : Function n
  • 4. Explanation  Documentation Section – This is used to provide some meaningful information about the program.  Link Section - In this section we include the header files whose functions are used in the program. Eg : #include<stdio.h>  Definition Section – In this section we use the Symbolic Constants Eg : # PI 3.14  Global Declaration – In this section we declare the variable which is going to used are accessed by any where in the program.  Main – This contains the coding (variable, statements) which are going to be executed. Eg: printf().  Function 1 … Function n – Sub functions which are used in the programs.
  • 5. Steps to do a Program. Going to the C Editor.  Click Start Run (Type) Command. Then the command prompt will be appear. In that  Type as follows cd cd tc tc
  • 6. In the Editor  To create a new file. Click File  New  To save a file Click File  Save(F2) Type the file name with the extension as .c Eg: Test.c  To open a file Click File Open(F3)  To Quit Click File Quit  To Compile file to see the errors Click Compile Compile(Alt+F9)  To run or execute a file to see the output Click Run Run(ctrl+F9)
  • 7. Escape Sequence The escape sequence are used to format the statements which are going to be displayed on the screen. The most frequently used escape sequence are:  n – This is used to produce new line while display  t – This is used to produce tab while display.
  • 8. Simple Program /* Simple Program */ Document section #include<stdio.h> Link Section #include<conio.h> void main() { clrscr(); printf("*"); printf("n Hai"); getch(); }
  • 9. Comment Line The Comment Line Symbols are used to make the compiler not to execute. When a line is declared as comments, It will not be executed by Compiler. The types of Comments are :  Single Line Comment – ( //… ) It used to make a single line as a comment  Multi Line Comment – (/* … */) It is used to make more than one line as a comment
  • 10. Variables & Constants Variables  These are the locations in the memory in which the given values are stored.  The values which can be changed during the execution of the program. Constants:  The values which cannot be changed during the execution of the program.
  • 11. Data types This will indicate the type of the value which is going to be stored in the variable. Data type Delimiter ====== ====== char %s,%c int %d long int %ld float %f double %lf boolean --
  • 12. Operators These are used to do certain operations. The types of operators are as follows.  Arithmetic Operators: These are used to do arithmetic operations. It consist of two operands. + This is used to do addition operation. - This is used to do subtraction operation. * This is used to do Multiplication Operation. / This is used to do Division operation and return “quotient” as result % This is used to do division operation and return “Remainder” as result.
  • 13.  Relational Operators: These are used to do the relational operation. It can be the combination of two arithmetic expression. > Greater than < Less than >= Greater than or Equal to <= Less than or Equal to != Not Equal to  Logical Operators: These are used to do the logical operation. It can contain two relational expression. & And || or ! not
  • 14. Example Program #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); a=5; b=5; c=a+b; printf("C is : %d",c); getch(); }
  • 16. Control Statements These are used to control the execution of the program. Control Statements Conditional Unconditional Two Way Branching Multi Way Branching Go to Simple … If If … Else If … Else If Switch Case  Conditional Control Statement: Based on the given the execution of the program is controlled.  Uncnditional Control Statement: It is independent to control the execution. That means, it may or may not dependent on the condition.
  • 17. Simple If: Syntax: ======= if(Cond) { statement; } #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("Enter the Value For A : "); scanf("%d",&a); if(a>=0) { printf("The Value is Accepted."); } getch(); }
  • 19. #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter the Value for A : "); scanf("%d",&a); printf("Enter the value for B : "); scanf("%d",&b); if(a>b) { printf("A is Big."); } else { printf("B is Big."); } getch(); }
  • 20. If … Else If Syntax: ======= if(Cond 1) { Statement 1; } else if(cond 2) { statement 2; } : : else if(cond n) { statement n; } else { else_Statement; }
  • 21. #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter A,B,C : "); scanf("%d%d%d",&a,&b,&c); if(a>b && a>c) { printf("t%d is Big.",a); } else if(b>c) { printf("t%d is Big.",b); } else { printf("t%d is Big.",c); } getch(); }
  • 22. Nested If #include<stdio.h> #include<conio.h> main() { int a,b,c; clrscr(); printf("Enter the A,B,C : "); scanf("%d%d%d",&a,&b,&c); if(a>b) { if(a>c) { printf("A is Big"); } else { printf("C is Big"); } } else { if(b>c) { printf("B is Big"); } else { printf("C is Big"); } } getch(); }
  • 23. Switch Case Syntax: ====== switch(exp) { case value_1: Statement 1; break; case value_2: Statemnt 2; break; case Value_3: Statement 3; break; : : case value_n: Statement n; break; default: default statement; break; }
  • 24. #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("Enter the Value for A : "); scanf("%d",&a); switch(a) { case 1: printf("One"); break; case 2: printf("Two"); break; case 3: printf("Three"); break; default: printf("The Value is not between 1 and 3."); break; } getch(); }
  • 25. Nested Case #include<stdio.h> #include<conio.h> void main() { char c; clrscr(); printf("Enter the Character : "); scanf("%c",&c); switch(c) { case 'a': case 'e': case 'i': case 'o': case 'u': printf("The Vowel in Small Letter."); break; case 'A': case 'E': case 'I': case 'O': case 'U': printf("The Vowel in Capital Letter."); break; default: printf("Invalid Value."); break; } getch(); }
  • 26. Go to Syntax: ======= goto label #include<stdio.h> #include<conio.h> main() { int i=0; clrscr(); st: i=i+1; printf("i=%d",i); if(i<10) { goto st; } getch(); }
  • 28. Loop: Set of Statements reapeted continously till the given condition is satisfied. Types ===== 1)Entry Control Loop 2)Exit Control Loop Entry Control Loop: =================== In the entry control loop, the given condition is checked first, if the condition is true then only the statements are executed. Example: ======== 1)For 2)while Exit Control Loop: ================== In the exit control loop, the statements are executed once, then the condition is verified. Example: ======== Do...while
  • 29. Unary Operators  These operators are frequently in loops. ++ Increment operator: eg : i++(i=i+1) Pre Increment: At first the value of variable is incremented and then the action is carried out. Post Increment: At first the action is carried out then the value is Incremented. -- Increment operator: eg : i--(i=i-1) Pre Decrement At first the value of variable is decremented and then the action is carried out. Post Decrement At first the action is carried out then the value is decremented.
  • 30. For  It is an entry control loop. Syntax: ===== for(initialization;test_condition;increment/decrement) { Statements; } Initialization: In this part, we initialize the value for the variable. Test_condition: In this part, the condition until which the loop is to be executed. Increment / decrement: Here, the variable is incremented or decremented to reach the condition
  • 32. while  It is an entry control loop Syntax: ==== While(condition) { Statements; }
  • 34. Do … While  It is an exit control loop Syntax: ==== do { Statements; } while(cond);
  • 37. Arrays  Group of elements stored under a common name. Types: ===== 1)Single Dimensional Array 2)Double Dimensional Array
  • 38. Single Dimensional Array: Syntax: ====== datatype variable_Name[Size]; initialization: =============== 1) During Declaration 2)Using Assignment Operator 2) In Runtime Through Scanf using loop
  • 39. During Declaration  datatype variable_name[size]={value}; #include<stdio.h> #include<conio.h> main() { int a[5]={23,43,45,34,23}; char c[5]={‘a’,’e’,’i’,’o’,’u’}; clrscr(); printf(“The value in the cell a[2]=%d",a[2]); Printf(“nThe Character in the cell c[2]=%c”,c[2]); getch(); }
  • 40. Using Assignment(=) Operator variable_name[cell]=value; #include<stdio.h> #include<conio.h> void main() { int a[3]; char c[3]; a[0]=1; a[1]=2; a[2]=3; c[0]='a'; c[1]='b'; c[2]='c'; clrscr(); printf("The Value in the Cell a[2]=%d",a[2]); printf("The Character in the cell a[2]=%c",a[2]); getch(); }
  • 41. In Runtime Through Scanf using loop #include<stdio.h> #include<conio.h> main() { int a[5],i; clrscr(); for(i=0;i<5;i++) { printf("nEnter the Value for Cell - %d :",i); scanf("%d",&a[i]); } printf("nOutputn======"); for(i=0;i<5;i++) { printf("na[%d]=%d",i,a[i]); } printf("na[2]=%d",a[2]); getch(); }
  • 42. Practical Example #include<stdio.h> #include<conio.h> main() { int reg[10],m1[10],m2[10],n; int tot[10],i; float avg[10]; clrscr(); printf("nEnter the No of Students:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("nEnter the Reg.No of Student - %d : ",i+1); scanf("%d",&reg[i]); printf("Enter the Mark1 of Student - %d : ",i+1); scanf("%d",&m1[i]); printf("Enter the Mark2 of Student - %d : ",i+1); scanf("%d",&m2[i]); } printf("nnOutputn======"); for(i=0;i<n;i++) { printf("nnReg.No of Student - %d is : %d",i+1,reg[i]); printf("nMark 1 of Student - %d is : %d",i+1,m1[i]); printf("nMark 2 of Student - %d is : %d",i+1,m2[i]); tot[i]=m1[i]+m2[i]; avg[i]=tot[i]/2; printf("nTotal of Student - %d is : %d",i+1,tot[i]); printf("nAvverage of Student - %d is : %f",i+1,avg[i]); } getch(); }
  • 43. Two Dimensional Array  Syntax: ====== datatype variable_name[size][size]; #include<stdio.h> #include<conio.h> main() { int a[25][25],b[25][25],c[25][25]; int i,j,row,clm; clrscr(); printf("ntttMatrix Addition"); printf("nttt====== ========"); printf("nEnter the Number of Rows & Columns : "); scanf("%d %d",&row,&clm); printf("nnEnter the Matrix-1 Values.n");
  • 44. for(i=0;i<row;i++) { for(j=0;j<clm;j++) { printf("Enter the Value for the Cell a[%d][%d] : ",i,j); scanf("%d",&a[i][j]); } } printf("nnEnter the Matrix-2 Values.n"); for(i=0;i<row;i++) { for(j=0;j<clm;j++) { printf("Enter the Value for the Cell b[%d][%d] : ",i,j); scanf("%d",&b[i][j]); } } printf("nOutputn======"); printf("nMatrix-1n"); for(i=0;i<row;i++) { for(j=0;j<clm;j++) { printf("t%dt",a[i][j]); } printf("n"); }
  • 47. Pointers  It is a variable which is used to access the address of other variable. Syntax: ===== Datatype *variable_name Example: ===== int *ptr;
  • 48. #include<stdio.h> #include<conio.h> void main() { int *ptr,a; clrscr(); printf("Enter value for a :"); scanf("%d",&a); ptr=&a; printf("nThe Value of ptr : %u",ptr); printf("nThe Value of *ptr : %d",*ptr); getch(); }
  • 49. Character Pointer #include<stdio.h> #include<conio.h> void main() { char nam[]={"hello"}; char *ptr={"hello"}; clrscr(); printf("nName = %s",nam); printf("n*ptr =%s",*ptr); getch(); }
  • 50. Pointer as Array #include<stdio.h> #include<conio.h> void main() { int a[5],*ptr[5],i; clrscr(); for(i=0;i<5;i++) { printf("nEnter the Value for the cell a[%d] : ",i); scanf("%d",&a[i]); ptr[i]=&a[i]; } printf("nOutputn======nn"); for(i=0;i<5;i++) { printf("nThe value of ptr : %u the value of *ptr : %d",ptr[i],*ptr[i]); } getch(); }
  • 52. Functions It is a sub program in which set of executable statements are stored under a name. Whenever the statements are needed, instead of repeating the statements the 'name' is called. The name in which the set of statements are stored is called "Function". Calling Function: ======= ========= The function which calls another function is called "Calling function" Called Function: ====== ========= The function which is called by another function is called "Called Function" Arguments: ========== These are the Values passed to the called function from calling function. The arguments in calling function is called "Actual Argument". The argument in called function is caled "Formal Argument". Return Value: ======= ===== Values return by the called function to the calling function.
  • 53. Types  Without Argument Without Return Value  Without Argument With Return Value  With Argument Without Return Value  With Argument With Return Value
  • 54. Without Argument Without Return Value #include<stdio.h> #include<conio.h> void func()//called function { printf("nControl is inside the function, "); printf("Hai, I am function"); } void main() { clrscr(); printf("nThe Control is going inside the function."); func(); //calling function prnitf("nThe Control Came out of the function and Enter main."); getch(); }
  • 55. Without Argument With Return Value #include<stdio.h> #include<conio.h> int func()//called function { int x, y; int z; printf("Enter the value for x : "); scanf("%d",&x); printf("Enter the value for Y : "); scanf("%d".&y); z=x+y; return z; } void main() { int c; clrscr(); c=func(); //calling function prnitf("nThe result is : %d",c); getch(); }
  • 56. With Argument Without Return Value #include<stdio.h> #include<conio.h> void func(int x,int y)//called function { int z; z=x+y; prnitf("nThe result is : %d",z); } void main() { int a,b,c; clrscr(); printf("Enter the value for a : "); scanf("%d",&a); printf("Enter the value for b : "); scanf("%d".&b); c=func(a,b); //calling function getch(); }
  • 57. With Argument With Return Value #include<stdio.h> #include<conio.h> int func(int x,int y)//called function { int z; z=x+y; return z; } void main() { int a,b,c; clrscr(); printf("Enter the value for a : "); scanf("%d",&a); printf("Enter the value for b : "); scanf("%d".&b); c=func(a,b); //calling function prnitf("nThe result is : %d",c); getch(); }
  • 58. Global Variable It is a variable which is commonly used by all the functions. #include<stdio.h> #include<conio.h> int g=10; void func()//called function { printf("nThe Control is inside functionn"); printf("ng=%d",g); } void main() { printf("nThe Control is in side the main"); printf("ng=%d",g); func(); g=g+10; func(); getch(); }
  • 59. Recursive Function When a function calls itself then it is said to be recursive function. #include<stdio.h> #include<conio.h> rec(int n)//Called function { if(n>=0) { printf(“nn=%d”,n); rec(n-1); } else return 0; } void main() { int a=5; clrscr(); rec(a);//Calling function getch(); }
  • 60. String Functions #include<stdio.h> #include<conio.h> #include<string.h> void main() { char s1[20],s2[20]; clrscr(); printf("Enter S1 : "); scanf("%s",&s1); printf("Enter S2 : "); scanf("%s",&s2); printf("strrev(s1) : %s",strrev(s1)); //To reverse a string printf("nStrlen(s1) : %d",strlen(s1));//to find the length of the string printf("nStrupr(s1) : %s",strupr(s1));//to convert the string to upper case printf("nStrlwr(s1) : %s",strlwr(s1));//to convert the string to lower case printf("nstrcmp(s1,s2) : %d",strcmp(s1,s2));//to compare the string s2 with s1 and retun the result printf("nstrcpmi(s1,s2) : %d",strcmpi(s1,s2));//to compare the string s2 with s1 by not taking the case and retun the result printf("nstrcat(s1,s2) : %s",strcat(s1,s2));//to join the two strings getch(); }
  • 62. Structure It is a collection of different items. Syntax: ======= struct structure_name { datatype 1 member 1; datatype 2 member 2; : : datatype n member n; }; struct structure_name structure_variable; structure_variable.member;
  • 63. #include<stdio.h> #include<conio.h> struct stu { int rno; char name[25]; int eng,tam,mat,sci,cs; int tot; float avg; }; void main() { struct stu s; clrscr(); printf("Enter the Rno :"); scanf("%d",&s.rno); printf("Enter the Name : "); scanf("%s",&s.name); printf("Enter the English Mark : "); scanf("%d",&s.eng); printf("Enter the Tamil Mark : "); scanf("%d",&s.tam); printf("Enter the maths Mark : "); scanf("%d",&s.mat); printf("Enter the Science Mark : "); scanf("%d",&s.sci); printf("Enter the CS Mark :"); scanf("%d",&s.cs);
  • 64. s.tot=s.eng+s.tam+s.mat+s.sci+s.cs; s.avg=(float)s.tot/5; clrscr(); printf("nOutputn======"); printf("nRno is : %d",s.rno); printf("nName is : %s",s.name); printf("nEnglish : %d",s.eng); printf("nTamil : %d",s.tam); printf("nMaths : %d",s.mat); printf("nSCience : %d",s.sci); printf("nCS : %d",s.cs); printf("nTotal : %d",s.tot); printf("nAverage : %f",s.avg); getch(); }
  • 65. Structure as array #include<stdio.h> #include<conio.h> struct stu { int rno; char name[25]; int eng,tam,mat,sci,cs; int tot; float avg; }; void main() { struct stu s[3]; int i; clrscr(); for(i=0;i<2;i++) { printf("nnEnter the Details of Student - %dn",i+1) printf("Enter the Rno :"); scanf("%d",&s[i].rno); printf("Enter the Name : "); scanf("%s",&s[i].name); printf("Enter the English Mark : "); scanf("%d",&s[i].eng); printf("Enter the Tamil Mark : "); scanf("%d",&s[i].tam); printf("Enter the maths Mark : "); scanf("%d",&s[i].mat); printf("Enter the Science Mark : "); scanf("%d",&s[i].sci); printf("Enter the CS Mark :"); scanf("%d",&s[i].cs); s[i].tot=s[i].eng+s[i].tam+s[i].mat+s[i].sci+s[i].cs; s[i].avg=(float)s[i].tot/5; } clrscr();
  • 66. printf("nOutputn======"); for(i=0;i<3;i++) { printf("nnThe Details of student - %d",i+1) printf("nRno is : %d",s[i].rno); printf("nName is : %s",s[i].name); printf("nEnglish : %d",s[i].eng); printf("nTamil : %d",s[i].tam); printf("nMaths : %d",s[i].mat); printf("nSCience : %d",s[i].sci); printf("nCS : %d",s[i].cs); printf("nTotal : %d",s[i].tot); printf("nAverage : %f",s[i].avg); } getch(); }
  • 68. File Handlings  File is a place where we can store the data permanently  There are many ways to handle a file, in that we are going to see about 1) How to write the data to the file 2) How to read the data from the file
  • 69. Writing to File #include<stdio.h> #include<conio.h> void main() { char str; FILE *fptr; clrscr(); fptr=fopen("test1.txt","w"); printf("Enter The Text and Press ^ to stop."); do { str=getchar(); putc(str,fptr); } while(str!='^'); getch(); }
  • 70. Reading From File #include<stdio.h> #include<conio.h> void main() { char str; FILE *fptr; clrscr(); fptr=fopen("arun.txt","r"); str=getc(fptr); while(str!=EOF) { putchar(str); str=getc(fptr); } getch(); }