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();
}