Wednesday, December 10, 2014

Program To Find Out The Final Velocity Of A Body Using Linear Motion Equation

To Know About Linear Motion Click Here



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr()
float v,u,a,t;
cout<<"Enter the initial velocity : ";
cin>>u;
cout<<"Enter the acceleration : ";
cin>>a;
cout<<"Enter the time : ";
cin>>t;
v=u+a*t;
cout<<"The final velocity is : "<<v;
getch();
}


Input

Enter the initial velocity : 5
Enter the acceleration : 2
Enter the time : 10

Output

The final velocity is : 25

Wednesday, November 20, 2013

Program to print the first 10 lines of Pascal's Triangle


#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
long triangle(int x,int y);
int main()
{
clrscr();
const lines=10;
for (int i=0;i<lines;i++)
for (int j=1;j<lines-i;j++)
cout << setw(2) << " ";
for (int j=0;j<=i;j++)
cout << setw(4) << triangle(i,j);
cout << endl;
getch();
}
long triangle(int x,int y)
{
if(x<0||y<0||y>x)
return 0;
long c=1;
for (int i=1;i<=y;i++,x--)
c=c*x/i;
return c;
}

To know about Pascal's Triangle Click Here

Friday, October 11, 2013

Program to find out Economic Order Quantity (EOQ)

Economic Order Quantity is the size of order that gives maximum economy in purchasing the materials. It is also known as Standard Order Quantity.
To know more about EOQ click here

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float eoq,co,ch,d;
cout<<"Enter the ordering cost : ";
cin>>co;
cout<<"Enter the holding cost : ";
cin>>ch;
cout<<"Enter the annual demand : ";
cin>>d;
eoq=sqrt((2*co*d)/ch);
cout<<"Economic Order Quantity = "<<eoq;
getch();
}



Wednesday, October 2, 2013

Program to find out the Torque developed in a shaft

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p,n,t;
cout<<Enter the Power transmitting by the shaft in kilowatt : ";
cin>>p;
cout<<Enter the speed of the shaft in revolutions per minute : ";
cin>>n;
t=(p*60)/(2*3.14*n);
cout<<"The Torque developed in shaft is : "<<t<<"\t"<<"KNm";
getch();
}


Wednesday, August 21, 2013

Program to illustrate the working of new and delete operators

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
cout<<"Enter the number of students in the class : ";
cin>>n;
int *p=new int[n];
int *q=new int[n];
cout<<"Input the class numbers : ";
for(i=0;i<n;i++)
cin>>*(p+i);
cout<<"Input the marks : ";
for(i=0;i<n;i++)
cin>>*(q+1);
cout<<"The list of students with marks : ";
for(i=0;i<n;i++)
cout<<"\n"<<*(p+i)<<"\t"<<*(q+i);
delete [] p;
delete [] q;
getch();
}

For more details about pointers click here

Wednesday, August 7, 2013

Program for Newton's Law of Gravitation

In this program user inputs the mass of two bodies and the distance between them and calculate and output the Force of attraction between two masses according to Newton's law of gravitation.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float f,m1,m2,r;
cout<<"Enter the value of two masses in Kg : ";
cin>>m1>>m2;
cout<<"Enter the distance between two masses in meters : ";
cin>>r;
f=(6.67*pow(10.0,-11.0)*m1*m2)/(r*r);
cout<<"The force of attraction between two masses = "<<f<<" Newton ";
getch();
}

Program to delete an element from an array

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int s,n,i,p,a[50];
clrscr();
cout<<"Enter number of students : ";
cin>>n;
cout<<"Enter the marks : ";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the marks to be deleted : ";
cin>>s;
for(i=0;i<n;i++)
if(a[i]==s)
    {
     p=i;
     break;
    }
for(i=p;i<n-1;i++)
a[i]=a[i+1];
cout<<"The new mark list is : ";
for(i=0;i<n-1;i++)
cout<<a[i];
getch();
}