Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to build off of this current program in C and I am very confused on this assignment. #include #include #include int roll(int x){

I have to build off of this current program in C and I am very confused on this assignment.

#include #include #include int roll(int x){ if (x>50 || x < 1){ return 4; } else{ return (rand()%(x+1)); } }

int main(int argc, char const *argv[]) { int A[50];

srand(time(NULL)); int k,i,sum=0,countOf7=0,consecutiveSameNums=0;

for ( k = 0; k < 50; ++k ){ A[k] = roll(10); }

printf("first 3 values "); for ( k = 0; k < 3; ++k ) printf("%d\t", A[k]); printf(" ");

for (i = 0; i < 50; ++i) { sum=sum+A[i]; } printf("Sum : %d ",sum );

for (i = 0; i < 50; ++i) { if (A[i]==7) { countOf7++;

countOf7++; } } printf("7 rolled %d times ",countOf7 );

for (i = 0; i < 49; ++i) { if (A[i]==A[i+1]) { consecutiveSameNums++; } } printf("%d times two consecutive same numbers rolled ",consecutiveSameNums$

return 0; }

Assignment:

For the quiz, roll a 10-sided dice 50 times

Write each of these functions, then call appropriate so solve the requests problems

Print the values in an array: void printArray( int A[], int N )

A is the array of integers, N is the number of items to print

Find the sum of values in an array: int sumArray( int A[], int N )

Frequency of value in array: int freqArray( int A[], int N[], int T)

A is array, N is number of item, T is target value

Utility function make sure you have this function:

int roll( int )

Purpose: roll a dice, return the value

Params: how sides on the dice

If # of sides is outside 1 to 50 range, return 4

Additional functions to write & test:

Write the functions, test them, youll submit to the quiz

int isVowel( char )

Purpose: determine if character is a vowel, return 1 for yes, 0 for no

Note: y is note a vowel, not even sometimes :)

Params: a character

char toGrade( int ) [ABCDF]

Purpose: convert numeric score to letter grade, standard 90-80-70

Params: integer representing score

If score is outside 0 to 100 legal range, return ?

int fullCartons( int )

Purpose: how egg cartons (dozen) can be filled

Params: number of eggs

void zigzag( int )

Purpose: make 1 zig-zag bump

Params: height of the zig

This is a zigzag of size 4

(- to illustrate but must be in your code)

#

-#

--#

---#

--#

-#

#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago