reciprocal of user inputted number

I've been working on this program and I have it all pretty much down, but I just need one thing that I can't, for the life of me, think of! I need to find the reciprocal of a number that the user inputted (ex: if user input was 2 output would be 0.5 or if input was .6, out put would be 1.6 repeating). If theres a simple way, I can't think of it. Thanks.
Last edited on
how do you find the reciprocal of a number mathematically? divide 1 by the number

so 1/(n/d)
will be d/n
closed account (18hRX9L8)
1
2
3
4
5
6
7
8
9
10
#include <iostream>

main()
{
	double usernum,reciprocal;
	std::cout<<"What number do you want to get the reciprocal of?  ";
	std::cin>>usernum;
	reciprocal=1/usernum;
	std::cout<<"The reciprocal of "<<usernum<<" is "<<reciprocal<<".";
}
Topic archived. No new replies allowed.