C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings to double values. Calculate the sum,difference,and product of these values and print them.
int main(){
// character string value array for user
char stringValue[10];
double sum=0.0;// initialize sum to store the results
from 2 double values
double difference=0.0; // initialize difference to
store the results from 2 double values
double product = 0.0; // intitialzie product to store
the results from 2 double values
int x; // initialize x for loop counter
// loop 2 times from 1 to 2
for(x=1;x<=2;x++){
// prompt user to enter floating
point string value
printf("Enter the floating point
string value:\t");
// gets function to get string
values
scanf("%s",stringValue);
// atof converts the string into
double values
sum+=atof(stringValue);
difference -=
atof(stringValue);
product *= atof(stringValue);
}// end for loop
// Display sum,diffence, and product of 2 values
entered from user
printf("\nThe total of the two values entered is
%f\n",sum);
printf("The difference of the two values entered is
%f\n",difference);
printf("The product of the two values entered is
%f\n",product);
return 0;
}
#include <stdio.h> #include <stdlib.h> int main() { // character string value array for user char stringValue[10]; double sum = 0.0;// initialize sum to store the results from 2 double values double difference = 0.0; // initialize difference to store the results from 2 double values double product = 1.0; // intitialzie product to store the results from 2 double values int x; // initialize x for loop counter // loop 2 times from 1 to 2 for (x = 1; x <= 2; x++) { // prompt user to enter floating point string value printf("Enter the floating point string value:\t"); // gets function to get string values scanf("%s", stringValue); // atof converts the string into double values sum += atof(stringValue); if (x == 1) difference = sum; else difference -= atof(stringValue); product *= atof(stringValue); }// end for loop // Display sum,diffence, and product of 2 values entered from user printf("\nThe total of the two values entered is %f\n", sum); printf("The difference of the two values entered is %f\n", difference); printf("The product of the two values entered is %f\n", product); return 0; }
C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings...
C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...
Programming in C: Write a program that accepts an integer and two floating-point values and prints the sum of these values. Example: Input:12,13.14,6.7; Output:31.84. Use formatted I/O
**Using C Language** Get a number from the user and use that number for loops and to make some calculations. Get a number from the user (n) (For example if the user enters a 3, each loop below will repeat 3 times) //ask, get, and return an integer (by reference) void GetIntPointer(int *numPtr); //input: the number entered by the user (pass by copy) //Calculates the product of the first (n)numbers using a while loop and store the result in *productPtr...
Instructions Write a C++ program that performs the following: Accept a list of floating point values on a single line (separated by spaces). This is vector A. The user may enter as many values as they desire. Accept a second list of floating point values on a single line (separated by spaces). This is vector B. The user may enter as many values as they desire. There is no requirement that the two vectors have the same number of elements....
i have no idea how to do floating point comparison this is c programming CHALLENGE 3.16.1: Floating-point comparison: Print Equal or Not equal Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targetValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is Equal 1 #include <stdio.h 2 #include <math.h> 4 int main(void)f 6 8 scanf("%lf", &targetValue); 1 test passed double targetValue; double...
/*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/ /* */ /* */ /* This program computes average power, average magnitude */ /* and zero crossings from a speech signal. */ #include <stdio.h> #include <math.h> #define MAXIMUM 50 int main(void) { /* Declare variables */ int k=0, npts=30; double speech[MAXIMUM]={0.000000,-0.023438,-0.031250,-0.031250,-0.039063,-0.039063,-0.023438,0.000000,0.023438,0.070313,-0.039063,-0.039063,0.046875,0.101563,0.117188,0.101563,0.070313,0.054688,0.023438,0.000000,-0.031250,-0.039063,-0.070313,-0.070313,-0.070313,-0.070313,-0.062500,-0.046875,-0.039063,-0.031250}; /* Declare the function prototypes */ /* Compute and print statistics. */ printf("\n SPEECH DATA "); print(,,);//complete the statement printf("\n"); printf(" SPEECH STATISTICS : \n"); printf(" average power: %f \n",);//complete the statement printf(" average magnitude: %f...
1- Correct the syntax errors in the following program, and rewrite the program so that it follows the proper style conventions. What does the program do? (Write it out as a comment). (10 pts) #include <stdio.h> int main() {/* * Calculate and display the difference of two values *) int X, /* first input value */ x, /* second input value */ sum; /* sum of inputs */ X=9, x=7.5 X + x = sum; printf("%d + %d = %d\n";...
In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...
Write a complete C program. Define a structure type element_t to represent one element from the periodictable of elements. Components should include the atomic number (aninteger); the name, chemical symbol, and class (strings); a numeric field forthe atomic weight; and a seven-element array of integers for the number ofelectrons in each shell. The following are the components of an element_t structure for sodium.11 Sodium Na alkali_metal 22.9898 2 8 1 0 0 0 0 Have the user enter the data...
In C++ Exercise #2: Design and implement a programming (name it SimpleMath) that reads two floating-point numbers (say R and T) and prints out their values, sum, difference, and product on separate lines with proper labels. Comment your code properly and format the outputs following these sample runs.