You are on page 1of 62

PROJECT

FILE
INTRODUCTION
Name: Vidhi Singh
Class: 11th-D
Roll no.: 11450
Subject: Computer
Technology
& Programming

Submitted to:
Mrs.Garima Saxena
Signature:
PREFACE
This project has covered the course of
class 11th Computer Technology and
Programming given by the Board of
Secondary Education, Rajasthan as an
optional subject. The programming is
prepared to make the student aware of
the knowledge based on 11th CTP course.
I have tried to concern the best
available source of information in the
respective subject for the completion
of this file. I have tried my level
best to include all topics covering
the syllabus. I look to all the
construction feedback and suggestions
for the improvement of this report.

Vidhi Singh
XI-D
ACKNOWLEDGEMENT
I would like to express my sincere
gratitude to my CTP teacher Mrs.
Garima Saxena for their vital support,
guidance and encouragement without
which this project would not have come
forth from my side.
I would respect our Principal sir Mr.
Pawan Maheshwari who has given us the
opportunity to have Computer
Technology and Programming as an
optional paper. He has put in all
efforts for the benefit of students
and provides us a wonderful
environment & required infrastructure.
I would like to thank my parents and
friends who have helped me with their
valuable suggestions and guidance
which has been helpful in various
phases of the completion of this
project.

Vidhi Singh
XI-D
CERTIFICATE
This is to certify that Ms.Vidhi Singh
daughter of Mr.Shailendra Singh bearing
roll no.:11450, has accomplished her
project based on the syllabus of 11th
Computer Technology & Programming.
According to the curriculum of Rajasthan
Board of Secondary Education, Ajmer of
standard 11th. This report has to be done
by the student opting CTP as an optional
subject. This project report is prepared
under the guidance and instructions of
Mrs. Garima Saxena. This project report
is complied with all the rules and
regulations lead by the Board of
Secondary Education, Ajmer, Rajasthan
for the session 2018-19.

Mrs.Garima Saxena Mr.Pawan Maheshwari


(Oftg. Principal)
FACULTY: Computer Technology & Programming

Date: / /
CONTENTS
1.About‘C’Language
2. Programming in ‘C’
Language
3.Object Oriented
Programming
4.Introduction to C++
5.programming in C++
ABOUT
LANGUAGE
ABOUT‘C’LANGUAGE
‘C’ is a programming language. ‘C’
language was first developed in 1972 by
Dennis Ritchie at A.T. Bell Labs.
Ritchie Called his newly developed
language ‘C’ simply because there was a
‘B’ programming language already, ‘C’
language is high level language. Infact
‘C’ is one of the most popular general
purpose programming language. It is a
case sensitive language. It has been
closely associated with the UNIX
operating system where it was developed,
since most of the programs that run on
it are written in ‘C’ language. It
supports to write high level as well as
low level language, therefore, it is
also known as middle level language. It
is highly portable, structured,
processor machine, independent and
platform independent language. It
supports primitive data type as well as
user defined data type for representing
complex data type as per user’s
requirement. It supports modular
programming. Due to this facility ,
program debugging is easy and simple to
write large programs in module.
 PROGRAM TO PRINT YOUR
NAME ON SCREEN

/*program to print your name*/


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("My name is Vidhi.");
getch();

output:

My name is Vidhi.
 PROGRAM TO CALCULATE SUM
OF ANY TWO NUMBERS

/*program to find sum of two


numbers*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first no.:");
scanf("%d",&a);
printf("Enter second no.:");
scanf("%d",&b);
c=a+b;
printf("Sum:%d",c);
getch();
}

Output:
Enter first no.:2
Enter second no.:2
Sum:4
 PROGRAM TO CALCULATE
SIMPLE INTEREST
/*Program to find simple interest*/
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,t,si=0;
clrscr();
printf("Enter principle:");
scanf("%d",&p);
printf("Enter rate of interst:");
scanf("%d",&r);
printf("Enter time:");
scanf("%d",&t);
si=(p*r*t)/100;
printf("Simple Interst:%d",si);
getch();
}

Output:
Enter principle:7
Enter rate of interest:7
Enter time:7
Simple Interest:3
TYPE CONVERSION OF
EXPRESSION
In computer science, type
conversion or typecasting refers to
changing an entity of one datatype into
another. There are two types of
conversion: implicit and explicit. The
term for implicit type conversion
is coercion. Explicit type conversion in
some specific way is known as casting.
Explicit type conversion can also be
achieved with separately defined
conversion routines such as an
overloaded object constructor.

1.IMPLICIT TYPE OF CONVERSION:


Implicit type conversion, also known
as coercion, is an automatic type
conversion by the compiler.
Some languages allow, or even require
compilers to provide coercion.
Eg. If a=7(int) & b=9.5(floating point)
Then, the value of expression is-
2*a+b will be 23.5000
2.EXPLICIT TYPE OF CONVERSION:
A cast, or explicit type conversion, is
special programming instruction which
specifies what data type to treat a
variable]] as (or an intermediate
calculation result) in a given expression.
Casting will ignore "extra" information
(but never adds information to the type
being casted). The C/C++ cast is either
"unchecked" or "bit pattern".
Eg. (float) a/b;
If a=7(int),b=3(int)
Then expression a/b will give the
Value integer 2 as the answer.
If we want to take answer in floating
Point then we have to write expression
I following way-
(float)a/b;
 PROGRAM TO EXPLAIN IMPLICIT AND
EXPLICIT CONVERSION

//Program to explain implicit and


explicit conversion//
#include<stdio.h>
#include<conio.h>
void main()
{
int a=7,b=8;
float x, y= 7.5;
clrscr();
x=a+y;
printf("x=%f",x);
x=(float)a/b;
printf("\n");
printf("x=%f",x);
getch();
}

Output:

X=14.500000
X=0.875000
CONTROL STATEMENT

‘C’ language executes the statements in


sequence as they have written. Every
statement executes only once. But some
programs uses decision logical condition
that which statement is to be executed
and which is not. This can be done by
‘if’ and ‘switch’ statements.
It executes the statements till logical
condition remains true is called
looping.
Control statement executes program
statement in sequence. Following control
statements are used in ‘C’ language:-
1. Decision making statement:
(a) if statement (b)if-else statement
(c) switch statement
2. Looping statement:
(a) for loop (b)while loop (c)do while
loop
3. Other control statement:
(a) break (b)continue (c) goto
If statement

It is a powerful control statement


which checks the condition first then
according to the result, statement
gets executed. if statements are of 4
types:-
1. Simple if statement
2. If-else statement
3. Nested if-else statement
4. Else-if stairs

(1)Simple if statement:
In this statement, condition is
checked first, if it is true then it
will executes statement group
otherwise not. Statements group can be
one or more than one statements.
SYNTAX:
If(condition)
{
Statement
}
 PROGRAM TO EXPLAIN SIMPLE IF
STATEMENT

/*Program to find whether the number


is even or not*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter number:");
scanf("%d",&n);
if(n%2==0)
printf("It is an even number.");
getch();
}

Output:
Enter number:16
It is an even number.
(2) if-else statement:
This statement tests a condition, if
the condition is true, then first
group of statement executes and if
false then second group executes.
SYNTAX:
if(condition)
{
Set of statement 1
}
Else
{
Set of statement 2
}
 PROGRAM TO EXPLAIN if-else
STATEMENT

/*Program to find greater between


two numbers*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter first number:");
scanf("%d",&a);
printf("Enter second number:");
scanf("%d",&b);
if(a>b)
printf("First number is greater.");
else
printf("Second number is greater.");
getch();
}

Output:
Enter first number:45
Enter second number:55
Second number is greater
(3)Nested if-else statement:
When a if-else statement is written
in another if-else, then it is
called as nested if-else statement.
SYNTAX:
if(condition 1)
{
if(condition 2)
{
Statement 1
}
else
{
Statement 2
}
else
{
Statement 3
}
else
{
Statement 4
}
PROGRAM TO EXPLAIN NESTED
if-else STATEMENT

/*Program to compare two numbers*/


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter first number:");
scanf("%d",&a);
printf("Enter second number:");
scanf("%d",&b);
if(a>b)
printf("First number is greater");
if(a==b)
printf("First number is equal to the
second");
else
printf(" second number is greater");
getch();
}
Output:
Enter first number:46
Enter second number:46
First number is equal to the second
(4)Statement else-if stairs:
These if statement are used to
multipurpose statements. This
statement is used when condition is
to be written result of one by one.
SYNTAX:
if(condition 1)
{
Statement 1
}
else if(condition 2)
{
Statement 2
}
else if(condition 3)
{
Statement 3
}
else
{
Statement 4
}
PROGRAM TO EXPLAIN STATEMENT
else-if stairs

/*Program to print result of a


student*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,sum=0;
float per;
clrscr();
printf("Marks in English:");
scanf("%d",&a);
printf("Marks in Maths:");
scanf("%d",&b);
printf("Marks in Science:");
scanf("%d",&c);
sum=a+b+c;
printf("Total:%d\n",sum);
per=(sum*100)/300;
printf("Percentage:%f\n",per);
if(per>=60)
printf("Result: First Division");
else if(per>=40)
printf("Result: Second Division");
else if(per>=36)
printf("Result: Third Division");
else
printf("Result: Fail");
getch();
}
Output:
Marks in English:89
Marks in Maths:91
Marks in Science:87
Total:267
Percentage:89.00
Result: First Division
Switch Statement

Switch case can be used to select


one option among multiple options.
It also included a condition like
if-else. Switch statement executes
various statements according to the
value of expression or variable. But
value of variable or expression
should be an integer or constant.
SYNTAX:
switch(variable o expression)
{
case value 1:no. of statements;
break;
case value 2:no. of statements;
break;
case value 3:no. of statements;
break;
case value n:no. of statements;
break;
default : no. of statements;
}
PROGRAM TO EXPLAIN switch
STATEMENT
/*Program to print name of the day according
to the given number from 1to 7*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter any number from 1 to 7:-");
scanf("%d",&n);
switch (n)
{
case 1:printf("Monday");
break;
case 2:printf("Tuesday");
break;
case 3:printf("Wednesday");
break;
case 4:printf("Thursday");
break;
case 5:printf("Friday");
break;
case 6:printf("Saturday");
break;
case 7:printf("Sunday");
default:printf("ERROR");
}
getch();
}

Output:
Enter any number from 1 to 7:-3
Wednesday
LOOPING

Some statements are require to run


more than once except decision
making statement in a program. In
some statements, execution is
repeated again and again.
 for loop
 while loop
 do-while loop
 Nested loop
for loop:
In this loop, if the condition is
true then loop will execute else
not.
SYNTAX:
for(exp 1;exp 2;exp 3)
{
Looping body
}
Where; exp 1:tells the initial value
of counter variable and it is
executed only once.
exp 2: It is a condition expression,
if it is true then loop will
execute.
Exp 3: It is used to increase or
decrease the value of counter
variable.
PROGRAM TO EXPLAIN for LOOP

/*Program to print your name 10


times*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<=9;i++)
printf("My name is Vidhi\n");
getch();
}

Output:
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
while loop:
While loop is entry controlled loop.
It is used when we don’t know how
many times a loop is to be executed.
Until the condition is true it will
execute otherwise the loop execution
will be stopped.
SYNTAX:
while (condition)
{
Looping body
}
 PROGRAM TO EXPLAIN while LOOP
/*Program to print numbers from 1 to
10*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
while(i<=10)
{
printf("%d\n",i);
i++;
}
getch();
}

Output:
1
2
3
4
5
6
7
8
9
10
do-while loop:
It is a exit controlled loop. In
this loop, first the loop body will
be executed and then the condition
will be checked, it means this loop
will execute at least one time. This
loop will be executed until the
condition is true otherwise it will
be terminated.

SYNTAX:
do
{
Loop body
}
while (condition);
PROGRAM TO EXPLAIN do-while LOOP

/*Program to print all even numbers


between 50 to 60*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i=50;
clrscr();
do
{
printf("%d\n",i);
i+=2;
}
while(i<=60);
getch();
}

Output:
50
52
54
56
58
60
Nested Loop:
A loop may contain another loop in
its body. This form of a loop is
called nested loop. But in a nested
loop, the inner loop must terminate
before the outer loop.

SYNTAX:
for (condition)
{
for (condition)
{
}
}
PROGRAM TO EXPLAIN NESTED LOOP
/*Program to print tables of 1 to
10*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=10;i++)
{
j=1;
while(j<=10)
{
printf("%d\t",i*j);
j++;
}
printf("\n");
}
getch();
}

OUTPUT:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
break statement:
Break statement enables to print a
program o skip over part of the
code. A break statement skips the
rest of the loop and jumps over to
the statement following the loop.
SYNTAX:
break;

continue statement:
The continue statement is another
jump statement somewhat like the
break statement as both of the
statements skip over a part of the
code. continue statement is little
different from break statement,
instead of forcing termination, it
forces the next round of the loop to
take place, skipping any code in
between.
SYNTAX:
continue;
PROGRAMMiN
g
IN
‘C’ LaNGUaGE
Array
An array is a finite collection of similar
or homogenous data stored in adjacent
memory locations. By finite means that
there are specific numbers of elements in
an array and by similar means that all the
elements in an array are of same type.
for eg. An array may contain all integers
and all characters but not both.

Declaration of array:
In declaration of array three things are
used:
1. Array type
2. Array name
3. Number of elements in array
When an array is declared then memory space
is allotted equal to the array size. Array
is declared as follows:
<Array type> <Array name> <[Size]>
Eg. int mark[50];
Here, int mark[50] tells that marks array
having size 50 and it can store integers.
Eg. float salary[100];
double total[20];
char emp-name[20];
Types of array:
Mainly array is of two types:
1. One dimensional array
2. Multi dimensional array

One dimensional array:


The simplest form of an array is one
dimensional array. It contains a row or a
column. The array itself is given a name
and its elements are referred to their sub-
scripts.
Eg. There are 50 students in a class, then
we will use one dimensional array to store
marks.
marks[0]=70
marks[1]=55
marks[2]=64
marks[3]=72
: :
marks[48]=48
marks[49]=57
Multi dimensional array:
It is an array which has two or more than
two dimensions.
Sometimes, it seems that one dimensional
array is not sufficient to store marks like
if a class has 20 students and we want to
store marks of 5 subjects ten we need a tab
(contain 20 row and 5 column). Multi
dimensional array is like which can have
two or more dimension.
SYNTAX:
Writing method of it is as follows:
<Array type> <Array name> [max limit 1]
[max limit 2] – [max limit n]
If it is two dimensional array then two
square brackets ([][])will come in array
name.
Eg. a[5][5] has first element a[0][0], then
second a[0][1]………a[4][4] will be last.
It has 5 rows and 5 columns:
0 1 2 3 4
0 9 6 16 24 61
1 16 72 95 97 55
2 49 57 40 45 25
3 29 64 5 18 2
4 10 12 98 59 26
Function

It is difficult to make a large program of


‘C’ language so it is divided into small-
small parts. These parts complete an
operation. These parts can be join in
sequence to solve a complex problem.
It is in all high level language that
parts of statements can be written
independently with separate name and
whenever or number of times that part is
required can be called. These independent
parts are known as sub program or function.
To solve problem, we can make separate
program segment. These segments are known
as function. It can be defined as –
“A function is a self contained program
segment that is used for some specific well
defined task.”
Categories of Function
Functions can be divided into following
categories according to sending parameters-
1. Function with no arguments and no return
values:-
In these type of functions we are not
sending any paraments and the function is
also not returning any value. In this
category, control flow moves from main
function to user defined function and user
defined function to main function. No data
is used with it. This category is used to
transfer a control from one place to
another.
2. Function with arguments but no return
values:-
In this category during calling a function
we sends arguments from the main function,
but function is not returning any value to
main function. In this data is read in main
function and later on sends to user defined
function.
3.Function with arguments and return
value:-
In this category while calling the user
defined function, actual parameter are send
and which can hold by the formal
parameters. When execution of user defined
function completes then control come back
to main function with return value.

Structure
We have learnt about array which can store
one type of element. But structure can
contain various types of element. So in a
structure a user can use int, float,
double, char & array data. Every element of
structure is known as member.
Declaration of structure:-
Declaration of structure is difficult
because it declares each member in
structure- syntax for declaring a structure
is-
struct <tag>
{
<data type> member 1;
<data type> member 2;,member 3;
………………………………………
………………………………………
<data type> member n;
};
In above structure struct is a keyword. Tag
is a identifier of structure & member 1 ,
member 2 ,…… member n are declared as
different – different members.

Program to explain structure:-


/*Structure 'student' to print name, roll no. and marks
of two subjects*/
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
char name[20];
int roll;
int physics;
int chemistry;
};
struct student s1;
clrscr();
printf("Name:");
gets(s1.name);
printf("Roll no.:");
scanf("%d",&s1.roll);
printf("Physics:");
scanf("%d",&s1.physics);
printf("Chemistry:");
scanf("%d",&s1.chemistry);
printf("Name of the student:%s",s1.name);
printf("\nRoll no. of the student:%d",s1.roll);
printf("\nMarks in Physics:%d",s1.physics);
printf("\nMarks in Chemistry:%d",s1.chemistry);
getch();
}

OUTPUT:
Name:vidhi singh

Roll no.:50

Physics:55

Chemistry:78

Name of the student:Vidhi singh


Roll no. of the student:50

Marks in Physics:55

Marks in Chemistry:78

Object
Oriented
Programming
Object Oriented Programming

Object-oriented programming (OOP) is
a programming paradigm based on the concept of
"objects", which may contain data, in the form
of fields, often known as attributes; and code,
in the form of procedures, often known
as methods. A feature of objects is that an
object's procedures can access and often modify
the data fields of the object with which they are
associated (objects have a notion of "this" or
"self"). In OOP, computer programs are designed
by making them out of objects that interact with
one another.[1][2] There is significant diversity
of OOP languages, but the most popular ones
are class-based, meaning that objects
are instances of classes, which typically also
determine their type.
Many of the most widely used programming
languages (such as C++, Object Pascal, Java,
Python etc.) are multi-paradigm programming
languages that support object-oriented
programming to a greater or lesser degree,
typically in combination
with imperative, procedural programming.
Significant object-oriented languages
include Java, C++, C#, Python, PHP, JavaScript, R
uby,Perl, Object Pascal, Objective-
C, Dart, Swift, Scala, Common Lisp, and
Smalltalk.
Object-oriented programming uses objects, but not
all of the associated techniques and structures
are supported directly in languages that claim to
support OOP. The features listed below are,
however, common among languages considered
strongly class- and object-oriented (or multi-
paradigm with OOP support), with notable
exceptions mentioned.
Features of Object Oriented Programming :-

ABSTRACTION AND ENCAPSULATION:


Combining data and functions into a
single unit called class and the process
is known as Encapsulation. Data
encapsulation is important feature of a
class. Class contains both data and
functions. Data is not accessible from
the outside world and only those
function which are present in the class
can access the data. The insulation of
the data from direct access by the
program is called data hiding or
information hiding. Hiding the complexity
of program is called Abstraction and only
essential features are  short we can say
that internal working is hidden.
INHERITANCE: it is the process by which
object of one class aquire the properties
or features of objects of another class.
The concept of inheritance provide the
idea of reusability means we can add
additional features to an existing class
without Modifying it. This is possible by
driving a new class from the existing
one. The new class will have the combined
features of both the classes.
Example: Robine is a part of the class
flying bird which is again a part of the
class bird.
POLYMORPHISM: A greek term means ability
to take more than one form. An operation
may exhibit different behaviours in
different instances. The behaviour
depends upon the types of data used in
the operation.
Reusability:
Reusability is nothing but re- usage of
structure without changing the existing
one but adding new features or
characteristics to it. It is very much
needed for any programmers in different
situations.
It helps in reducing the code size since
classes can be just derived from existing
one and one need to add only the new
features and it helps users to save their
time.
Introduction
to ‘C++’
C++
C++  is a general-purpose programming language. It
has imperative, object-oriented and generic programmi
ng features, while also providing facilities for low-
level memory manipulation.
It was designed with a bias toward system
programming and embedded, resource-constrained and
large systems, with performance, efficiency and
flexibility of use as its design highlights.[6] C++
has also been found useful in many other contexts,
with key strengths being software infrastructure and
resource-constrained applications,
[6]
 including desktop applications, servers (e.g. e-
commerce, Web search or SQL servers), and
performance-critical applications (e.g. telephone
switches or space probes).[7] C++ is a compiled
language, with implementations of it available on
many platforms. Many vendors provide C++ compilers,
including the Free Software
Foundation, Microsoft, Intel, and IBM.
C++ is standardized by the International Organization
for Standardization (ISO), with the latest standard
version ratified and published by ISO in December
2017 as ISO/IEC 14882:2017 (informally known as C+
+17).[8] The C++ programming language was initially
standardized in 1998 as ISO/IEC 14882:1998, which was
then amended by the C++03, C++11 and C++14 standards.
The current C++17standard supersedes these with new
features and an enlarged standard library. Before the
initial standardization in 1998, C++ was developed
by Bjarne Stroustrup at Bell Labs since 1979, as an
extension of the C language as he wanted an efficient
and flexible language similar to C, which also
provided high-level features for program
organization.  C++20 is the next planned standard
[9]

thereafter.
Many other programming languages have been influenced
by C++, including C#, D, Java, and newer versions of
C.
Programming
in ‘C++’
Programs:

1.Program to print your name.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"My name is Vidhi Singh";
getch();
}

OUTPUT:

My name is Vidhi Singh


2. Program to find sum of two
numbers.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter first no.:";
cin>>a;
cout<<"Enter second no.:";
cin>>b;
c=a+b;
cout<<"Sum:"<<c;
getch();
}

OUTPUT:
Enter First no.:2
Enter second no.:2
Sum:4
3.Program to find area of rectangle.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int l,b,area=0;
cout<<"Enter length of the
rectangle:";
cin>>l;
cout<<"Enter breadth of the
rectangle:";
cin>>b;
area=l*b;
cout<<"Area of the
Rectangle:"<<area;
getch();
}

OUTPUT:
Enter length of the rectangle:2
Enter breadth of the rectangle:1
Area of the rectangle:2
4.Program to find area of square.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int s,area=0;
cout<<"Enter side of the square:";
cin>>s;
area=s*s;
cout<<"Area of the Square:"<<area;
getch();
}

OUTPUT:
Enter side of the square:3
Area of the square:6
5. Program to find area of circle.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int r,area=0;
cout<<"Enter radius of the circle:";
cin>>r;
area=22.7*r*r;
cout<<"Area of the circle:"<<area;
getch();
}

OUTPUT:
Enter radius of the circle:4
Area of the circle:363
6. Program to find Simple Interest.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int p,r,t,si=0;
cout<<"Enter Principle:";
cin>>p;
cout<<"Enter rate:";
cin>>r;
cout<<"Enter time:";
cin>>t;
si=(p*r*t)/100;
cout<<"Simple Interest:"<<si;
getch();
}

OUTPUT:
Enter Principle:5000
Enter rate:5
Enter time:5
Simple Interest:60
7. Program to find greater between
two numbers.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter a:";
cin>>a;
cout<<"Enter b:";
cin>>b;
if(a>b)
cout<<"a is greater";
else
cout<<"b is greater";
getch();
}

OUTPUT:
Enter a:4
Enter b:9
b is greater
8. Program to print your name 10
times.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
for(i=0;i<10;i++)
cout<<"My name is Vidhi\n";
getch();
}

OUTPUT:

My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
My name is Vidhi
9. Program to find given no. is even
or odd.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n;
cout<<"Enter number:";
cin>>n;
if(n%2==0)
cout<<"Number is even";
else
cout<<"Number is odd";
getch();
}

OUTPUT:
Enter number:66
Number is even
10. Program to print all even
numbers between 2 & 20.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
for(i=2;i<=20;i+=2)
{
cout<<i;
cout<<"\n";
}
getch();
}

OUTPUT:
2
4
6
8
10
12
14
16
18
20

You might also like