Write an if/else statement that compares the value of the variables soldYesterday and soldToday , and based upon that comparison assigns salesTrend the value -1 ( soldYesterday greater than soldToday ) or 1 .

i wrote:

if (soldYesterday > soldToday)
{
		salesTrend = -1||0;
}

and its coming out incorrect, any ideas?

Recommended Answers

All 2 Replies

Try to use if..else.

if (soldYesterday > soldToday)
 {
   /* statements */
   }
else
 {
  /* statements */
 }

If your aim is to do the thing in one line, you can use ?:

salesTrend = (soldYesterday > soldToday) ? -1 : 0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.