Answer to Question #159050 in C for Arslan habib

Question #159050
a) Write a program which accomplished each of the following after prompting user to typed three integers.
• Calculates the product of three integers.
• Calculate the square and cube of each of the integer.
b) Make a general store receipt of the customer who has bought several items. The Output should contain regular price of an item, the department code, and calculated the discount price. The receipt should be proper formatted using Escape sequence
1
Expert's answer
2021-01-30T08:18:12-0500
#include <stdio.h>
#include <math.h>
int main() {
    int a, b, c, product;
    printf("Enter three integers: \n");
    printf("a = "); scanf("%d", &a);
    printf("b = "); scanf("%d", &b);
    printf("c = "); scanf("%d", &c);
    product = a * b * c;
    printf("The product of three integers: %d * %d * %d = %d", a, b, c, product);
    printf("\n%d ^ 2 = %d", a, a * a);
    printf("\n%d ^ 2 = %d", b, b * b);
    printf("\n%d ^ 2 = %d", c, c * c);
    printf("\n%d ^ 3 = %d", a, a * a * a);
    printf("\n%d ^ 3 = %d", b, b * b * b);
    printf("\n%d ^ 3 = %d", c, c * c * c);
    return 0;
}



b)

#include <stdio.h>
#include <math.h>
int main() {
    char item[25];
    int department_code;
    float regular_price, discount_price;
    printf("Enter the name of item: "); scanf("%s", item);
    printf("Enter the regular price of item: "); scanf("%f", &regular_price);
    printf("Enter the discount price of item: "); scanf("%f", &discount_price);
    printf("Enter the department code: "); scanf("%d", &department_code);
    printf("|=*=*=*=*=*=* receipt =*=*=*=*=*=*|");
    printf("\nItem: %s", item);
    printf("\nDepartment Code: %d", department_code);
    printf("\nRegular price: %f$", regular_price);
    printf("\nDiscount price: %f$", discount_price);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS