1.
Arithmetic
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a,b,c,d,e,f;
cout<<”Enter the Values”;
cin>>a>>b;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
cout<<”Addition is”<<c;
cout<”Subtraction”<<d;
cout<<”Multiplication”<<e;
cout<<”Division”<<f;
getch();
}
2. Area
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a,b,c,d,e,f;
cout<<”Enter the Values”;
cin>>a>>b;
c=3.14*a*a;
d=a*b;
e=0.5*a*b;
f=a*a
cout<<”Area of circle is”<<c;
cout<”Area of rectangle”<<d;
Prof :- Siddhesh Naik
cout<<”Area of traingle”<<e;
cout<<”Area of square”<<f;
getch();
}
3. Swapping
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a,b,c;
cout<<”Enter the Values”;
cin>>a>>b;
c=a;
a=b;
b=c;
cout<<”First Value is ”<<a;
cout<”Second Value is”<<b;
getch();
}
4. Celsius to Ferrante
#include<iostream.h>
#include<conio.h>
Void main()
{
Int c,f;
cout<<”Enter the temp in celsius”;
cin>>c;
f=c*(9/5)+32
//Note( c=(5/9)*(f-32))
cout<<”In ferranate”<<f;
getch();
Prof :- Siddhesh Naik
}
5. Even / Odd
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a;
cout<<”Enter the temp in celsius”;
cin>>a;
if(a%2==0)
{
cout<<”Even”;
}
Else
{
cout<<”Odd”>;
}
getch();
}
6. Smallest / Largest(Two numbers)
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a,b,c;
cout<<”Enter the Values”;
cin>>a>>b;
if(a<b)
{
cout<<”Smallest”<<a;
cout<<”Largest”<<b;
Prof :- Siddhesh Naik
}
Else
{
cout<<”Smallest”<<b;
cout<<”Largest”<<a;
}
getch();
}
7. Factorial
#include<iostream.h>
#include<conio.h>
Void main()
{
Int no,i,ans=1;
cout<<”Enter the Values”;
cin>>no;
for(i=1;i<=no;i++)
{
ans=ans*i;
}
cout<<”Factorial is”<<ans;
getch();
}
8. Prime Or Not
#include<iostream.h>
#include<conio.h>
Void main()
{
Int no,i;
cout<<”Enter the Values”;
Prof :- Siddhesh Naik
cin>>no;
for(i=2;i<no;i++)
{
if(no%i==0)
{
cout<<”Not Prime”;
break;
}
}
if(i==no)
{
cout<<”Prime”;
}
getch();
}
9. Fibonacci Series ( 0+1+1+2+3+.....+n)
#include<iostream.h>
#include<conio.h>
Void main()
{
Int fo=0,f1=1,fib;
cout<< fo<< f1;
while(fo<=15)
{
fib=f0+f1;
cout<<fib;
fo=f1;
f1=fib;
}
getch();
}
10. Reverse(Ex:- no=123 then rev=321)
Prof :- Siddhesh Naik
#include<iostream.h>
#include<conio.h>
Void main()
{
Int no,rev=0,rem;
cout<<”Enter the Values”;
cin>>no;
while(no!=0)
{
rem=no%10;
rev=rev*10+rem;
no=no/10;
}
cout<<”Reverse is ”<<rev;
getch();
}
11. Sum(Ex:- no=123 then sum=1+2+3)
#include<iostream.h>
#include<conio.h>
Void main()
{
Int no,sum=0,rem;
cout<<”Enter the Values”;
cin>>no;
while(no!=0)
{
rem=no%10;
sum=sum+rem;
no=no/10;
}
cout<<”sum is ”<<sum;
getch();
Prof :- Siddhesh Naik
}
12. GCD between two no’s
#include<iostream.h>
#include<conio.h>
Void main()
{
Int a,b,;
cout<<”Enter the Values”;
cin>>a>>b;
while(a!=b)
{
if(a>b)
{
a=a-b;
}
else
{
b=b-a;
}
}
cout<<GCD is”<<a;
getch();
}
13. Table of Given Number
#include<iostream.h>
#include<conio.h>
Void main()
{
Int no,i,ans;
cout<<”Enter the Values”;
Prof :- Siddhesh Naik
cin>>no;
for(i=1;i<=10;i++)
{
ans=no*i;
cout<<”\n”<<ans;
}
getch();
}
14. Ascending (Bubble sort Method)
#include<iostream.h>
#include<conio.h>
void main( )
{
int a[10],i,j,c;
cout<<”enter the elements in the array”;
for(i=0;i<=9;i++)
{
cin>>a[i];
}
for(j=0;j<=9;j++)
{
for (i=0;i<=9;i++)
{
if ( a[i]>a[i+1])
{
c=a[i];
a[i]=a[i+1];
a[i+1]=c;
}
}
}
cout<<”the elements in the ascending order is “;
for (i=0;i<=9;i++)
Prof :- Siddhesh Naik
{
cout<<”\n”<<a[i];
}
getch();
}
Prof :- Siddhesh Naik