Professional Documents
Culture Documents
Tut 170807
Tut 170807
Tutorial
Programming & Data Structure: CS 11001
Section - 9/C
DO NOT POWER ON THE MACHINE
Department of Computer Science and Engineering
I.I.T. Kharagpur
Autumn Semester: 2007 - 2008 (17.08.2007)
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 2
Download
http://www.facweb.iitkgp.ernet.in/∼goutam
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 3
Tutorial IV.I
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 4
Tutorial IV.II
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 5
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 6
#include <stdio.h>
int main(){ // tutIV.3.c
char c ;
c = getchar() ;
putchar(c) ;
putchar(’\n’) ;
return 0 ;
}
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 7
Loop Termination
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 8
#include <stdio.h>
int main(){ // tutIV.4.c
char c ;
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 9
ASCII to Number
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 10
#include <stdio.h>
int main(){ // tutIV.5.c
char c ;
c = getchar() ;
printf("val(%c) = %d\n", c, c - ’0’) ;
return 0 ;
}
& %
' $
PDS Tutorial: IV (CS 11001): Section 9 Dept. of CS&Engg., IIT Kharagpur 11
Tutorial IV.III
& %