five veryy urgent super simple C questions
pleae find the attachment for the complete questoins as question 5 didn't fit here , just check the attach file and you can find all 5 questions there :)
this is very urgent so please do it very quick thanks alot.
1. (2 points) The exponential of a complex number, x+yi,
(where i is the square root of -1) is a complex number
given by the formula:
exp(x+yi) = exp(x)*cos(y) + exp(x)*sin(y)i
Develop a brief, console-based, ANSI C program that
prompts the user for a complex number and prints out
its complex exponential. The user's complex number
is to be read in as a string and parsed to extract
its real and imaginary parts, x and y, where x and y
are assumed positive for simplicity (see the console-
based Parsing Adder of the "Manipulating Strings"
lecture for inspiration with this). Examples of the
desired interactions are:
Enter a complex number: 1 + 0i
exp(1 + 0i) = 2.71828 + 0i
Enter a complex number: 0 + 1.5708i
exp(0 + 1.5708i) = 0 + 1i
Enter a complex number: 1 + 1.5708i
exp(1 + 1.5708i) = 0 + 2.7128i
Note that the input values are always full complex
numbers (not just a real or imaginary part) and so
are outputs. Verify that your porgram works and paste
its code below.
2. (2) What will be the value of the variable 'decision'
at the end of the following code segment (show your work)?
Assume that true has been defined as the integer value 1
and false was defined as zero.
criteria1 = true && false;
criteria2 = 100 >= 49 + 51 ;
criteria3 = !criteria1 && criteria2 ;
criteria4 = criteria1 || !criteria2 ;
decision = (criteria2 && !criteria1) || !(criteria4 && criteria3) ;
3. (2) What are conditional statements used for in a
4. (2) The code below is a parsing calculator that can
perform additions and subtractions (of positive
char op, * opa, uexpr;
float arg1, arg2, result;
printf("Enter an expression: ");
opa = strpbrk(uexpr,operators);
op = *opa;
*opa = 0;
sscanf(uexpr, "%g", &arg1);
sscanf(++opa, "%g", &arg2);
result = arg1 + arg2;
result = arg1 - arg2;
printf("%g %c %g = %g\n",arg1,op,arg2,result);
else puts("Bad expression");
If we want this code to also perform multiplications
and divisions, one line of code needs to be modified
and 6 lines of code need to be added. Write down the
updated line of code and the 6 new lines of code
needed to achieve this objective in the space below.
5. (2) develop a short console-based C program that
attempts comprehension of its user's mood. The
program should prompt its user for his/her mood
(a string, possibly with spaces between words)
and search the string for the words "good", "bad"
and "not". If "good" is found (without "not"),
or if both "not" and "bad" are found, then the
program should print "That is great!". On the
other hand, if "bad" is found (without "not") or
if both "not" and "good" are found, then the
program should print "Sorry to hear that.". If
neither of the above cases arise, the program
should print "Hmmmm...". Examples of desired
How's it going? good!
That is great!
How's it going? not too bad!
That is great!