cp_1_lect_24 - Unformatted I/O 5/10/10 getchar() Click to...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style 5/10/10 Unformatted I/O getchar() putchar()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5/10/10 Reading a character: using getchar() The getchar() function accepts any character keyed in. This includes the RETURN and TAB. Syntax: variable_name=getchar(); Example: char n; n= getchar();
Background image of page 2
5/10/10 Use of getchar function to read a character from #include<stdio.h> main() { char a; printf(“would you like to know my name”); printf(“type y for yes and n for no”); a= getchar(); if ( a==‘Y’ || a==‘y’ ) printf(“my name is busy bee”); else
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5/10/10 output Would you like to know my name? Type Y for yes and N for no: Y My name is Busy Bee Would you like to know my name? Type Y for yes and N for no: n You are good for nothing
Background image of page 4
5/10/10 Writing a character: using putchar() The putchar() function is for writing characters one at a time to the terminal. Syntax: putchar(variable_name); Example: char n; n= ‘Y’; putchar(n); Will display the content of variable n ,
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/07/2010 for the course CS&IS TA C162 taught by Professor Kavitha during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 14

cp_1_lect_24 - Unformatted I/O 5/10/10 getchar() Click to...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online