Question
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started