1 of 8

C PROGRAM

COMPILED BY ARUP ROY CHOUDHURY, ASSOCIATE PROFESSOR, DEPARTMENT OF MATHEMATICS, MALDA COLLEGE, MALDA

2 of 8

PROGRAM AND PROGRAMMING LANGUAGE

Program: A program is a set of instructions written in a language that tells the computer to perform certain task or solve a particular problem in a step by step manner.

Programming Language: A programming language consists of set of symbols, letters and numbers using which instructions or commands can be written according to the pre-defined rules and syntax of the computer.

ANSI C: In 1983, American National Standard Institute (ANSI) appointed a technical committee to define a standard for C. The committee approved a version of C in 1989 which is known as ANSI C.

We consider a simple C program:

#include<stdio.h>

main( )

3 of 8

C Programming

{

printf(“\n Welcome to C.”);

}

The first statement is the computer directive. It instruct the computer to link with the stdio.h header file containing standard input and output functions.

The next line is main( ). This is a special function having no argument used in every C program. This tells the computer where the program starts. After main( ) a brace opens and a brace closes within which all the statements are written to form the function body.

Here

printf(“\n Welcome to C.”);

is the statement within the function main to be executed. \n indicates to print “Welcome to C”

4 of 8

C Programming

from a new line. Each statement in the function main ends with a semicolon.

In C, everything is written in lower case letters. Upper case letters may be used for symbolic names representing constants.

Basic structure of a C-program should be of the form:

#include<stdio.h>

#include<conio.h>

#include<math.h>

main( )

{

declaration of data type;

//clrscr( );

5 of 8

C Programming

input statement;

calculation statement;

output statement;

//getch( );

}

All C-program must have the first statement “#include<stdio.h>” which is the computer directive. It instruct the computer to link with the stdio.h header file containing standard input and output functions viz., printf( ), scan( ). The library function printf( ) is used to send data items to standard out-put device. The scanf( ) is used to enter data items through standard in-put device.

Again the statement “#include<conio.h>” is used to instruct the computer to include the header file conio.h. This header file contains the library functions clrscr( ), getch( ).

6 of 8

C Programming

  •  

Function

Expression in C

sin x

sin(x)

cos x

cos(x)

tan x

tan(x)

cosh x

cosh(x)

sinh x

sinh(x)

tanh x

tanh(x)

acos(x)

7 of 8

C Programming

Function

Expression in C

asin(x)

atan(x)

exp(x)

fabs(x)

pow(x,y)

8 of 8

C Programming

Function/Symbol

Expression in C

sqrt(x)

>=

<=