CSI_Pract_1_2
CSI_Pract_1_2
e
Day
un
5 Functions in C++
n ,P
6 Function Overloading
ga
be
7 Function calling: Call by
m
reference & Call by value
,A
8 Recursive Functions
r.)
9 Arrays in C++
(J
&C
12 Calculator Application
SC
1
SECTION-I C++ Programming
Program no. 1
• Write a program in c++ that adds and subtracts the given two numbers and
display the sum and difference.
• Enter the program and verify the execution of the same on the computer.
Source program
e
#include <iostream.h>
un
#include <conio.h>
,P
void main ()
{
n
ga
int a,b,c,d;
clrscr ();
be
cout<<"Enter value of a := ";
m
cin>>a;//4
,A
c=a+b
(J
&C
}
SC
2
Program no. 2
e
void main ()
un
{
int a,b;
,P
clrscr ();
n
cout<<"Enter value of a := ";
ga
cin>>a;//4 be
cout<<"Enter value of b := ";
cin>>b; //7
m
,A
if(a>b) //condition
r.)
{
(J
else
AS
{
cout<<”b is greater than a”;
O
}
SC
Explanation
Is(condition) is true
Execute the code
Otherwise
Execute the another code
3
include <iostream.h>
#include <conio.h>
void main ()
{
int a,r;
clrscr ();
cout<<"Enter value of a := ";
cin>>a;//4
r=a%9; //remainder
if(r==0) //condition
{
cout<<”a is divisible by 9”;
}
e
else
un
{
,P
cout<<”a is not divisible by 9”;
}
n
ga
}
be
m
,A
r.)
(J
&C
AS
O
SC