{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HES1300 Lab 2(1) - Swinburne University of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Swinburne University of Technology (Sarawak Campus) Faculty of Engineering, Computing and Science Semester 2, 2014 HES1300 Robotics & Mechatronics Project 1 (C Programming) Lab 2 – Problem solving in C Task 1 - Standard Input and Output formatting (printf() and scanf()) 1. Create a new program ( lab3_1.c ) which prints the following numbers and text exactly as shown: Name: John Note: the Player’s Name must always use 10 characters. Score: 7464 Note: the score must always use 5 digits. Attack: 134 (20 spaces) Defence: 89 Note: use 3 digits for Attack and Defence Gold: 1214.20 (20 spaces) Experience: 123.35 Note: Gold and Experience are 5 digits float with 2 decimal places 2. Create a new program ( lab3_2.c ) which reproduces the output of Task3_1.c , but uses named variables instead of hard-coded constants for all output data. You will need the following data types: Variable Type Name char [10] Score int Attack int Defence int Gold double Experience double 3. Declare and initialise the first four variables. ( e.g. int score = 100; ) 4. For the remaining variables, declare them first, and then initialise them on separate lines of code.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}