Home | Lab 1 | Lab 2 | Lab 3 | Lab 4 | Lab 5 | Lab 6 | Lab 7 | Lab 8 | Lab 9 | Lab 10 | Lab 11 | Lab 12

Linked at EntranceNepal.com, i-geek blog & Ekendra's Share World

Object: Exercise on writing, compiling and executing a sample program in C.

Download this full program | Lab 1 | in pdf format

Background Theory:

 Computer Program- set of instructions that direct a computer to perform some processing function or combination of functions.

 Programming Language- artificial language used to write a sequence of instructions (a computer program) that can be run by a computer.

 High-Level Language- a computer language that provides a certain level of abstraction from the underlying machine language through the use of declarations, control statements, and other syntactical structures as C.

 C-Programming Language- a standardized imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. Since then it has spread to many other OSs and is one of the most widely used programming languages prized for its efficiency and portability. It is also commonly used in computer science education, despite not being designed for novices and so we are.

 C is relatively minimalist programming language that operates close to hardware and more similar to assembly language that to high-level language though is 3rd Generation of its type.

 Every C program consists of one or more modules called functions. Each function must contain:

     I.    A function heading with function name followed by optional arguments enclosed in parenthesis.

    II.    A list of argument declarations if included in heading.

  III.    A compound statement comprising the remainder of the function.

 Compiler- computer program that translates source code, instructions in a program into object code, those same instructions written in a language the computer’s central processing unit (CPU) can read and interpret. Compilers collect and reorganize (compile) all the instructions in a given set of source code to produce object code.

 Interpreter: this is analogous to web browsing and HTML code which is the output seen.

Code:

Object Code- translated version of Source code

Program to calculate area of circle:

     /*Program to calculate the area of circle of given radius*/

# include <stdio.h>                                      /* header file*/

# include <conio.h>

void main()

{

            float Area, Radius;                           /* variable declaration*/

            clrscr();                                               /* to clear the screen*/

            printf (“Radius= ”);                            /* library function*/

            scanf (“%f”, &Radius);                     /* library function*/

            Area= 3.1415*Radius*Radius;

            printf (The area of Circle= %f”, Area);     /* output Area*/

            printf (“\n\t Press any key to continue…”);

            getch();                                              /* holds the output*/

}

To Download this full program | Lab 1 | in pdf format you must have PDF reader as Adobe Acrobat Reader 5 and above in your computer,

click here to download now.

Search yourself for more such codes

Google

Home | Lab 1 | Lab 2 | Lab 3 | Lab 4 | Lab 5 | Lab 6 | Lab 7 | Lab 8 | Lab 9 | Lab 10 | Lab 11 | Lab 12

© Protected under Creative Commons License.
Written by Ekendra Lamsal, www.ekendralamsal.com
for comments email at gmail address:
gearShifts@gmail.com