Basic statements and expressions. Trace (show a \"memory snapshot\") the followi
ID: 3886231 • Letter: B
Question
Basic statements and expressions. Trace (show a "memory snapshot") the following statements by hand, showing your work: int f = 4, g = 2, h: double r = 2.5, q: h = f + r/g: g++: q = h%g*2: r = f -(g -7)*q-h: Translate the following into equivalent C statements: a. Declare a variable named tickets and assign to it a whole number between 1 and 10 b. Double the current value of tickets and assign the new value back to tickets. c. Declare a variable named cost and assign the cost of a recent ticket you purchased for some event. The cost variable should be able to store fractions of dollars as well as whole dollars. Assume that the following statement has been executed: int boxes = 12: The statement which would correctly display the value of boxes is (circle the letter of the correct answer): printf("%d", boxes): printf"%d", &boxes;): scanf("%d", &boxes;): printf("%f", boxes);Explanation / Answer
1.
#include <stdio.h>
int main(void) {
int f=4,g=2,h;
double r=2.5,q;
h=f+r/g;
g++;
q=h%g*2;
r=f-(g-7)*q-h;
printf("h value %d",h);
printf(" f value %d",f);
printf(" g value %d",g);
printf(" r value %d",r);
printf(" q value %d",q);
return 0;
}
Output:
2.
#include <stdio.h>
int main(void) {
int tickets;
int doubletickets;
float cost;
printf("Enter the number between 1-10");
scanf("%d",&tickets);
doubletickets=tickets*tickets;
tickets=doubletickets;
cost=tickets;
printf(" The ticket cost is %f",cost);
return 0;
}
Output:
3.
Answer: A
#include <stdio.h>
int main(void) {
int boxes=12;
printf("%d",boxes);
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.