Need help with if else statement

What I'm trying to achieve is to not allow the denominator to be 0. So I am trying to make the denominator default to 1 if I was to enter 0 for the it. I need help with my if else statement, on my compiler it keeps saying "expected ';' before else". Also the if statement won't run correctly even if I took out "else".

Thanks a bunch in advance.

1
2
3
4
5
6
7
8
printf(" Enter the stock ticker... ");
scanf("%s",&Ticker[0]);
printf(" Enter the price of %s: ");
scanf(" %d %d/%d",&whole,&num,&dem);
  if (dem == 0);
    {"%d",&dem = 1;}
  else      
    {pricePerShare = whole + (float)num/dem;}


1
2
if (dem == 0);
    {dem = 1;}


Stop using printf and scanf. They're confusing you.
Last edited on
Thanks a bunch. That fixed my problem. I'm only using printf and scanf because my professor wants me to use C first before going into C++.
Topic archived. No new replies allowed.