Question

In: Computer Science

Using C Programming. Put all of these 4 things in one source file and attach to...

Using C Programming. Put all of these 4 things in one source file and attach to this question. Put #1 in main. Put all the others into separate function functions but in the same file.  

1)  

Put this code in main.

You are writing a program for Bowl Me Over, a local bowling alley. The program will allow staff to enter any number of bowling scores. Scores in a standard game range between 0 to 300, with being a perfect score. Get scores from the user as integers. Continue to get scores until the user enters a value outside of the acceptable score range. As soon as a value outside of this range is entered, output information as show below.

For a perfect score, you must not to use arrays and you must only include 1 loop to do this processing. Only use concepts and code we have covered.

Examples below, user input is italicized:

Bowling score: 2

Bowling score: 207

Bowling score: 200

Bowling score: 301

Top score: 207

Average score: 136.3333

Elite bowlers (scores above 200): 1

Beginners (scores below 100): 1

Hints: not concerned about formatting the average to 2 decimal places as long as it is a double number

2)

Given a function header:

int verify(int arg1, char argChar)

write a function that will return 21 only if arg1 is positive and argChar is a lower case vowel (a, e, i, o, or u). Otherwise, return -1.

3)

Write a function that will return the 4th root of a double number passed as a parameter. Name the function fourthRoot(). Hints, the 4th root of 16 is 2 (2 * 2 *2 *2 =16). x 1/r = r root of x.

Solutions

Expert Solution

#include <stdio.h>
#include <math.h>

int verify(int arg1, char argChar)
{
if(arg1>0&&(argChar=='a'||argChar=='e'||argChar=='i'||argChar=='o'||argChar=='u'))
return 21;
return -1;
}

double fourthRoot(double n)
{
return pow(n,0.25);
}

int main()
{
double average,score,top=-1;
int count=0,elite=0,beginner=0;
printf("Bowling score: ");
scanf("%lf",&score);
while(score>=0&&score<=300)
{
if(score<100)
beginner++;
if(score>200)
elite++;
count++;
average+=score;
if(score>top)
top=score;
printf("Bowling score: ");
scanf("%lf",&score);
}
printf("Top score: %lf\n",top);
printf("Average score: %f\n",(average/count));
printf("Elite bowlers (scores above 200): %d\n",elite);
printf("Beginners (scores below 100): %d\n",beginner);
  
printf("verify(2,'a') = %d\n",verify(2,'a'));
printf("verify(-1,'a') = %d\n",verify(-1,'a'));
printf("verify(2,'A') = %d\n",verify(2,'A'));
  
printf("Fourth root of 16 = %lf\n",fourthRoot(16));
printf("Fourth root of 21 = %lf",fourthRoot(21));
return 0;
}


Related Solutions

Using c programming language How do you put data from a text file into a 2d...
Using c programming language How do you put data from a text file into a 2d array For example a text file with names and age: john 65 sam 34 joe 35 sarah 19 jason 18 max 14 kevin 50 pam 17 bailey 38 one 2d array should have all the names from the file and one 2d array should have all the ages and both arrays should be printed out separately and be 3x3
Please answer the problem below in C programming language: Create a pointer activity source file -...
Please answer the problem below in C programming language: Create a pointer activity source file - cptr2.c - that takes two arguments, a number from 1 to 3, and a string sentence(s). Create variables for a character, an integer, a string pointer. Based on integer value you will use that number of string pointers. The string variable is a string pointer that has not been allocated.    Define pointers to those variables types without any initialization of those points to the...
Systems Programming - File Operations in Linux using C Preventing copying the same file What does...
Systems Programming - File Operations in Linux using C Preventing copying the same file What does the standard cp do if you try to copy a file onto itself? $ cp file1 file1 cp: 'file1' and 'file1' are the same file Modify cp1.c to handle the situation and include comments. /** * @file cp1.c * @brief Uses read and write with tunable buffer size * usage: cp1 src dest */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #define BUFFERSIZE...
C Programming file.c takes in one input argument that denotes a file to be read. It...
C Programming file.c takes in one input argument that denotes a file to be read. It needs to convert the contents of that file into a character array (char *) and then into a an unsigned character array (unsigned char *). Please fix and or complete the program, and explain any of the changes too: ---- #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { FILE *f; f = fopen(argv[1], "r"); if( !f ) { exit(1); }...
Using C programming I have a file that contains earthquake data that I will copy and...
Using C programming I have a file that contains earthquake data that I will copy and paste below. I want to use either bubble or insertion sort to sort the file by latitude in ascending order, then create a new file containing the sorted data. example file to sort: time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net 2020-10-17T17:22:03.840Z,32.877,-116.2991667,0.31,1.16,ml,21,119,0.07747,0.26,ci 2020-10-17T17:17:29.980Z,34.1611667,-116.452,2.75,0.87,ml,17,66,0.05224,0.22,ci 2020-10-17T17:03:54.460Z,33.5396667,-116.4613333,8.66,0.63,ml,18,126,0.06084,0.16,ci 2020-10-17T16:55:01.080Z,63.254,-151.5232,8,1.4,ml,,,,0.9,ak
Systems Programming - File Operations Create your version of the tail command in Linux using C...
Systems Programming - File Operations Create your version of the tail command in Linux using C The lseek system call allows you to move the current position anywhere in a file. The call lseek(fd, 0, SEEK_END) moves the current position to the end of the file. The tail command displays the last ten liens of a file. Try it. tail has to move, not to the end of the file, but to a spot ten lines before the end of...
C++ Programming Simply explain what the difference between "including" a header file and using a compiled...
C++ Programming Simply explain what the difference between "including" a header file and using a compiled library file during linking? Where are the C++ header files and compiled C++ library files on your computer?
Edit question Miscellaneous C knowledge. (Put all answers in the same q5.txt file, they’re all short.)...
Edit question Miscellaneous C knowledge. (Put all answers in the same q5.txt file, they’re all short.) (a) [2 marks] On an old 16-bit computer system and its C compiler,sizeof(double)=8andsizeof(int)=2. Given the two type definitions below, what weresizeof(s)andsizeof(lingling)on that system? Assume that ins, there is no gap between the twofields. typedef struct s { double r[5];int a[5]; } s; typedef union lingling { double r[5];int a[5]; } lingling; (b) [2 marks] Given the following declarations, two questions: What is the type...
Programming Language C++ Encrypt a text file using Caesar Cipher. Perform the following operations: Read the...
Programming Language C++ Encrypt a text file using Caesar Cipher. Perform the following operations: Read the console input and create a file. ['$' character denotes end of content in file.] Close the file after creation. Now encrypt the text file using Caesar Cipher (Use key value as 5). Display the contents of the updated file. #include <iostream> using namespace std; int main() { // write code here }
C Programming: Write a program that accepts 2 arguments, an input file and an output file....
C Programming: Write a program that accepts 2 arguments, an input file and an output file. The program is to store in the output file the contents of the input file in reverse. If the input file looks like this: Hello World.\n This is Line 2\n This is the end.\n then the output file should look like this: \n .dne eht si sihT\n 2 eniL si sihT\n .dlroW olleH The main program should look like this: int main(int argc, char...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT