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

C program to do the number of calories burned per hour by bicycling, jogging and

ID: 3741651 • Letter: C

Question

C program to do the number of calories burned per hour by bicycling, jogging and swimming is 200, 475, and 275 respectively. A person loses 1 pound of weight for each 3500 calories burned. program with a function that accepts three real numbers that represent hours bicycling, hours jogging and hours swimming and returns the pounds lost as a type double.




Then a program How to initialize an array of size 5 using an initializer list and to compute it’s sum How to initialize an array of size 5 with even numbers starting from 2 using ‘for’ loop and to compute it’s sum
Using scan set with scanf to input vowels and consonants
A scan set scans the characters in the input stream, looking only for those characters that match the characters contained in the scan set. Each time a character is matched, it is stored in the scan set’s corresponding argument – a pointer to a character array. The scan set stops inputting characters when a character that is not contained in the scan set is encountered.
To read vowels, scanf(“%[aeiou]”,char_array);
To read consonants, scanf(“%[^aeiou]”,char_array); ( the caret symbol ‘^’ is used for negation.


And a c Program to compute the car insurance premium for a person based on their age and the number of tickets they have received. The following table explains how to perform the ticket computation: If Person's Age Is
Then Insurance Cost Is
Less than 21
$1500 + $250 x number of tickets
From 21 through 24
$1200 + $250 x number of tickets
25 or older
$1000 + $200 x number of tickets
Print the person’s age, number of tickets and the computed insurance cost. C program to do the number of calories burned per hour by bicycling, jogging and swimming is 200, 475, and 275 respectively. A person loses 1 pound of weight for each 3500 calories burned. program with a function that accepts three real numbers that represent hours bicycling, hours jogging and hours swimming and returns the pounds lost as a type double.




Then a program How to initialize an array of size 5 using an initializer list and to compute it’s sum How to initialize an array of size 5 with even numbers starting from 2 using ‘for’ loop and to compute it’s sum
Using scan set with scanf to input vowels and consonants
A scan set scans the characters in the input stream, looking only for those characters that match the characters contained in the scan set. Each time a character is matched, it is stored in the scan set’s corresponding argument – a pointer to a character array. The scan set stops inputting characters when a character that is not contained in the scan set is encountered.
To read vowels, scanf(“%[aeiou]”,char_array);
To read consonants, scanf(“%[^aeiou]”,char_array); ( the caret symbol ‘^’ is used for negation.


And a c Program to compute the car insurance premium for a person based on their age and the number of tickets they have received. The following table explains how to perform the ticket computation: If Person's Age Is
Then Insurance Cost Is
Less than 21
$1500 + $250 x number of tickets
From 21 through 24
$1200 + $250 x number of tickets
25 or older
$1000 + $200 x number of tickets
Print the person’s age, number of tickets and the computed insurance cost. C program to do the number of calories burned per hour by bicycling, jogging and swimming is 200, 475, and 275 respectively. A person loses 1 pound of weight for each 3500 calories burned. program with a function that accepts three real numbers that represent hours bicycling, hours jogging and hours swimming and returns the pounds lost as a type double.




Then a program How to initialize an array of size 5 using an initializer list and to compute it’s sum How to initialize an array of size 5 with even numbers starting from 2 using ‘for’ loop and to compute it’s sum
Using scan set with scanf to input vowels and consonants
A scan set scans the characters in the input stream, looking only for those characters that match the characters contained in the scan set. Each time a character is matched, it is stored in the scan set’s corresponding argument – a pointer to a character array. The scan set stops inputting characters when a character that is not contained in the scan set is encountered.
To read vowels, scanf(“%[aeiou]”,char_array);
To read consonants, scanf(“%[^aeiou]”,char_array); ( the caret symbol ‘^’ is used for negation.


And a c Program to compute the car insurance premium for a person based on their age and the number of tickets they have received. The following table explains how to perform the ticket computation: If Person's Age Is
Then Insurance Cost Is
Less than 21
$1500 + $250 x number of tickets
From 21 through 24
$1200 + $250 x number of tickets
25 or older
$1000 + $200 x number of tickets
Print the person’s age, number of tickets and the computed insurance cost.

Explanation / Answer

1) C program to calculate the calories burned per hour

#include <stdio.h>

//Function to compute pounds lost
double pound_lost(double b, double j, double s) {
//Initializing the variables to store calorie values
double calories_b;
double calories_j;
double calories_s;
  
//Calculating the calories for each activity based on the hour input
calories_b = b*200;
calories_j = j*475;
calories_s = s*275;
  
//Computing the total calories
double total_calories = calories_b + calories_j + calories_s;
  
//Calculating the weight lost in pounds
double weight_lost = total_calories/3500;
  
return weight_lost;
}
int main()
{
//Calling the function to calculate the lost weight and passing sample values
double weight_lost_in_pounds = pound_lost(10, 14, 20);
  
printf(" Weight lost : %lf pounds", weight_lost_in_pounds);
return 0;
}


SAMPLE OUTPUT:

Weight lost : 4.042857 pounds

2) C program to initialize an array and calculate the sum

#include <stdio.h>

int main()
{
//Initializing array
int arr[] = {1,2,3,4,5};
  
//Initializing sum
int sum = 0;
  
int i;
  
//Iterating through each element and adding it to sum
for(i=0; i<5; i++) {
sum += arr[i];   
}
  
//Printing the array sum
printf("Sum is %d", sum);
return 0;
}

SAMPLE OUTPUT:

Sum is 15

3) C program to initialize an array of even numbers and calculate the sum

#include <stdio.h>

int main()
{
//Initializing array
int arr[5];
  
int i;
  
for(i=0; i<5; i++) {
//Calculate the even number corresponding to array index and store it in array
arr[i] = (i+1)*2;
}
//Initializing sum
int sum = 0;
  
  
//Iterating through each element and adding it to sum
for(i=0; i<5; i++) {
sum += arr[i];   
}
  
//Printing the array sum
printf("Sum is %d", sum);
return 0;
}

SAMPLE OUTPUT:

Sum is 30

4) C program to match the vowels and consonants

#include <stdio.h>

int main()
{
//Declaring a character array
char char_array[100];
  
//Matching vowels from the input array
scanf("%[aeiou]", char_array);
  
printf(" Vowels matched: %s", char_array);
  
//Matching consonants from the input array
scanf("%[^aeiou]", char_array);
  
printf(" Consonants matched: %s", char_array);
  
}

INPUT:

uiophxwknhrtuiofp

SAMPLE OUTPUT:

Vowels matched: uio
Consonants matched: phxwknhrt

5) C program to calculate the insurance premium based on the age and no. of tickets

#include <stdio.h>

//Function to compute premium based on the age and no. of tickets
int compute_premium(int a, int n) {
int premium;
  
//Logic to calculate the premium
if(a<21) {
premium = 1500 + 250*n;
}
else if(a<=24) {
premium = 1200 + 250*n;
}
else {
premium = 1000 + 200*n;
}
}
int main()
{
int premium;
  
//Computing premium for different inputs
premium = compute_premium(50,5);
printf(" Age: 50, Number of tickets: 5, Premium: %d", premium);
  
premium = compute_premium(19,7);
printf(" Age: 19, Number of tickets: 7, Premium: %d", premium);
  
premium = compute_premium(30,10);
printf(" Age: 20, Number of tickets: 10, Premium: %d", premium);
  
premium = compute_premium(23,8);
printf(" Age: 20, Number of tickets: 10, Premium: %d", premium);
}

SAMPLE OUTPUT:


Age: 50, Number of tickets: 5, Premium: 2000
Age: 19, Number of tickets: 7, Premium: 3250
Age: 20, Number of tickets: 10, Premium: 3000
Age: 20, Number of tickets: 10, Premium: 3200