Needs to be done in visual studio. I keep having problems with
making my own function to call for the statistics and the random
number generator. they are both supposed to be separate functions
from the main. Can anyone help? Language is C


SOURCE CODE IN C:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
/*
Function to roll the die and store the results
@param rolls[] array to store the dice roll results
@param count number of rolls to simulate
*/
void rollDice(int rolls[], int count)
{
for(int i=0; i<count; i++)
rolls[i]=(rand()%6)+1;
}
/*
Function to calculate frequency of each roll, average roll and
standard deviation of the rolls and display them
@param rolls[] array to store the dice roll results
@param count number of rolls in the array
*/
void stats(int rolls[], int count)
{
int freq[]={0, 0, 0, 0, 0, 0};
int total=0;
for(int i=0; i<count; i++)
{
freq[rolls[i]-1]+=1;
total+=rolls[i];
}
double avg=(double)total/count, var=0;
for(int i=1; i<=6; i++)
{
var+=freq[i-1]*(i-avg)*(i-avg);
}
var/=count;
double std=sqrt(var);
printf("Results of %d rolls:\n", count);
for(int i=1; i<=6; i++)
printf("%d occurred %d times (%.4f%c).\n", i, freq[i-1], ((double)freq[i-1]/count)*100, '%');
printf("The average is %.6f.\n", avg);
printf("The standard deviation is %.6f.\n", std);
}
/*
Function to create the array of rolls and call the other
functions to fill the rolls and print stats
*/
int main()
{
srand(time(0));
printf("This program will simulate a user-specified number of rolls of a fair die and print out various statistical information about the rolls.\n\n");
int count, rolls[100000];;
printf("How many rolls do you want to simulate? ");
scanf("%d", &count);
while(count<1 || count>100000)
{
printf("Number of rolls should be between 1 and 100000.\nHow many rolls do you want to simulate? ");
scanf("%d", &count);
}
rollDice(rolls, count);
stats(rolls, count);
return 0;
}
OUTPUT:

Needs to be done in visual studio. I keep having problems with making my own function...
Done in C++ using visual studio 1. Write a program with one additional function called int[] reverseArray(int array). This function will receive an array from main and then reverse and should return the reversed array to the main to print out. Use a single array and a single loop, you’re are neither allowed to print out just in reverse order nor allowed to use another array variable to store the original array in reverse order. 2. Write a program which...
I need help figuring out how to code this in C++ in Visual Studio. Problem Statement: Open the rule document for the game LCR Rules Dice Game. Develop the code, use commenting to describe your code and practice debugging if you run into errors. Submit source code. Use the document to write rules for the user on how to play the game in a text file. Then, using the information from the resource articles, create a program that will read...
THIS IS FOR C++ PROGRAMMING USING VISUAL
STUDIO
THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING
#include "pch.h"
#include
#include
using namespace std;
// Function prototype
void displayMessage(void);
void totalFees(void);
double calculateFees(int);
double calculateFees(int bags) {
return bags * 30.0;
}
void displayMessage(void) {
cout << "This program calculates the total
amount of checked bag fees." << endl;
}
void totalFees() {
double bags = 0;
cout << "Enter the amount of checked bags you
have." << endl;
cout <<...
C++ ONLY THANKS!
USE VISUAL STUDIO COMPILER ONLY!
Part 1: Exercise 1: Problem description Write a three function
program (your main function and two other functions). The main
function of the program should create an array that can store 10
integers. The main function will then pass the array to a second
function that gets the integers from the user and stores them in
the array. Then your main will call a third function that displays
the elements in the...
Done in C++ using visual studio Instructions to solve all three problems below using function • The value of n should be asked from user in the main() and pass the value of n to an additional function as argument value; Ex: Factorial(n). • The functions should calculate the values according to the formulas below and return the values. • Then the main() function should print out those returned values. • All three parts should have their own separate function,...
I am trying to program a dice game in Visual Studios c++ but am having trouble. The program allows the user to choose the number of rolls, not exceeding 100,000. I am trying to print out the number of times each number(1-6) was rolled, but it's not working. What am I doing wrong? The link below is a copy of my code. https://docs.google.com/document/d/1baKfnof4pjdQ4905hwXluFtbcA1Fs7QESMQKy45xdpE/edit
I just need the code in c++ by using array and random number generation Write a function called rollDice. This function emulates rolling two 6-sided dice Choose two random numbers between 1 and 6 They should be random enough (pseudo-radom), not the same random number every time the function is run Add the numbers together and return the sum Note: it is not sufficient to merely randomly choose a number between 2 and 12, can you see why? Write a...
This program should be run on Visual Studio. Please use printf
and scanf as input and output. Thank you
6.12 Lab Exercise Ch.6b: C-string functions Create and debug this program in Visual Studio. Name your code Source.c and upload for testing by zyLabs You will write 2 functions which resemble functions in the cstring library. But they will be your own versions 1. int cstrcat(char dstDchar src) which concatenates the char array srcl to char array dstD, and returns the...
I need help making my array into a function that can called by
the main function using my program. This is C programming
int prime (int x) {
int i;
i = 2;
while (i < x) {
if (x % i == 0) return 0;
i++;
}
return 1;
}
int main (void){
int n;
scanf ("%d", &n);
if (n < 1) {
printf ("Error: at least one data value must be
provided.\n");
return 1;
}
int a[n];
int...
Thank you!!!
4.1 [2 pts. int rollO Define a function roll() that takes no arguments, and returns a random integer from 1 to 6. Before proceeding further, we recommend you write a short main method to test it out and make sure it gives you the right values. Comment this main out after you are satisfied that roll() works. Remenber:texibook Seciion 49 is on randormness, and Chapier 5is on functions. int getKandomNumber return 4 l chosen by fair dice roll....