Showing posts with label INTRODUCTION TO C. Show all posts
Showing posts with label INTRODUCTION TO C. Show all posts

Wednesday, September 24, 2014

INTRODUCTION TO C

1. Explain in detail about „C‟ declarations and variables.

In C, lowercase and uppercase characters are very important. All commands in C must be lowercase. The C programs starting point is identified by the word main( ). This informs the computer as to where the program actually starts.
The brackets that follow the keyword main indicate that there are no arguments supplied to this program.
The two braces, { and }, signify the begin and end segments of the program. The purpose of the statement include <stdio.h> is to allow the use of the printf statement to provide program
output. Text to be displayed by printf() must be enclosed in double quotes. The program has only one statement printf("Programming in C is easy.\n");
printf() is actually a function (procedure) in C that is used for printing variables and text. Where text appears in double quotes "", it is printed without modification. There are some exceptions however. This has to do with the \ and % characters. These characters are modifier‟s, and for the present the \ followed by the n character represents a newline character. Thus the program prints Programming in C is easy.
and the cursor is set to the beginning of the next line. As we shall see later on, what follows the \ character will determine what is printed, ie, a tab, clear screen, clear line etc. Another important thing to remember is that all C statements are terminated by a semi-colon ;
General rules of „C‟ language:
· program execution begins at main()
· keywords are written in lower-case
· statements are terminated with a semi-colon
· text strings are enclosed in double quotes

· C is case sensitive, use lower-case and try not to capitalize variable names
· \n means position the cursor on the beginning of the next line
· printf() can be used to display text to the screen
· The curly braces {} define the beginning and end of a program block.

BASIC STRUCTURE OF C PROGRAMS
C programs are essentially constructed in the following manner, as a number of well defined sections.
/* HEADER SECTION */
/* Contains name, author, revision number*/
/* INCLUDE SECTION */
/* contains #include statements */
/* CONSTANTS AND TYPES SECTION */
/* contains types and #defines */
/* GLOBAL VARIABLES SECTION */
/* any global variables declared here */
/* FUNCTIONS SECTION */
/* user defined functions */
/* main() SECTION */
int main()
{
}