c++ program running difficulty

I am facing running problems in the following programmes kindly give some solutions.I will be very grateful.These 6 programmes are to be submitted soon:

1)
#include<iostream.h>
#include<conio.h>
struct student
{
int rno;
char name[20];
float mark;
}s[5];
void main()
{
clrscr();
cout<<"Enter the r no\nEnter the name\nEnterthe mark";
for(int i=1;i<=5;i++)
{
cin>>s[i].rno>>s[i].name>>s[i].mark;
}
cout<<"The no is\nThe name is\nThe mark is";
for(i=1;i<=5;i++)
{
cout<<s[i].rno<<s[i].name<<s[i].mark;
}
getch();
}


2)
#include<iostream.h>
#include<conio.h>
#include<math.h>
float area(float a,float b,float c)
{
float s,ar;
ar=sqrt(s*(s-a)*(s-b)*(s-c));
return ar;
}
float area(float a,float b)
{
return a*b;
}
float area(float a)
{
3.14*a*a;
return a;
}
void main()
{
clrscr();
int choice,s1,s2,s3,ar;
char ch;
do
{
cout<<"\nArea Main Menu\n";
cout<<"1.Triangle\n";
cout<<"2.Rectangle\n";
cout<<"3.Circle\n";
cout<<"Enter your choice";
cin>>ch;
switch(choice)
{
case 1:cout<<"Enter the three sides\n";
cin>>s1>>s2>>s3;
ar=area(s1,s2,s3);
cout<<"The area is"<<ar<<"\n";
break;
case 2:cout<<"Enter length and breath\n";
cin>>s1>>s2;
ar=area(s1,s2);
cout<<"The area is"<<ar<<"\n";
break;
case 3:cout<<"Enter the radius\n";
cin>>s1;
ar=area(s1);
cout<<"The area is"<<ar<<"\n";
break;
case 4:break;
default:cout<<"Wrong choice!!\n";
}
}while(choice>0&&choice<4);
getch();
}


3)
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class student
{
int rno;
char name[20];
int age;
public:
void getdata();
void display();
};
void student::getdata()
{
cout<<"Enter your roll no";
cin>>rno;
cout<<"Enter your name";
gets(name);
cout<<"Enter your age";
cin>>age;
}
void student::display()
{
cout<<rno;
puts(name);
cout<<age;
}
void main()
{
clrscr();
student s,s1;
s.getdata();
s.display();
s1.getdata();
s1.display();
getch();
}


4)
#include<iostream.h>
#include<conio.h>
class Deposit
{
long int principal;
int time;
float rate;
float total_amt;
public:
Deposit();
Deposit(long p,int t,float r);
Deposit(long p,int t);
Deposit(long p,float r);
void calc_amt(void);
void display(void);
};
Deposit::Deposit()
{
principal=time=rate=0.0;
}
Deposit::Deposit(long p,int t,float r)
{
principal=p;
time=t;
rate=r;
}
Deposit::Deposit(long p,int t)
{
principal=p;
time=t;
rate=0.08;
}
Deposit::Deposit(long p,float r)
{
principal=p;
time=2;
rate=r;
}
void Deposit::calc_amt(void)
{
total_amt=principal+(principal*time*rate)/100;
}
void Deposit::display(void)
{
cout<<"\nPrincipal Amount"<<principal;
cout<<"\nPeriod of Investment:"<<principal;
cout<<"\nRate of Interest"<<rate;
cout<<"\tTotal Amount:Rs"<<total_amt<<"\n";
}
void main()
{
clrscr();
Deposit D1,D2(2000,2,0.07f),D3(4000,1),D4(3000,0.12f);
D1.calc_amt();
D2.calc_amt();
D3.calc_amt();
D4.calc_amt();
cout<<"Object1\n";D1.display();
cout<<"Object2\n";D2.display();
cout<<"Object3\n";D3.display();
cout<<"Object4\n";D4.display();
getch();
}



5)
#include<iostream.h>
#include<conio.h>
int Lsearch(int[],int,int);
void main()
{
int AR[50],item,N,index;
cout<<"Enter dasired array size(max.50)...";
cin>>N;
cout<<"\nEnter Array Elements";
for(int i=0;i<N;i++)
{
cin>>AR[i];
}
cout<<"\nEnter Element to be searched for...";
cin>>item;
index=Lsearch(AR,N,item);
if(index==-1)
cout<<"\nSorry!!Given element could not be found";
else
cout<<"\nElementfound at index:"<<index<<",Position:"<<index+1<<endl;
}
int Lsearch(int AR[],int size,int item)
{
for(int i=0;i<size;i++)
{
if(AR[i]==item)
return i;
}
return-1;
}



6)
#include<iostream.h>
#include<conio.h>
#include<process.h>
int Bsearch(int AR,int size,int item)
{
int beg,last,mid;
beg=0;
last=size-1;
while(beg<=last)
{
mid=(beg+last)/2;
if(item==AR[mid])
{
return mid;
}
else if(item>AR[mid])
{
beg=mid+1;
}
else
{
last=mid-1;
}
}
return-1;
}
void main()
{
int AR[50],item,N,index;
cout<<"Enter desired array size(max.50)...";
cin>>N;
cout<<"\nEnter Array Elements(must be sorted in Asc order)\n";
for(int i=0;i<N;i++)
cin>>AR[i];
cout<<"\nEnter Element to be searched for....";
cin>>item;
index=Bsearch(AR,N,item);
if(index==-1)
cout<<"\nSorry!Given element could not be found";
else
cout<<"\nElement found at index:"<<index<<",Position:"<<index+1<<endl;
}

Please, use code tags. Specify, what is the problem with each program.
And please: It's <iostream>, not <iostream.h> and int main(), not void main()
Topic archived. No new replies allowed.