Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following code is part of a game mechanism which draws concentric, random si

ID: 3542566 • Letter: T

Question


The following code is part of a game mechanism which draws concentric, random sized circles on the screen to simulate a rippling effect. Code has one or more errors in it. They might be syntax, runtime, or design flaws. Your task is to implement this functionality into CyCalc V4 (project for VS2012 available on BB), by using the code below. The user should be able to call the functionality from main(), and circles should be drawn on the graphics window, large enough that they are visible. Correct any errors the code has, and comment it accordingly where you made corrections to make it work.




#include <stdlib.h>

#include <stdio.h>

#include "graphics.h"

#include<math.h>

#define PI = 3.14159265359;


void main(int* argc, char** argv){

int counter = 0.1;

double pi == 3.1415926539;

printf("How many circles do you need ? ");

scanf("%s

Explanation / Answer

#include <stdio.h>

#include <math.h>

#include <conio.h>


#define SCREEN_X 79

#define SCREEN_Y 19

#define PI 3.14159265359


void main(void)


{

char table_g[SCREEN_X][SCREEN_Y];

float min_x,max_x,step_x,s,m,a=4.,b=1.;

int i,j,c;


printf("Varianza: ");

scanf("%f",&s);


printf("Media: ");

scanf("%f",&m);


do

{

for(i=0;i<SCREEN_X;i++)

{

for(j=0;j<SCREEN_Y;j++)

table_g[i][j]=' ';

}


min_x=m-a*s;

max_x=m+a*s;

step_x=(max_x-min_x)/(SCREEN_X-1);


for(i=0;i<SCREEN_X;i++)

{

/* j=1./(sqrt(2*PI*s))*exp(-pow(min_x+i*step_x-m,2)/(2*s))*SCREEN_Y;*/

j=exp(-pow(min_x+i*step_x-m,2)/(2*s))*SCREEN_Y*b;

if(j<SCREEN_Y)

table_g[i][j]='*';

}


for(i=0;i<SCREEN_X;i++)

printf("-");


printf(" Varianza: %.2f Media: %.2f Range: %.2f/%.2f ",s,m,min_x,max_x);


for(i=0;i<SCREEN_X;i++)

printf("-");


for(j=SCREEN_Y-1;j>=0;j--)

{

printf(" ");

for(i=0;i<SCREEN_X;i++)

printf("%c",table_g[i][j]);

}


printf(" -[ESC=Exit][+=Zoom in][-=Zoom out]");

for(i=0;i<SCREEN_X-34;i++)

printf("-");

c=getch();

if(c=='+')

{

a/=1.1;

b*=1.1;

}

if(c=='-')

{

a*=1.1;

b/=1.1;

}

} while (c!=0x1B);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote