SlideShare a Scribd company logo
Part 9
Special case
#include <stdio.h>
main()
{
float sum ;
int n ;
sum = 0 ;
for( n = 1 ; n <= 10 ; ++n )
{
sum = sum + 1/(float)n ;
printf("%2d %6.4fn", n, sum) ;
}
}
PROGRAM SHOWING THE USE OF A CAST
The program in shows the use of getchar function in an interactive environment.
The program displays a question of YES/NO type to the user and reads the user's
response in a single character (Y or N). If the response is Y, it outputs the message
My name is BUSY BEE
otherwise, outputs.
You are good for nothing
#include<stdio.h>
main()
{
char answer;
printf("Would you like to know my name?n");
printf("Type Y for YES and N for NO: ");
answer = getchar(); /* .... Reading a character...*/
if(answer == 'Y' || answer == 'y')
printf("nnMy name is BUSY BEEn");
else
printf("nnYou are good for nothingn");
}
The program of requests the user to enter a character and displays a message
on the screen telling the user whether the character is an alphabet or digit,
or any other special character
This program receives a character from the keyboard and tests whether
it is a letter or digit and prints out a message accordingly.
These tests are done with the help of the following functions:
isalpha(character)
isdigit(character)
For example, isalpha assumes a value non-zero (TRUE) if the argument character
contains an alphabet; otherwise it assumes 0 (FALSE). Similar is the case with the
function isdigit
#include <stdio.h>
#include <ctype.h>
main()
{
char character;
printf("Press any keyn");
character = getchar();
if (isalpha(character) > 0)
printf("The character is a letter.");
else
if (isdigit (character) > 0)
printf("The character is a digit.");
else
printf("The character is not alphanumeric.");
}
The program uses three new functions: islower, toupper, and tolower. The function
islower is
#include <stdio.h>
#include <ctype.h>
main()
{
char alphabet;
printf("Enter an alphabet");
putchar('n'); /* move to next line */
alphabet = getchar();
if (islower(alphabet))
putchar(toupper(alphabet));
else
putchar(tolower(alphabet));
}
#include <stdio.h>
#include <ctype.h>
main()
{
char alphabet;
printf("Enter an alphabet");
putchar('n'); /* move to next line */
alphabet = getchar();
if (isupper(alphabet))
putchar(tolower(alphabet));
else
putchar(toupper(alphabet));
}

More Related Content

PPTX
C Programming Language Part 11
Rumman Ansari
 
PPTX
C Programming Language Part 8
Rumman Ansari
 
PPTX
C Programming Language Part 7
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 5
Rumman Ansari
 
PPTX
C Programming Language Part 6
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 2
Rumman Ansari
 
PPTX
C Programming Language Part 4
Rumman Ansari
 
PPTX
Decision making and branching
Saranya saran
 
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Part 6
Rumman Ansari
 
C Programming Language Step by Step Part 2
Rumman Ansari
 
C Programming Language Part 4
Rumman Ansari
 
Decision making and branching
Saranya saran
 

What's hot (20)

PPTX
Expressions using operator in c
Saranya saran
 
PPTX
Intro to c chapter cover 1 4
Hazwan Arif
 
PDF
1 introducing c language
MomenMostafa
 
PDF
7 functions
MomenMostafa
 
PPT
Functions and pointers_unit_4
Saranya saran
 
PPTX
C programming(Part 1)
Dr. SURBHI SAROHA
 
PPTX
Programming in C (part 2)
Dr. SURBHI SAROHA
 
PPTX
C programming(part 3)
Dr. SURBHI SAROHA
 
PDF
C programming
Samsil Arefin
 
PPT
Lecture 6- Intorduction to C Programming
Md. Imran Hossain Showrov
 
PPT
Functions and pointers_unit_4
MKalpanaDevi
 
PPSX
Concepts of C [Module 2]
Abhishek Sinha
 
PDF
8 arrays and pointers
MomenMostafa
 
PPT
Lecture 8- Data Input and Output
Md. Imran Hossain Showrov
 
PDF
4 operators, expressions &amp; statements
MomenMostafa
 
PPSX
C programming pointer
argusacademy
 
PPTX
Input output statement in C
Muthuganesh S
 
PPT
Input And Output
Ghaffar Khan
 
Expressions using operator in c
Saranya saran
 
Intro to c chapter cover 1 4
Hazwan Arif
 
1 introducing c language
MomenMostafa
 
7 functions
MomenMostafa
 
Functions and pointers_unit_4
Saranya saran
 
C programming(Part 1)
Dr. SURBHI SAROHA
 
Programming in C (part 2)
Dr. SURBHI SAROHA
 
C programming(part 3)
Dr. SURBHI SAROHA
 
C programming
Samsil Arefin
 
Lecture 6- Intorduction to C Programming
Md. Imran Hossain Showrov
 
Functions and pointers_unit_4
MKalpanaDevi
 
Concepts of C [Module 2]
Abhishek Sinha
 
8 arrays and pointers
MomenMostafa
 
Lecture 8- Data Input and Output
Md. Imran Hossain Showrov
 
4 operators, expressions &amp; statements
MomenMostafa
 
C programming pointer
argusacademy
 
Input output statement in C
Muthuganesh S
 
Input And Output
Ghaffar Khan
 
Ad

Viewers also liked (19)

PPTX
C Programming Language Part 5
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 1
Rumman Ansari
 
PPTX
Basic c programming and explanation PPT1
Rumman Ansari
 
PPTX
How c program execute in c program
Rumman Ansari
 
PPTX
My first program in c, hello world !
Rumman Ansari
 
PPT
Steps for Developing a 'C' program
Sahithi Naraparaju
 
PPTX
Programming in C Basics
Bharat Kalia
 
PDF
Composicio Digital _Practica Pa4
Marcos Baldovi
 
PPTX
Introduction to Basic C programming 02
Wingston
 
PPSX
C programming basics
argusacademy
 
DOC
Resume Andrew L. Harrell jan 2016
Andrew Harrell
 
PPTX
Book for the burg march2014
Nadene Brunk
 
PDF
JCPSA612810104104_1
Martin Jones
 
DOC
Muzika torkayetsya dushi
Poltava municipal lyceum #1
 
PPTX
11 gezond-is-vetcool
anfrancoise
 
PDF
Festival Brin, il programma
Claudia Bertanza
 
PDF
Ribishan Avunhipuram
Ribishan Ap
 
PDF
Productos de fin de año.
José Alderete
 
PDF
Group Personal Accident Policy
Digital PurplePond
 
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 1
Rumman Ansari
 
Basic c programming and explanation PPT1
Rumman Ansari
 
How c program execute in c program
Rumman Ansari
 
My first program in c, hello world !
Rumman Ansari
 
Steps for Developing a 'C' program
Sahithi Naraparaju
 
Programming in C Basics
Bharat Kalia
 
Composicio Digital _Practica Pa4
Marcos Baldovi
 
Introduction to Basic C programming 02
Wingston
 
C programming basics
argusacademy
 
Resume Andrew L. Harrell jan 2016
Andrew Harrell
 
Book for the burg march2014
Nadene Brunk
 
JCPSA612810104104_1
Martin Jones
 
Muzika torkayetsya dushi
Poltava municipal lyceum #1
 
11 gezond-is-vetcool
anfrancoise
 
Festival Brin, il programma
Claudia Bertanza
 
Ribishan Avunhipuram
Ribishan Ap
 
Productos de fin de año.
José Alderete
 
Group Personal Accident Policy
Digital PurplePond
 
Ad

Similar to C Programming Language Part 9 (20)

PPT
Chtp408
giovanniveitch
 
PPT
C chap08
teach4uin
 
PDF
5 1. character processing
웅식 전
 
PPT
Karakter dan String
Fernalia Halim
 
DOCX
UNIT 4-HEADER FILES IN C
Raj vardhan
 
PDF
6 c control statements branching &amp; jumping
MomenMostafa
 
PDF
Cse115 lecture14strings part01
Md. Ashikur Rahman
 
PDF
02CExamples for c program and exercises Pdf
VeanDieson
 
PDF
Chapter 13.1.3
patcha535
 
PPTX
Basic Input and Output
Nurul Zakiah Zamri Tan
 
PPT
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
PPT
String manipulation techniques like string compare copy
Dr. T. Kalaikumaran
 
PDF
String
SANTOSH RATH
 
PPT
Basics of C.ppt
RohanJoshi290109
 
PPT
Basics of C.ppt
SangramNayak23
 
PPTX
Introduction of Basics of c programming.pptx
priyankabonde1998
 
PPTX
Presentation more c_programmingcharacter_and_string_handling_
KarthicaMarasamy
 
PDF
C reference manual
Komal Ahluwalia
 
PPTX
c_pro_introduction.pptx
RohitRaj744272
 
C chap08
teach4uin
 
5 1. character processing
웅식 전
 
Karakter dan String
Fernalia Halim
 
UNIT 4-HEADER FILES IN C
Raj vardhan
 
6 c control statements branching &amp; jumping
MomenMostafa
 
Cse115 lecture14strings part01
Md. Ashikur Rahman
 
02CExamples for c program and exercises Pdf
VeanDieson
 
Chapter 13.1.3
patcha535
 
Basic Input and Output
Nurul Zakiah Zamri Tan
 
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
String manipulation techniques like string compare copy
Dr. T. Kalaikumaran
 
String
SANTOSH RATH
 
Basics of C.ppt
RohanJoshi290109
 
Basics of C.ppt
SangramNayak23
 
Introduction of Basics of c programming.pptx
priyankabonde1998
 
Presentation more c_programmingcharacter_and_string_handling_
KarthicaMarasamy
 
C reference manual
Komal Ahluwalia
 
c_pro_introduction.pptx
RohitRaj744272
 

More from Rumman Ansari (18)

PDF
Sql tutorial
Rumman Ansari
 
PDF
C programming exercises and solutions
Rumman Ansari
 
PDF
Java Tutorial best website
Rumman Ansari
 
DOCX
Java Questions and Answers
Rumman Ansari
 
DOCX
servlet programming
Rumman Ansari
 
PPTX
C program to write c program without using main function
Rumman Ansari
 
PPTX
Steps for c program execution
Rumman Ansari
 
PPTX
Pointer in c program
Rumman Ansari
 
PPTX
What is token c programming
Rumman Ansari
 
PPTX
What is identifier c programming
Rumman Ansari
 
PPTX
What is keyword in c programming
Rumman Ansari
 
PPTX
Type casting in c programming
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 3
Rumman Ansari
 
DOCX
C Programming
Rumman Ansari
 
PPTX
Tail recursion
Rumman Ansari
 
PPTX
Tail Recursion in data structure
Rumman Ansari
 
PDF
Spyware manual
Rumman Ansari
 
PPTX
Linked list
Rumman Ansari
 
Sql tutorial
Rumman Ansari
 
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Rumman Ansari
 
servlet programming
Rumman Ansari
 
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Rumman Ansari
 
Pointer in c program
Rumman Ansari
 
What is token c programming
Rumman Ansari
 
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Rumman Ansari
 
C Programming Language Step by Step Part 3
Rumman Ansari
 
C Programming
Rumman Ansari
 
Tail recursion
Rumman Ansari
 
Tail Recursion in data structure
Rumman Ansari
 
Spyware manual
Rumman Ansari
 
Linked list
Rumman Ansari
 

Recently uploaded (20)

PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PPTX
Practice Questions on recent development part 1.pptx
JaspalSingh402
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPTX
anatomy of limbus and anterior chamber .pptx
ZePowe
 
PPTX
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
PDF
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
ijcncjournal019
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPT
High Data Link Control Protocol in Data Link Layer
shailajacse
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
Practice Questions on recent development part 1.pptx
JaspalSingh402
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
anatomy of limbus and anterior chamber .pptx
ZePowe
 
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
ijcncjournal019
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
High Data Link Control Protocol in Data Link Layer
shailajacse
 

C Programming Language Part 9

  • 2. #include <stdio.h> main() { float sum ; int n ; sum = 0 ; for( n = 1 ; n <= 10 ; ++n ) { sum = sum + 1/(float)n ; printf("%2d %6.4fn", n, sum) ; } } PROGRAM SHOWING THE USE OF A CAST
  • 3. The program in shows the use of getchar function in an interactive environment. The program displays a question of YES/NO type to the user and reads the user's response in a single character (Y or N). If the response is Y, it outputs the message My name is BUSY BEE otherwise, outputs. You are good for nothing
  • 4. #include<stdio.h> main() { char answer; printf("Would you like to know my name?n"); printf("Type Y for YES and N for NO: "); answer = getchar(); /* .... Reading a character...*/ if(answer == 'Y' || answer == 'y') printf("nnMy name is BUSY BEEn"); else printf("nnYou are good for nothingn"); }
  • 5. The program of requests the user to enter a character and displays a message on the screen telling the user whether the character is an alphabet or digit, or any other special character This program receives a character from the keyboard and tests whether it is a letter or digit and prints out a message accordingly. These tests are done with the help of the following functions: isalpha(character) isdigit(character) For example, isalpha assumes a value non-zero (TRUE) if the argument character contains an alphabet; otherwise it assumes 0 (FALSE). Similar is the case with the function isdigit
  • 6. #include <stdio.h> #include <ctype.h> main() { char character; printf("Press any keyn"); character = getchar(); if (isalpha(character) > 0) printf("The character is a letter."); else if (isdigit (character) > 0) printf("The character is a digit."); else printf("The character is not alphanumeric."); }
  • 7. The program uses three new functions: islower, toupper, and tolower. The function islower is #include <stdio.h> #include <ctype.h> main() { char alphabet; printf("Enter an alphabet"); putchar('n'); /* move to next line */ alphabet = getchar(); if (islower(alphabet)) putchar(toupper(alphabet)); else putchar(tolower(alphabet)); }
  • 8. #include <stdio.h> #include <ctype.h> main() { char alphabet; printf("Enter an alphabet"); putchar('n'); /* move to next line */ alphabet = getchar(); if (isupper(alphabet)) putchar(tolower(alphabet)); else putchar(toupper(alphabet)); }