Consider the following:
#include <stdio.h>
int main()
{
int first=9;
int second=0;
double ratio;
if(second==0)
ratio="n/a";
else
ratio=(double)singularCount/pluralCount;
printf("ratio is: %f", ratio);
return 0;
}
This obviously wont run as it should.
How can I modify my code/print statement to print a float if there are no problems, and n/a if there is division by 0?
I will be printing many of these ratios in a list, so I'd like to see "n/a" when there is division by 0.
Desired Output:
ratio is: n/a