#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class converter{
private:
int x,y;
public:
int get(int);
}a;
int converter::get(int y)
{
cout<<"Please enter the height of a person in inches:";
cin>>x;
y=x/12;
return(y);
}
void main()
{
cout<<setw(55)<<"BISMILLAH HI REHMAN NI RAHIM:\n";
int b;
b=a.get(y);
cout<<b;
getch();
}
#include<iostream.h> iostream.h is non-standard and hasn't been seen since about 1998. Is is called <iostream> now. Please stop using whatever ancient compiler you are using and get something modern and correct for free.
#include<conio.h> This is non-standard and you shouldn't rely on it existing.
#include<iomanip.h> iomanip.h is non-standard and hasn't been seen since about 1998. Is is called <iomanip> now. Please stop using whatever ancient compiler you are using and get something modern and correct for free.
A modern compiler will refuse to compile your program for many reasons.
void main()
This is wrong. main returns an int. Always.
y=x/12;
This is an int divided by an int, which will give you an int. What is 14/12? One. What is 23/12? One. If you want to work with numbers that are not integers, don't use ints.
thanks for quick reply.can you plz tell me how to return value and how can we write parameters.should they be the same as the variables or can be different? i have been struggling to understand it for a long time but can't understand it.
and how can we write parameters.should they be the same as the variables or can be different? i have been struggling to understand it for a long time but can't understand it.
/*
return type
| formal parameter i
| | formal parameter f
| | | */
double function(int i, float f)
{
// local variables
double d=0.1;
constunsignedint ui = 32;
// you can use formal parameters as if they're local variables
d *= f + i * ui;
return d; // return a value
}
int main()
{
// local variables
int a;
float b;
/*
function call
|
local | actual parameter a
variable r | |
| | | actual parameter b
| | | | */
double r = function(a, b)
}
The purpose of namespace std; is that you don't have to write std::cout or std::cin every time you want to use input or output operations. It's mostly a convenient thing