Hi I wrote a program for a programming class in which we had to make a test in which to see what an earthquake is on a richter scale. Here it is:
#include "stdafx.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
int n = 0;
if(n <= 5.0)
{
printf("There is little or no damage dealt by the earthquake!");
}
else
{
if(n >= 5.0 && n < 5.5)
{
printf("Some damage was dealt by the earthquake!");
}
else
{
if(n >= 5.5 && n < 6.5)
{
printf("Serious damage was dealt as a result of the earthquake!");
}
else
{
if(n >= 6.5 && n < 7.5)
{
printf("Major disator from the earthquake!");
}
else
{
if(n>7.5)
{
printf("There is a state of emergency because the earthquake has totaled most buildings!!");
}
}
}
}
}
return 0;
}
My question is how do I make a random number between 1 and 8 including both 1 and 8 and assigning it to n so it really shows how the program works and if I do stuff like this it's worth xtra credit. I sorta need it b\c the teacher sucks and doesn't really state clearly when we have assignments. Thanks ^_^