Skip to main content

Posts

Showing posts from May 4, 2008

Format Specifiers

Format Specifiers: The format specifiers are used in C programming to specify the format of the datatypes. The various format specifiers used in C programming are as follows; %d : Used for getting integer. %c : Used for getiing character output. %f : For float value. %l : For long integer. %s : For a string.

Basic Variables

As a programmer, you will frequently want your program to "remember" a value. For example, if your program requests a value from the user, or if it calculates a value, you will want to remember it somewhere so you can use it later. This post will show you the different types of variables ( Reminder: )that are available in C. The four basic variables are int(integers,float (decimals),double (long numbers)and char (characters). The following sample program will show you how they could be used; #include stdio.h int main(void) { int integer; float decimal; double longnumber; char character; integer = 9; decimal = 5.6; longnumber = 56489; character = 'G'; return 0; } Now lets learn to display the contents of the different variable types. Heres a sample program; #include stdio.h int main(void) { int integer = 9; float decimal = 5.6; double longnumber = 564897; char character = 'G'; printf("The contents of the variable int