SlideShare a Scribd company logo
PAPER: INTRODUCTION PROGRAMMING LANGUAGE USING C
PAPER ID: 20105
PAPER CODE: BCA 105
DR. VARUN TIWARI
(ASSOCIATE PROFESSOR)
(DEPARTMENT OF COMPUTER SCIENCE)
BOSCO TECHNICAL TRAINING SOCIETY,
DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
STRING MANIPULATION FUNCTION
& C HEADER FILE FUNCTION
OBJECTIVES
IN THIS CHAPTER YOU WILL LEARN:
1. TO UNDERSTAND ABOUT STDIO.H IN C.
2. TO LEARN ABOUT MATH.H IN C.
3. TO LEARN ABOUT CTYPE.H IN C.
4. TO UNDERSTAND STDLIB.H IN C.
5. TO LEARN ABOUT CONIO.H IN C.
6. TO LEARN ABOUT STRING.H IN C.
7. TO LEARN ABOUT PROCESS.H IN C.
STDIO.H:
Function Description
printf()
It is used to print the character, string, float, integer, octal and
hexadecimal values onto the output screen.
scanf() It is used to read a character, string, numeric data from keyboard.
gets() It reads line from keyboard
puts() It writes line to output screen
fopen() fopen() is used to open a file in different mode
fclose() closes an opened file
getw() reads an integer from file
putw() writes an integer to file
EXAMPLE PRINTF AND SCANF
#include <stdio.h>
void main()
{
int a;
printf(“Enter any number-:");
scanf(“%d”,&a);
printf(“output is -:%d”,a);
}
EXAMPLE FOPEN AND FCLOSE
FOPEN FUNCTION IS USED TO OPENING A FILE IN DIFFERENT MODES AND FCLOSE FUNCTION IS USED
TO CLOSING A FILE.
#include<stdio.h>
void main(){
FILE *a;
a = fopen("file.txt", "w");//opening file
fprintf(a, "Hello how r u.n");//writing data into file
fclose(a);//closing file
}
EXAMPLE GETS AND PUTS
GETS() FUNCTION IS USED TO READS STRING FROM USER AND PUTS() FUNCTION IS USED TO PRINT THE STRING.
#include<stdio.h>
#include<conio.h>
void main(){
char n[25];
clrscr();
printf("enter your name: ");
gets(n);
printf("your name is: ");
puts(n);
getch(); }
EXAMPLE OF GETW() AND PUTW()
GETW() FUNCTION IS USED TO READ A INTEGER VALUE FROM A FILE AND PUTW() IS USED TO WRITE AN INTEGER VALUE FROM A FILE.
#include <stdio.h>
void main () {
FILE *f;
int a,n;
clrscr();
f = fopen ("bcd1.txt","w");
for(a=1;a<=10;a++) {
putw(a,f); }
fclose(f);
f = fopen ("bcd1.txt","r");
while((n=getw(f))!=EOF)
{ printf("n Output is-: %d n", n);} fclose(f); getch(); }
MATH.H:
Function Function Description
ceil It returns nearest integer greater than argument passed.
cos It is used to computes the cosine of the argument
exp It is used to computes the exponential raised to given power
floor Returns nearest integer lower than the argument passed.
log Computes natural logarithm
log10 Computes logarithm of base argument 10
pow Computes the number raised to given power
sin Computes sine of the argument
sqrt Computes square root of the argument
tan Computes tangent of the argument
EXAMPLE OF CUBE() , CEIL() , EXP() AND COS()
#include <stdio.h> #include <math.h>
#define pi 3.1415
void main()
{ double n =4.6,a=24.0,res; clrscr();
res = ceil(n);
printf("n ceiling integer of %.2f = %.2f", n, res);
a = (a * pi) / 180;
res = cos(a);
printf("n cos value of is %lf radian = %lf", a, res);
res = exp(n);
printf("n exponential of %lf = %lf", n, res); getch(); }
EXAMPLE OF POW, LOG, FLOOR AND LOG10
#include <stdio.h>
#include <math.h>
void main()
{ double n = 4.7,p=-9.33,res,b=3,po=4; clrscr();
res = pow(b,po);
printf("n %lf ^ %lf = %lf", b, po, res);
res = log(n);
printf("n log value is %f = %f", n, res);
res = floor(p);
printf("n floor integer of %.2f = %.2f", p, res);
res = log10(n);
printf("n log10 value is %f = %f", n, res);
getch(); }
Example of sin(), sqrt() and tan() in c.
#include <stdio.h>
#include <math.h>
void main()
{ double n = 4.7,sr,res;
clrscr();
res = sin(n);
printf("n sin value is -: %lf = %lf", n, res);
sr = sqrt(n);
printf("n square root of %lf = %lf", n, sr);
res = tan(n);
printf("n tan value is -: %lf = %lf", n, res); getch(); }
CONIO.H:
Function Function Description
clrscr() This function is used to clear the output screen.
getch()
This function is used to hold the screen until any character not press from
keyboard
textcolor() This function is used to define text color.
textbackground() This function is used to define background color of the text.
getche() It is used to get a character from the console and echoes to the screen.
Example of getch(),getche()
void main()
{
char c;
int p;
printf( "Press any keyn" );
c = getche();
printf( "You pressed %c(%d)n", c, c );
c = getch();
printf("Input Char Is :%c",c);
getch();
}
Example of clrscr(), textcolor() and textbackground()
#include<conio.h>
void main()
{ int i;
clrscr();
for(i=0; i<=15; i++)
{ textcolor(i);
textbackground(10-i);
cprintf("Bosco Technical Training Society");
cprintf("rn"); }
getch(); }
CTYPE.H:
Function Function Description
isalnum Tests whether a character is alphanumeric or not
isalpha Tests whether a character is alphabetic or not
iscntrl Tests whether a character is control or not
isdigit Tests whether a character is digit or not
islower Tests whether a character is lowercase or not
ispunct Tests whether a character is punctuation or not
isspace Tests whether a character is white space or not
isupper Tests whether a character is uppercase or not
tolower Converts to lowercase if the character is in uppercase
toupper Converts to uppercase if the character is in lowercase
Example of iscntrl() , isdigit() , isupper(),
islower()
#include <stdio.h> #include <ctype.h>
void main() { char c='n';
char p; char q,r; clrscr();
if(iscntrl(c)) printf("n u entered control value"); else printf("n not a control character");
printf("n enter any numeric value"); scanf("%c",&p);
if(isdigit(p)) printf("n entered value is digit"); else printf("n not digit");
q='a'; if(islower(q)) printf("n entered value is lower"); else printf("n not lower");
printf("n");
r='p'; if(isupper(r)) printf("n entered value is upper"); else printf("n not upper");
getch();
}
Example of isalnum() , isalpha() , ispunct(),
isspace()
#include <stdio.h> #include <ctype.h>
void main() { char c='c'; char p;
char q,r; clrscr();
if(isalpha(c)) printf("n u entered alphabetic value"); else printf("n Not an Alphabet");
printf("n Enter any numeric value"); scanf("%c",&p); if(isalnum(p))
printf("n Entered value is alphanumeric"); else printf("n Not alphanumeric");
q=' '; if(isspace(q)) printf("n Space is here"); else printf("n Space is not here"); printf("n");
r=':'; if(ispunct(r)) printf("n Entered value is punctuation"); else printf("n Not Punctuation");
getch(); }
Example of ispunct() , isspace() , isupper(), tolower() and toupper()
#include <stdio.h>
#include <ctype.h>
void main()
{ char c;
c = 'M'; res = tolower(c); printf("tolower is -: %c = %c n",
c, res);
c = 'h'; res = toupper(c); printf("toupper is-: %c = %c n", c,
res);
getch();}
STRING.H:
Function Function Description
strlen() computes string's length
strcpy() copies a string to another
strcat() concatenates(joins) two strings
strcmp() compares two strings
strlwr() converts string to lowercase
strupr() converts string to uppercase
Example of all string function
#include <stdio.h> #include <string.h>
void main() {
char a[20]="java"; char b[20]="program"; char c[20]; int res,d,g;
char s1[] = "vivek", s2[] = "viVek", s3[] = "vivek"; char q[40];
clrscr(); d=strlen(a); g=strlen(b);
printf("n length is a-: %d",d);
printf("n length is b -%d",g); strcpy(a,c); puts(c); printf("n %s",strcat(a,b));
res = strcmp(s1, s2); printf("n strcmp(s1, s2) = %dn", res); res = strcmp(s1,
s3);
printf("n strcmp(s1, s3) = %dn", res); printf("n %s",strlwr(a)); printf("n
%s",strupr(b));
getch();
}
PROCESS.H:
Function Function Description
system() To run system command.
abort() Abort current process (function )
exit() Terminates the program
getpid() Get the process id of the program
Example of abort(),exit()
#include <stdio.h>
#include <stdlib.h>
void main () { FILE *f; f= fopen ("test.txt","r");
if (f == NULL) {
fputs ("error opening filen",stderr); abort(); } fclose (f); }
#include <stdio.h>
#include <stdlib.h>
void main ()
{ FILE *f; f = fopen ("test.txt","r");
if (f==NULL) { printf ("Error opening file"); exit (EXIT_FAILURE); } else
{ /* opening a file code here*/ }}
Example of system(),getpid()
#include <stdio.h>
#include <stdlib.h>
void main () {
system(“cls”);
system(“dir”);
printf(“n Process id of this program-: %X”,getpid());
getch();
}
STDLIB.H:
Function Function Description
atof Convert string to double (function )
atoi Convert string to integer (function )
atol Convert string to long integer (function )
rand Generate random number (function )
abort Abort current process (function )
Exit Terminates the program (function)
Example of atoi() , atol() , atof()
#include <stdio.h>
#include <stdlib.h>
void main ()
{ long int li;int i;
double n,m; double pi=3.141;
char buf[100];
printf ("enter degrees: ");
fgets (buf,100,stdin);
n = atof (buf);
m = sin (n*pi/180);
printf ("the sine of %f degrees is %fn" , n, m);
printf ("enter a long number: ");
li = atol(buf);
printf ("the value entered is %ld. its double is %ld.n",li,li*2);
i = atoi (buf);
printf ("the value entered is %d. its double is %d.n",i,i*2);
getch(); }
Example of abort(),exit()
#include <stdio.h>
#include <stdlib.h>
void main () { FILE *f; f= fopen ("test.txt","r");
if (f == NULL) {
fputs ("error opening filen",stderr); abort(); } fclose (f); }
#include <stdio.h>
#include <stdlib.h>
void main ()
{ FILE *f; f = fopen ("test.txt","r");
if (f==NULL) { printf ("Error opening file"); exit (EXIT_FAILURE); } else
{ /* opening a file code here*/ }}
Example of rand()
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main ()
{ int s,g;
srand (time(NULL));
s = rand() % 10 + 1;
do { printf ("Guess the number (1 to 10): ");
scanf ("%d",&g);
if (s<g) puts ("The secret number is lower");
else if (s>g) puts ("The secret number is higher");
} while (s!=g);
puts ("Hurrah your secret no is equal guess no");
return 0; }
THANK YOU
Ad

More Related Content

What's hot (20)

C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
mohamed sikander
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphism
mohamed sikander
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
rohit kumar
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
Chris Ohk
 
C tech questions
C tech questionsC tech questions
C tech questions
vijay00791
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
MKalpanaDevi
 
C++ programs
C++ programsC++ programs
C++ programs
Mukund Gandrakota
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
Amit Kapoor
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
MomenMostafa
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4
昀 李
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 
week-6x
week-6xweek-6x
week-6x
KITE www.kitecolleges.com
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
mohamed sikander
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphism
mohamed sikander
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
rohit kumar
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
Chris Ohk
 
C tech questions
C tech questionsC tech questions
C tech questions
vijay00791
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
MKalpanaDevi
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
Amit Kapoor
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
MomenMostafa
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4
昀 李
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 

Similar to String Manipulation Function and Header File Functions (20)

Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
C basics
C basicsC basics
C basics
MSc CST
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
arnold 7490
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
arnold 7490
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
Raj vardhan
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
yap_raiza
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
KavyaSharma65
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
C programming function
C  programming functionC  programming function
C programming function
argusacademy
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
 
String
StringString
String
SANTOSH RATH
 
Cpds lab
Cpds labCpds lab
Cpds lab
praveennallavelly08
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
C basics
C basicsC basics
C basics
MSc CST
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
Raj vardhan
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
yap_raiza
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
KavyaSharma65
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
C programming function
C  programming functionC  programming function
C programming function
argusacademy
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
 
Ad

More from Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi) (20)

Preprocessor Directive in C
Preprocessor Directive in CPreprocessor Directive in C
Preprocessor Directive in C
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Bit field enum and command line arguments
Bit field enum and command line argumentsBit field enum and command line arguments
Bit field enum and command line arguments
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Pointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory AllocationPointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory Allocation
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Array in C
Array in CArray in C
Array in C
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C storage class
C storage classC storage class
C storage class
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C Operators
C OperatorsC Operators
C Operators
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
E commerce application
E commerce applicationE commerce application
E commerce application
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Data normalization
Data normalizationData normalization
Data normalization
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Database connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwariDatabase connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwari
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Ado vs ado.net by varun tiwari
Ado vs ado.net by varun tiwariAdo vs ado.net by varun tiwari
Ado vs ado.net by varun tiwari
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Ad

Recently uploaded (20)

U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 

String Manipulation Function and Header File Functions

  • 1. PAPER: INTRODUCTION PROGRAMMING LANGUAGE USING C PAPER ID: 20105 PAPER CODE: BCA 105 DR. VARUN TIWARI (ASSOCIATE PROFESSOR) (DEPARTMENT OF COMPUTER SCIENCE) BOSCO TECHNICAL TRAINING SOCIETY, DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
  • 2. STRING MANIPULATION FUNCTION & C HEADER FILE FUNCTION
  • 3. OBJECTIVES IN THIS CHAPTER YOU WILL LEARN: 1. TO UNDERSTAND ABOUT STDIO.H IN C. 2. TO LEARN ABOUT MATH.H IN C. 3. TO LEARN ABOUT CTYPE.H IN C. 4. TO UNDERSTAND STDLIB.H IN C. 5. TO LEARN ABOUT CONIO.H IN C. 6. TO LEARN ABOUT STRING.H IN C. 7. TO LEARN ABOUT PROCESS.H IN C.
  • 4. STDIO.H: Function Description printf() It is used to print the character, string, float, integer, octal and hexadecimal values onto the output screen. scanf() It is used to read a character, string, numeric data from keyboard. gets() It reads line from keyboard puts() It writes line to output screen fopen() fopen() is used to open a file in different mode fclose() closes an opened file getw() reads an integer from file putw() writes an integer to file
  • 5. EXAMPLE PRINTF AND SCANF #include <stdio.h> void main() { int a; printf(“Enter any number-:"); scanf(“%d”,&a); printf(“output is -:%d”,a); }
  • 6. EXAMPLE FOPEN AND FCLOSE FOPEN FUNCTION IS USED TO OPENING A FILE IN DIFFERENT MODES AND FCLOSE FUNCTION IS USED TO CLOSING A FILE. #include<stdio.h> void main(){ FILE *a; a = fopen("file.txt", "w");//opening file fprintf(a, "Hello how r u.n");//writing data into file fclose(a);//closing file }
  • 7. EXAMPLE GETS AND PUTS GETS() FUNCTION IS USED TO READS STRING FROM USER AND PUTS() FUNCTION IS USED TO PRINT THE STRING. #include<stdio.h> #include<conio.h> void main(){ char n[25]; clrscr(); printf("enter your name: "); gets(n); printf("your name is: "); puts(n); getch(); }
  • 8. EXAMPLE OF GETW() AND PUTW() GETW() FUNCTION IS USED TO READ A INTEGER VALUE FROM A FILE AND PUTW() IS USED TO WRITE AN INTEGER VALUE FROM A FILE. #include <stdio.h> void main () { FILE *f; int a,n; clrscr(); f = fopen ("bcd1.txt","w"); for(a=1;a<=10;a++) { putw(a,f); } fclose(f); f = fopen ("bcd1.txt","r"); while((n=getw(f))!=EOF) { printf("n Output is-: %d n", n);} fclose(f); getch(); }
  • 9. MATH.H: Function Function Description ceil It returns nearest integer greater than argument passed. cos It is used to computes the cosine of the argument exp It is used to computes the exponential raised to given power floor Returns nearest integer lower than the argument passed. log Computes natural logarithm log10 Computes logarithm of base argument 10 pow Computes the number raised to given power sin Computes sine of the argument sqrt Computes square root of the argument tan Computes tangent of the argument
  • 10. EXAMPLE OF CUBE() , CEIL() , EXP() AND COS() #include <stdio.h> #include <math.h> #define pi 3.1415 void main() { double n =4.6,a=24.0,res; clrscr(); res = ceil(n); printf("n ceiling integer of %.2f = %.2f", n, res); a = (a * pi) / 180; res = cos(a); printf("n cos value of is %lf radian = %lf", a, res); res = exp(n); printf("n exponential of %lf = %lf", n, res); getch(); }
  • 11. EXAMPLE OF POW, LOG, FLOOR AND LOG10 #include <stdio.h> #include <math.h> void main() { double n = 4.7,p=-9.33,res,b=3,po=4; clrscr(); res = pow(b,po); printf("n %lf ^ %lf = %lf", b, po, res); res = log(n); printf("n log value is %f = %f", n, res); res = floor(p); printf("n floor integer of %.2f = %.2f", p, res); res = log10(n); printf("n log10 value is %f = %f", n, res); getch(); }
  • 12. Example of sin(), sqrt() and tan() in c. #include <stdio.h> #include <math.h> void main() { double n = 4.7,sr,res; clrscr(); res = sin(n); printf("n sin value is -: %lf = %lf", n, res); sr = sqrt(n); printf("n square root of %lf = %lf", n, sr); res = tan(n); printf("n tan value is -: %lf = %lf", n, res); getch(); }
  • 13. CONIO.H: Function Function Description clrscr() This function is used to clear the output screen. getch() This function is used to hold the screen until any character not press from keyboard textcolor() This function is used to define text color. textbackground() This function is used to define background color of the text. getche() It is used to get a character from the console and echoes to the screen.
  • 14. Example of getch(),getche() void main() { char c; int p; printf( "Press any keyn" ); c = getche(); printf( "You pressed %c(%d)n", c, c ); c = getch(); printf("Input Char Is :%c",c); getch(); }
  • 15. Example of clrscr(), textcolor() and textbackground() #include<conio.h> void main() { int i; clrscr(); for(i=0; i<=15; i++) { textcolor(i); textbackground(10-i); cprintf("Bosco Technical Training Society"); cprintf("rn"); } getch(); }
  • 16. CTYPE.H: Function Function Description isalnum Tests whether a character is alphanumeric or not isalpha Tests whether a character is alphabetic or not iscntrl Tests whether a character is control or not isdigit Tests whether a character is digit or not islower Tests whether a character is lowercase or not ispunct Tests whether a character is punctuation or not isspace Tests whether a character is white space or not isupper Tests whether a character is uppercase or not tolower Converts to lowercase if the character is in uppercase toupper Converts to uppercase if the character is in lowercase
  • 17. Example of iscntrl() , isdigit() , isupper(), islower() #include <stdio.h> #include <ctype.h> void main() { char c='n'; char p; char q,r; clrscr(); if(iscntrl(c)) printf("n u entered control value"); else printf("n not a control character"); printf("n enter any numeric value"); scanf("%c",&p); if(isdigit(p)) printf("n entered value is digit"); else printf("n not digit"); q='a'; if(islower(q)) printf("n entered value is lower"); else printf("n not lower"); printf("n"); r='p'; if(isupper(r)) printf("n entered value is upper"); else printf("n not upper"); getch(); }
  • 18. Example of isalnum() , isalpha() , ispunct(), isspace() #include <stdio.h> #include <ctype.h> void main() { char c='c'; char p; char q,r; clrscr(); if(isalpha(c)) printf("n u entered alphabetic value"); else printf("n Not an Alphabet"); printf("n Enter any numeric value"); scanf("%c",&p); if(isalnum(p)) printf("n Entered value is alphanumeric"); else printf("n Not alphanumeric"); q=' '; if(isspace(q)) printf("n Space is here"); else printf("n Space is not here"); printf("n"); r=':'; if(ispunct(r)) printf("n Entered value is punctuation"); else printf("n Not Punctuation"); getch(); }
  • 19. Example of ispunct() , isspace() , isupper(), tolower() and toupper() #include <stdio.h> #include <ctype.h> void main() { char c; c = 'M'; res = tolower(c); printf("tolower is -: %c = %c n", c, res); c = 'h'; res = toupper(c); printf("toupper is-: %c = %c n", c, res); getch();}
  • 20. STRING.H: Function Function Description strlen() computes string's length strcpy() copies a string to another strcat() concatenates(joins) two strings strcmp() compares two strings strlwr() converts string to lowercase strupr() converts string to uppercase
  • 21. Example of all string function #include <stdio.h> #include <string.h> void main() { char a[20]="java"; char b[20]="program"; char c[20]; int res,d,g; char s1[] = "vivek", s2[] = "viVek", s3[] = "vivek"; char q[40]; clrscr(); d=strlen(a); g=strlen(b); printf("n length is a-: %d",d); printf("n length is b -%d",g); strcpy(a,c); puts(c); printf("n %s",strcat(a,b)); res = strcmp(s1, s2); printf("n strcmp(s1, s2) = %dn", res); res = strcmp(s1, s3); printf("n strcmp(s1, s3) = %dn", res); printf("n %s",strlwr(a)); printf("n %s",strupr(b)); getch(); }
  • 22. PROCESS.H: Function Function Description system() To run system command. abort() Abort current process (function ) exit() Terminates the program getpid() Get the process id of the program
  • 23. Example of abort(),exit() #include <stdio.h> #include <stdlib.h> void main () { FILE *f; f= fopen ("test.txt","r"); if (f == NULL) { fputs ("error opening filen",stderr); abort(); } fclose (f); } #include <stdio.h> #include <stdlib.h> void main () { FILE *f; f = fopen ("test.txt","r"); if (f==NULL) { printf ("Error opening file"); exit (EXIT_FAILURE); } else { /* opening a file code here*/ }}
  • 24. Example of system(),getpid() #include <stdio.h> #include <stdlib.h> void main () { system(“cls”); system(“dir”); printf(“n Process id of this program-: %X”,getpid()); getch(); }
  • 25. STDLIB.H: Function Function Description atof Convert string to double (function ) atoi Convert string to integer (function ) atol Convert string to long integer (function ) rand Generate random number (function ) abort Abort current process (function ) Exit Terminates the program (function)
  • 26. Example of atoi() , atol() , atof() #include <stdio.h> #include <stdlib.h> void main () { long int li;int i; double n,m; double pi=3.141; char buf[100]; printf ("enter degrees: "); fgets (buf,100,stdin); n = atof (buf); m = sin (n*pi/180); printf ("the sine of %f degrees is %fn" , n, m); printf ("enter a long number: "); li = atol(buf); printf ("the value entered is %ld. its double is %ld.n",li,li*2); i = atoi (buf); printf ("the value entered is %d. its double is %d.n",i,i*2); getch(); }
  • 27. Example of abort(),exit() #include <stdio.h> #include <stdlib.h> void main () { FILE *f; f= fopen ("test.txt","r"); if (f == NULL) { fputs ("error opening filen",stderr); abort(); } fclose (f); } #include <stdio.h> #include <stdlib.h> void main () { FILE *f; f = fopen ("test.txt","r"); if (f==NULL) { printf ("Error opening file"); exit (EXIT_FAILURE); } else { /* opening a file code here*/ }}
  • 28. Example of rand() #include <stdio.h> #include <stdlib.h> #include <time.h> void main () { int s,g; srand (time(NULL)); s = rand() % 10 + 1; do { printf ("Guess the number (1 to 10): "); scanf ("%d",&g); if (s<g) puts ("The secret number is lower"); else if (s>g) puts ("The secret number is higher"); } while (s!=g); puts ("Hurrah your secret no is equal guess no"); return 0; }
  翻译: