You are on page 1of 10

ROLL NO: 1702910

PRACTICAL-1
AIM- Write a program to find reverse of a number.

#include<iostream.h>
#include<conio.h>
void main()
{
int rev=0,rem,n;
clrscr();
cout<<"Enter the number whose reverse you want to find"<<endl;
cin>>n;
while(n!=0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
cout<<"reverse of number is:-"<<endl;
cout<< rev<<endl;
getch();
}
ROLL NO: 1702910

OUTPUT:-
ROLL NO: 1702910

PRACTICAL-2
AIM- Write a program to print fabnocci series.

#include <iostream.h>
#include <conio.h>

int main()
{
int n, t1 = 0, t2 = 1, nextTerm = 0;
clrscr();

cout << "Enter the number of terms: ";


cin >> n;

cout << "Fibonacci Series: ";

for (int i = 1; i <= n; ++i)


{

if(i == 1)
{
cout << " " << t1;
continue;
}
if(i == 2)
{
cout << t2 << " ";
continue;
}
nextTerm = t1 + t2;
ROLL NO: 1702910

t1 = t2;
t2 = nextTerm;

cout << nextTerm << " ";


}
getch();
return 0;
}

OUTPUT:-
ROLL NO: 1702910

PRACTICAL-3
AIM- Write a program to swap two numbers.

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
cout<<"Enter the two numbers you want to swipe"<<endl;
cout<<endl;
cout<<"Enter the value of a:"<<endl;
cin>>a;
cout<<"Enter the value of b:"<<endl;
cin>>b;
c=a;
a=b;
b=c;
cout<<"numbers after swiping"<<endl;
cout<<"a= "<<a<<endl;
cout<<"b= "<<b<<endl;
getch();
}
ROLL NO: 1702910

OUTPUT:-
ROLL NO: 1702910

PRACTICAL-4
AIM- Write a program to swap two numbers without using third number.

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cout<<"Enter the two numbers you want to swipe"<<endl;
cout<<endl;
cout<<"Enter the value of a:"<<endl;
cin>>a;
cout<<"Enter the value of b:"<<endl;
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"Numbers after swiping are:"<<endl;
cout<<"a= "<<a<<endl;
cout<<"b= "<<b<<endl;
getch();
}
ROLL NO: 1702910

OUTPUT:-
ROLL NO: 1702910

PRACTICAL-5
AIM- Write a program to find factorial of a number.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num, i, fact=1;
cout<<"Enter a number : ";
cin>>num;
for(i=num; i>0; i--)
{
fact=fact*i;
}
cout<<"Factorial of "<<num<<" is "<<fact;
getch();
}
ROLL NO: 1702910

OUTPUT:-

You might also like