Saturday, 15 February 2014

Basic Programming Concepts

   

What is a Program?

A program is a set of instructions or commands which are given to the computer to perform a specific task or operations.
In other words,a program is actually logical sequence of various commands.

Basics Constituents of a 'C' Program

There are mainly three basic constituents of a 'C' language Program:

main()

The main() function is called "driver of the program".
It is responsible for the execution of various commands of the 'C' language Program.That's why it's called the driver of the program.

Syntax:
            main()
            {
              <statement 1>;
              <statement 2>;
              <statement 3>;
            }

printf()

The full form of printf() is "print in format".
It is an "Output-statement"

It is used to display the values of any type of variable as well as various messages on the output screen.
Syntax:
            printf(<"Message<Conversion Specification Characters>[Escape Sequence Characters]"> , <Variable>);

scanf()

The full form of scantf() is "scan in format".
It is an "Input-statement"

It is used to input any type of values or data through the keyboard by the user at runtime in any program of the 'C' language.
Syntax:
            scanf(<"Conversion Specification Characters"> , &<Variable>);

NOTE:
"&" is Ampersand(Address operator).
            It is used only in case of integer,long,float,character but not in case of strings.

Escape Sequence Characters

The Escape Sequence Characters are used to set the sequence the sequence of the output on the screen by using the following characters:

New Line:

"\n" : to go to a new line(maintain the vertical distance).

New Tab:

"\t" : to go to new tab(move forward by 7 characters)(maintain the horizontal distance).

No comments:

Post a Comment