1. 23P_0678 _Rashid Amin_QueNo 1
#include <stdio.h>
#define teteprotation_cost_per_use 1000
#define spaceship_cost_per_use 1500
#define spaceship_cost_per_distance 50
int teleportationCost(int portalCount) {
return portalCount * teteprotation_cost_per_use;
}
int calculateSpaceshipCost(int spaceshipCount, int distance) {
return spaceship_cost_per_use*spaceship_cost_per_distance* spaceshipCount;
}
int TotalCost(int portalCount,int spaceshipCount,int distance) {
int portalCost =teleportationCost(portalCount);
int spaceshipCost = calculateSpaceshipCost(spaceshipCount, distance);
int totalCost = portalCost + spaceshipCost;
printf("teleportation Portal Cost: $%dn", portalCost);
printf("Spaceship Cost: $%dn", spaceshipCost);
return totalCost;
}
int main() {
int portal_use, spaceship_use, distance;
printf ("transportation portal used: ");
scanf ("%d", &portal_use);
printf ("The value of spaceship used: ");
scanf ("%d", &spaceship_use);
printf ("The value of distance of spaceship travelled: ");
scanf ("%d", &distance);
int totalCost = TotalCost(portal_use, spaceship_use, distance);
printf("Total Transportation Cost: $%dn", totalCost);
return 0;
}
2. 23P_0678 _Rashid Amin_QueNo 2
#include <stdio.h>
int formulaOne(int power, int speed) {
return power + speed;
}
int formulaTwo(int efficiency) {
return efficiency * efficiency;
}
int main() {
// Input for Car 1
int car1_power = 10,car1_speed = 20,car1_efficiency = 40;
// Input for Car 2
int car2_power = 30,car2_speed = 50 ,car2_efficiency = 60;
int car1_performance = formulaOne(car1_power, car1_speed) + formulaTwo(car1_efficiency);
//The overall performance for Car 2
int car2_performance = formulaOne(car2_power, car2_speed) + formulaTwo(car2_efficiency);
// The new car's overall performance
int new_car_performance = car1_performance + car2_performance;
printf("New car's overall performance: %dn", new_car_performance);
return 0;
}
3. 23P_0678 _Rashid Amin_QueNo3
#include <stdio.h>
int main() {
int revenue, expenses, net_profit, profit_margin, roi;
const int scaling_factor = 100;
printf("The value of total revenue for the year: ");
if (scanf("%d", &revenue) != 1 || revenue < 0) {
printf("Invalid input for revenue. Please the value of on-negative integer.n");
return -1;
}
printf("Enter the total expenses for the year: ");
if (scanf("%d", &expenses) != 1 || expenses < 0) {
printf("Invalid input for expenses. Please the value of non-negative integer.n");
return -1;
}
net_profit = (revenue - expenses) * scaling_factor;
if (revenue == 0) {
printf("Error: Revenue is zero. Cannot define profit margin.n");
return 1;
}
if (expenses == 0) {
printf("Error: Expenses are zero. Cannot define ROI.n");
return 1;
}
profit_margin = (net_profit * scaling_factor) / revenue;
roi = (net_profit * scaling_factor) / expenses;
printf("Total Revenue: %dn", revenue);
printf("Total Expenses: %dn", expenses);
printf("Net Profit: %dn", net_profit / scaling_factor);
printf("Profit Margin: %d%%n", profit_margin / scaling_factor);
printf("Return on Investment (ROI): %d%%n", roi / scaling_factor);
return 0;
}
4. 23P_0678 _Rashid Amin_QueNo4
#include <stdio.h>
int main() {
char Box1Color, Box2Color;
printf("Enter the color of the first box (R for red, B for blue, G for green): ");
scanf(" %c", &Box1Color);
printf("Enter the color of the second box (R for red, B for blue, G for green): ");
scanf(" %c", &Box2Color);
if (Box1Color == Box2Color) {
printf("Two boxes of the same color cannot be placed together.n");
} else {
printf("Boxes placed successfully.n");
}
return 0;
}