Cmis 102

Submitted by: Submitted by

Views: 10

Words: 416

Pages: 2

Category: Science and Technology

Date Submitted: 11/11/2015 01:19 AM

Report This Essay

My program will calculate the number of goals scored by a soccer player in 10 games. Soccer player needs to score more than 20 goals to pass the world record for goals scored.

Pseudocode:

BEGIN

// This program will calculate the sum of goals scored in 10 games.

// Declare variables

Declare game_days, value, goals_scored as Integer

//Initialize Counter, Sum to 0

Set game_days=0

Set goals_scored = 0

// Loop through 10 integers

While game_days < 10

Print “How many goals did you score today?”

Input value

goals_scored = goals_scored + value

game_days=game_days+1

End While

// Print results and messages

Print “Total goals scored in 10 games” + goals_scored

If (goals_scored > 20)

Printf “Congratulations! You have set the world record for most goals scored!”

If (goals_scored< 20)

Printf “Keep scoring those goals!”

End if

END

C code

#include <stdio.h>

int main ()

{

/* variable definition: */

int game_days, value, goals_scored;

/* Initialize game days and goals scored */

game_days = 0;

goals_scored = 0;

// Loop through to input values

while (game_days < 10)

{

printf("How many goals did you score today?\n");

scanf("%d", &value);

goals_scored = goals_scored + value;

game_days = game_days + 1;

}

printf("Total goals scored in ten games %d\n " , sum );

if (goals_scored >20)

printf("Congratulations! You have set the world record for most goals scored!");

if (goals_scored <20)

printf("Keep scoring those goals!");

return 0;

}

stdin

1

1

1

1

1

1

1

1

1

1

Stdout

How many goals did you score today?

How many goals did you score today?

How many goals did you score today?

How many goals did you score today?

How many goals did you score today?

How many goals did you score today?...