Decimal Problem

Having a problem with my code... its not showing the decimal point when its outputted? anybody have any of suggestions why this is happens and how I could fix this?


#include<stdlib.h>
#include<iostream.h>
#include<iomanip.h>
#include<math.h>

int main()
{
int hold;
double num;


for (int i=1; i<100; i++)
{

num = 1/i;
cout<<setprecision(9)<<num<<"\n";

num == 0;

}

cin>>hold;
}
1/i is an integer division, and is always 0 unless i is 1. Use 1f/i or 1.0/i or something like that.
Thanks works now :)
Topic archived. No new replies allowed.