Icon New game New game

Practice Programming

Fill in the Blanks

Practice Programs

Download the paper version to play

Recommended age: 17 years old
6 times made

Created by

United States

Top 10 results

  1. 1
    01:48
    time
    100
    score
Do you want to stay in the Top 10 of this game? to identify yourself.
Make your own free game from our game creator
Compete against your friends to see who gets the best score in this game

Top Games

  1. time
    score
  1. time
    score
time
score
time
score
 
game-icon

Fill in the Blanks

Practice ProgrammingOnline version

Practice Programs

by Liz Smith
1

temp newX cout move iostream x endl moving Point main x int int newY pt namespace int pt p int new location return int temp Print Print

Purpose : pass a struct to a function and return a struct variable


#include / / for standard i / o
using std ; / / reserve library objects for standard use

/ / declare the Point to represent a 2D point

struct Point
{
; / / the x coordinate
int y ; / / the y coordinate

} ;

void ( ) ; / / to print a point in the format of ( x , y )

Point ( Point , , ) ; / / to move a point to a new location


int ( )
{
Point pt = { 1 , 2 } ; / / the given point

/ / display the point before moving
<< " Before , = " ;
Print ( pt ) ;
cout << endl ;

/ / move the point to ( 3 , 6 )
pt = move ( pt , 3 , 6 ) ;


/ / display the point after moving
cout << " After moving , pt = " ;
( ) ;
cout << ;

/ / successfully done
return 0 ;
}

void Print ( Point p )
/ / to print a point
{
cout << " ( " << . << " , " << p . y << " ) " ; / / print the format of ( x , y )
}
Point move ( Point p , , )
/ / to move a point
{
/ / point temp ;

/ / temp . x = newX ;
/ / temp . y = newY ;
Point = { newX , newY } ; / / a temporary point at a
;


}

educaplay suscripción