You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔢 This script can calculate the total amount of carbon dioxide produced by trees, cars, and homes in a given area. The script can also be used to calculate the percentage of the total carbon dioxide produced by each type of source.
#include <stdio.h>
#include <stdlib.h>
int main() {
// Declare variables to store the user's input.
int num_trees;
int num_cars;
int num_homes;
// Get the user's input.
printf("Enter the number of trees in your area: ");
scanf("%d", &num_trees);
printf("Enter the number of cars in your area: ");
scanf("%d", &num_cars);
printf("Enter the number of homes in your area: ");
scanf("%d", &num_homes);
// Calculate the total amount of carbon dioxide produced by the trees, cars, and homes in the area.
int total_co2 = num_trees * 100 + num_cars * 200 + num_homes * 300;
// Print the total amount of carbon dioxide produced.
printf("The total amount of carbon dioxide produced in your area is %d pounds.\n", total_co2);
// Calculate the percentage of the total carbon dioxide produced by each type of source.
int percent_trees = (num_trees * 100) / total_co2;
int percent_cars = (num_cars * 200) / total_co2;
int percent_homes = (num_homes * 300) / total_co2;
// Print the percentage of the total carbon dioxide produced by each type of source.
printf("The percentage of the total carbon dioxide produced by trees is %d%%.\n", percent_trees);
printf("The percentage of the total carbon dioxide produced by cars is %d%%.\n", percent_cars);
printf("The percentage of the total carbon dioxide produced by homes is %d%%.\n", percent_homes);
// Return 0 to indicate that the program executed successfully.
return 0;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
🔢 This script can calculate the total amount of carbon dioxide produced by trees, cars, and homes in a given area. The script can also be used to calculate the percentage of the total carbon dioxide produced by each type of source.
Beta Was this translation helpful? Give feedback.
All reactions