) 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
a)
#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", ®ular_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);
}
Comments
Leave a comment