The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
1)Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "positive" otherwise. Example output when userVal = -9 for the below sample program:
-9 is negative.
#include <stdio.h>
#include <string.h>
int main(void) {
char condStr[50] = "";
int userVal = 0;
userVal = -9;
strcpy(condStr, /* Your solution goes here */);
printf("%d is %s.\n", userVal, condStr);
return 0;
}
2)
Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7. Hint: Start with "numUsers = ...".
#include
int main(void) {
int numUsers = 0;
int updateDirection = 0;
numUsers = 8;
updateDirection = 1;
/* Your solution goes here */
printf("New value is: %d\n", numUsers);
return 0;
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll