SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman 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 Overloadingmohamed 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-3Dr. Loganathan R
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphismmohamed 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 1rohit kumar
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
C tech questions
C tech questionsC tech questions
C tech questionsvijay00791
 
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-2Dr. Loganathan R
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7Rumman Ansari
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris 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 solutionrohit kumar
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
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 solutionHazrat Bilal
 

La actualidad más candente (20)

C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
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
 
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
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphism
 
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
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
C tech questions
C tech questionsC tech questions
C tech questions
 
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
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
C++ programs
C++ programsC++ programs
C++ programs
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
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
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
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
 
week-6x
week-6xweek-6x
week-6x
 

Similar a String Manipulation Function and Header File Functions

Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
C basics
C basicsC basics
C basicsMSc CST
 
Input output functions
Input output functionsInput output functions
Input output functionshyderali123
 
'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 02Wingston
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CRaj 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 ANSWERSKavyaSharma65
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar 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 functionargusacademy
 
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 .pdfezonesolutions
 

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

Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
C basics
C basicsC basics
C basics
 
7 functions
7  functions7  functions
7 functions
 
C programms
C programmsC programms
C programms
 
Input output functions
Input output functionsInput output functions
Input output functions
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
UNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN CUNIT 4-HEADER FILES IN C
UNIT 4-HEADER FILES IN C
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
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
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
C Programming
C ProgrammingC Programming
C Programming
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C programming function
C  programming functionC  programming function
C programming function
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
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
 
String
StringString
String
 
Cpds lab
Cpds labCpds lab
Cpds lab
 

Más de Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)

Más de 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
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
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
 
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
 
Array in C
Array in CArray in C
Array in C
 
C storage class
C storage classC storage class
C storage class
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
C Operators
C OperatorsC Operators
C Operators
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
 
E commerce application
E commerce applicationE commerce application
E commerce application
 
Data normalization
Data normalizationData normalization
Data normalization
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
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
 
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
 

Último

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Último (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

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; }