Posts

Showing posts from February, 2013

Lecture 4 - Format Specifiers and Escape Sequences

Format specifiers Format specifiers are the special characters which govern the formatting of the variables on the screen. Format Specifier For (Data Type) Format Specifier For (Data Type) %d Signed Decimal Integer %s String %f Floating Point (decimal notation) %x Unsigned Hexadecimal Integer %c Character %o Unsigned Octal Integer %e Floating Point (exponential notation) l Prefix, e.g. %ld for long integer %u Un-signed Decimal Integer Table 4 – Format Specifiers /* This program demonstrates:- Declaration of Constants and Variables Use of Constant Variables Variable initialization Format Specifier Expression Function call                                 ...

Lecture 3 – Variables and Constants

Variables and Constants While writing a program you need some place to put your data on. For that we need variables and constants. Variable A variable is a named memory location, whose contents can be changed during the course of the program. For example a, x, y, k. There are two types of variable in C. 1.       Numeric a.        Integer An integer variable is a variable which has NO fractional part. For example a=5, b=6 etc. We will be using two types of integer variable during our course. int for integer and short for short integer. Integer takes 2-bytes whereas Short takes 1-byte in memory. ·          Integer can handle values from -32768 to 32767 ·          Short can handle values from -128 to 127 b.       Floating point An floating point variable is a variable which has fractional part. For exampl...