Chapter 1

Introduction

Print Hello World

#include <stdio.h> // include information about standard library
main(){ //function name
	printf("hello, world");
}

Variables and Arithmetic Expression

#include <stdio.h>
main(){
	int fahr, celsius;
	int lower, upper, step;
}

The For Statement

#include <stdio.h>
main(){
	int fahr;
for (fahr = 0; farh <= 300; fahr = fahr + 20)
		printf("%3d %5.1f\\n, fahr, (5.0/9.0)*(fahr-30));
}
#define LOWER 0
#define UPPER 300
c = getchar(); //reads the next input character
putchar(c);  //print the character

ASCII Value

#include <stdio.h>
int main()
{
    char chr;
    printf("Enter a character: ");
    scanf("%c", &chr);     

    // When %c is used, a character is displayed
    printf("You entered %c.\\n",chr);  

    // When %d is used, ASCII value is displayed
    printf("ASCII value is %d.", chr);  
    return 0;
}