Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Show the result of the following code segment. Each dash below is character spac

ID: 3888270 • Letter: S

Question

Show the result of the following code segment. Each dash below is character space on the screen. Place the output into the exact space where the program would output it. int value 11, price double cost- 14.5, discount = 9.0; price 12 discount -6.0 printf "Inprice-810dIn", price)a printf( "cost-%.2f ", cost); printf( %14.2f f" , 42.98765 , 687.549354); cost -8.5: value = cost -discount; price price - cost; cost value discount price printf There are 5dmore In numbers...In"8215379) printf Here are the answers ") printf( " %d %d %d ", 9, price , 2017); printf "value Int1odIn", value) //discount cost / 2; printf( "discount=%8.2f ", discount);

Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
int main()
{
int value=11, price;//value is 11
double cost=14.5 , discount=9.0;
price =12;
  
discount=6.0;//now discount is 6.0 insted of 9.0
  
printf(" price = %10d ",price);//it will take 10 characterspace before printing it
  
printf("cost = %.2f ",cost);//cost will be printed up to two decimal points so 14.50 will be the output , if it's %.5f then output would be 14.50000
  
printf("%14.2f %13f",42.98765, 687.549354);
  
//14.4f means 14 characterspace before printing the value and 2 decimal values so result will be 42.99 after roundoff 42.98765 to 42.99 after 14 whitespaces and %13f will print 687.549354 with 3 whitespaces at first because 13 characterspace should be there
  
cost = 8.5 ; //now cost is 8.5 instead of earlier 14.5
  
value =cost- discount;//8.5-6.0=2.5 , so value is 2 , insted of 11 that is assigned earlier because it's an integer value   
  
price = price - cost ; //12-8.5=3.5 but price is 3 because price is an integer
  
cost=value+(discount*price);// 2(value) + (6.0(discount)*3(price))=2+18.0=20.0 so cost is 20
  
printf("There are %5d more numbers.... ",8215379);
//
  
printf("Here are the answers ");
  
printf(" ----%d %d %d ---- ",9,price,2017);//this will print as 9 , 3 , 2017 these are only integer values
  
  
printf(" value = %10d ",value);//value is integer value and now it's 2
//discount = cost / 2 ; //this is a comment doesn't affect anything so discount's value will be same as earlier 6.0
  
printf("discount = %8.2f ",discount);//it will print 6.0
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote