By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

help i hv that code but he is giving me an error in "if" help ;D

P: 1
#include<stdio.h>
#include<ctype.h>

int na
{
if(a<b && a<c)
printf("%d ",a);
else if(c<b)
printf("%d ",c);
else
printf("%d ",b);
}




[Error] expected primary-expression before 'if'

WHY IT GIVES ME THIS ERROR
Jan 8 '16 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
Is na supposed to be a function?

If it is, you need an argument list:

Expand|Select|Wrap|Line Numbers
  1. int na(...arguments go here...)
  2. {
  3. if(a<b && a<c)
  4. printf("%d ",a);
  5.  else if(c<b)
  6. printf("%d ",c);
  7. else
  8.  printf("%d ",b);    
  9. }
  10.  
You also need to define a,b,c, and d.

The compiler knew it was in trouble at the if. The actual error will be there or at some earlier place in the code. Just put your finger on the if and start looking backwards up the code.
Jan 9 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.