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

Info icon This 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.
Image of page 1

Info icon This 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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern