
help me with the loops and the last part of this question .i am using c language....speed=distance/time....in the 1st part of the program i had to write a program to calculate speed...we had to input distance in meters and time in seconds.
please find the output screenshot and code below.
code :
//defining the predefined libraries
#include<stdio.h>
#include <time.h>
#include <stdlib.h>
//defining the method for calculating the speed
//here the distance is the parameter
float calculate_speed(float finish_line_distance) {
int time;
//time taking as the input from the user
printf("Enter the time in seconds : \n");
scanf("%d",&time);
//calculating speed = distance/time
float res = (finish_line_distance/time);
//returning the speed
return res;
}
//method for calculating the strength
int calculate_strength() {
int number;
//asking the user to enter the number between 0 and 100
printf("Enter a whole number between 0 and 100\n");
//reading a number from the console
scanf("%d",&number);
//returning the number
return number;
}
//calculating the combat value
int calculate_combat(float speed, int strength){
int minValue = 50;
//calculating the min(50,speed)
if(speed < 50) {
minValue = speed;
}
//generating the random value between -10 and 10
srand(time(NULL));
int nRandonNumber = (rand()%((10+1)-(-10)) + (-10));
printf("random number is %d\n",nRandonNumber);
//calculating the combat using the formaula given
float res = (minValue + ((strength/100) * 50) + nRandonNumber);
//returning the combat
return res;
}
//our main method starts here
void main() {
//defining the variables
float finish_line_distance,speed;
int strength;
//reading the distance from the user
printf("Enter the finish Line Distance : \n");
scanf("%f",&finish_line_distance);
//calling the function speed to calculate speed
float res = calculate_speed(finish_line_distance);
printf("speed is %f\n",res);
//calling the strength function to calculate strength
int res1 = calculate_strength();
printf("the strength is %d\n",res1);
//calling the combat function to calcualte the combat
int res2 = calculate_combat(res,res1);
//printing the result
printf("the comabat values is %d\n",res2);
}
output screenshot :

help me with the loops and the last part of this question .i am using c...
I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...
Summary task: C++ language; practice combining tools(functions, arrays, different kind of loops) to solve somewhat complex problem. Description A Valiant Hero is about to go on a quest to defeat a Vile Monster. However, the Hero is also quite clever and wants to be prepared for the battle ahead. For this question, you will write a program that will simulate the results of the upcoming battle so as to help the hero make the proper preparations. Part 1 First, you...
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops for the input validations required: number of employees(cannot be less than 1) and number of days any employee missed(cannot be a negative number, 0 is valid.) Each function needs a separate flowchart. The function charts are not connected to main with flowlines. main will have the usual start and end symbols. The other three functions should indicate the parameters, if any, in start; and...
Below is the code for two programs in C language, I was trying to make proper comments within the code so that someone can understand it. Please review the comments within the code and let me know if it makes good sense. Let me know if I need to make any changes to the comments! Thank you. PROGRAM 1: /* program calculates harmonic mean for 10 numbers entered by the user */ /* if illegal value (x<0) is entered, the...
Please, I need help, I cannot figure out how to scan variables
in to the function prototypes!
******This is what the program should look like as it runs but I
cannot figure out how to successfully build the code to do
such.******
My code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <conio.h>
float computeSeriesResistance(float R1, float R2, float R3);
float computeParallelResistance(float R1, float R2, float
R3);
float computeVoltage(int current, float resistance);
void getInputR(float R1, float R2, float R3);
void getInputCandR(int...
In
c++ programming, can you please edit this program to meet these
requirements:
The program that needs editing:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int cal_avg(char* filenumbers, int n){
int a = 0;
int number[100];
ifstream filein(filenumbers);
if (!filein) {
cout << "Please enter a a correct file to read in the
numbers from";
}
while (!filein.eof()) {
filein >> number[a];
a++;
}
int total = number[0];
for (a = 0; a < n; a++) {...
Code in C++
Function Prototypes
For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber.getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called...