You are on page 1of 10

PPS Lab DEEPAK KUMAR

(BTPS-102-18) (1803757)

Practical 1:- Familiarization with Programming Environment.

Introduction to Programing Language:-

A programming language is a set of commands, instructions, and other syntax use to create a
software program. Languages that programmers use to write code are called "high-level
languages." This code can be compiled into a "low-level language," which is recognized directly
by the computer hardware.

High-level languages are designed to be easy to read and understand. This allows programmers
to write source code in a natural fashion, using logical words and symbols. For example,
reserved words like function, while, if, and else are used in most major programming languages.
Symbols like <, >, ==, and != are common operators.

Introduction to C language:-

C is a procedural programming language. It was initially developed by Dennis Ritchie


between 1969 and 1973. It was mainly developed as a system programming language to write
operating system. The main features of C language include low-level access to memory, simple
set of keywords, and clean style, these features make C language suitable for system
programming like operating system or compiler development.

Many later languages have borrowed syntax/features directly or indirectly from C language. Like
syntax of Java, PHP, JavaScript and many other languages is mainly based on C language. C++
is nearly a superset of C language (There are few programs that may compile in C, but not in
C++).

Charateristics of C:-

 Small size
 Extensive use of function calls
 Loose typing – unlike PASCAL
 Structured language
 Low level (BitWise) programming readily available
 Pointer implementation – extensive use of pointers for memory, array, structures, and
functions.

Now, it had become a widely used professional language because of following reasons.

1
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

 It has high-level constructs.


 It can handle low-level activities.
 It produces efficient programs.
 It can be compiled on a variety of computers.

Advantages of C:-

C Language has a list of advantages due to this it is very much popular language around the
world and best suitable for the programmer to learn at the first stage of the programming.

– Procedure Oriented Language

C Language is procedure-oriented language, here user creates procedures or functions to execute


their task. Procedure-oriented language is very much easy to learn because it follows an
algorithm to execute your statements. To develop a program using procedure-oriented language,
you need to draw/prepare algorithm and then start converting it into procedure or functions.

– Lots of Libraries

C Language provides lots of functions which consist of system generated functions and user-
defined functions. C Compiler comes with a list of header files which consist of many general
functions which can be used to develop a program, while the programmer can also create
function as per their requirements that is called as user-generated/defined function.

– Speed of Compilation

C compiler produces machine code very fast compared to other language compilers. C compiler
can compile around 1000 lines of code in a second or two. One more benefit of the C Compiler is
that it also optimize the code for faster execution.

– Easy to Learn

C Language syntax is very easy to understand. It uses a keyword like if, else, goto, switch, main,
etc. This kind of keyword we all are using in our day to day life to convey meaning or to get
some decisions.

– Portable

C Language setup is around 3-5 MB. So you can carry this language in your Floppy Drive or Pen
Drive. It is very easy to install and operate, Again its output is an exe file which can be executed
in any computer without any other framework/software.

2
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

Disadvantages of C:-

C Language also has some disadvantages. C Language does not have major disadvantages, but
some features are missing in the C Language, obviously, that’s why C Language is very much
powerful now.

– Object Oriented Programming Features (OOPS)

Object Oriented Programming Features is missing in C Language, You have to develop your
program using procedure-oriented language only.

– Run Time Type Checking is Not Available

In C Language there is no provision for run-time type checking, for example, I am passing float
value while receiving parameter is of integer type then the value will be changed, it will not give
any error message.

– Namespace Feature

C does not provide namespace features, so you can’t be able to use the same variable name again
in one scope. If namespace features is available, then you can able to reuse the same variable
name.

– Constructor and Destructor is not available

C does not provide object-oriented features, so it doesn’t have Constructor and Destructor
features. Constructor and Destructor is used to construct an object and destroy an object. So in C
Language, you have to implement the construction and destruction of the variable manually,
using a function or by other means.

3
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

Practical 2: Simple Computation Problems Using Airthmatic Expressions.

2.1: Write A Program To Add Two Numbers.

#include<stdio.h>

#include<conio.h>

main()

inta,b,c;

clrscr();

printf("Enter two numbers");

scanf("%d%d",&a,&b);

c=a+b;

printf("Result is %d",c);

getch();

4
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

2.2:Write A Program To Subtract Multiply And Divide Two Numbers.

#include<stdio.h>

#include<conio.h>

void main()

inta,b,c,d,e,f;

clrscr();

printf("Enter two numbers");

scanf("%d%d",&a,&b);

c=a+b;

d=a-b;

e=a*b;

f=a/b;

printf("Result of addition is %d \n",c);

printf("Result of subtraction is%d \n",d);

printf("Result of multiplication is %d \n",e);

printf("Result of division is %d \n",f);

getch();

5
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

2.3:Write A Program To Find Average Of Four Numbers.

#include<stdio.h>

#include<conio.h>

void main()

inta,b,c,d,e,f;

clrscr();

printf("Enter Four Numbers");

scanf("%d%d%d%d",&a,&b,&c,&d);

e=a+b+c+d;

f=e/4;

printf("Sum is %d \n",e);

printf("Average is %d",f);

getch();

6
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

Practical 3: Problems Involving If-Then-Else Structure.

3.1:- Write A Program To Find Greater Number Among Two Given Numbers Using If
Condition.

#include<stdio.h>

#include<conio.h>

void main()

inta,b;

clrscr();

printf("Enter two numbers");

scanf("%d%d",&a,&b);

if(a>b)

printf("a is greater");

if(b>a);

printf("b is greater");

getch();

7
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

3.2:Write A Program To Find Greater Number Using If-Else Condition.

#include<stdio.h>

#include<conio.h>

void main()

inta,b;

clrscr();

printf("Enter two numbers");

scanf("%d%d",&a,&b);

if(a>b)

printf("a is greater");

else

printf("b is greater");

getch();

8
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

3.3: Write A Program To Find Greater Number Among Three Given Number Using

Nested If Condition.

#include<stdio.h>

#include<conio.h>

void main()

Int a,b,c;

clrscr();

printf("Enter three numbers");

scanf("%d%d%d",&a,&b,&c);

if(a>b)

if(a>c)

printf("a is greater");

else

9
PPS Lab DEEPAK KUMAR
(BTPS-102-18) (1803757)

printf("c is greater");

else

if (b>c)

printf("b is greater");

else

printf("c is greater");

getch();

10

You might also like