Question: Type in the hello world program shown on the board, compile it and get it to run. write the program using C. // ------------------------------------------------------------------------------------------ //

  1. Type in the hello world program shown on the board, compile it and get it to run. write the program using C.

// ------------------------------------------------------------------------------------------

// Name: Your name here

// Class: C++ 1

// Abstract: Homework 1.

// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------

// Includes

// ------------------------------------------------------------------------------------------

#include

#include

// ------------------------------------------------------------------------------------------

// Constants

// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------

// Prototypes

// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------

// Name: main

// Abstract: This is where the program starts

// ------------------------------------------------------------------------------------------

void main( )

{

printf( Hello World );

}

Step 2

  1. Modify the program in step 1 so that it will print the minimum and maximum values for the following data types:
  • short
  • integer
  • long
  • float

  1. Be sure to:
  • Verify that maximum and minimum values by adding or subtracting one and then printing.
  • Make your code readable.
  • Make the output readable.
  • Use the printf statement to output your answers.
  • The printf format specifiers match the data type.

  1. You cannot use the built-in limits if you know what those are.

  1. Be sure to test the minimum and maximum values for each data type by subtracting 1 and adding 1 and then printing out the variables again. For example:

shtMinimum = shtMinimum 1;

System.out.println( "Short Minimum Confirmation: " + shtMinimum + " " );

  1. What happens if you go past the minimum or maximum?

Put you answers in comments in the program for each data type.

Minus 25% for missing answers or incorrect answers.

  1. You must declare and set a variable to hold each value. You cannot simply hardcode the values into the printf statement. For example:

// Bad Code Example

printf( Short Maximum: 32767 ); // This is not allowed. You must use a variable.

// Good Code Example

// Declare variables

short shtMinimum = 0;

short shtMaximum = 0;

// Set to min/max values

shtMinimum = 100 ;

shtMaximum = 100 ;

// Short

printf( Short Minimum and Maximum );

printf( ------------------------------------------------ );

printf( Short Minimum: %hd , shtMinimum );

printf( Short Maximum: %hd , shtMaximum );

printf( );

shtMinimum =1;

shtMaximum +=1;

printf( Confirmation );

printf( Short Minimum: %hd , shtMinimum );

printf( Short Maximum: %hd , shtMaximum );

printf( );

Extra Credit

Make procedures for each data type. For example:

void main( )

{

DisplayShortMinimumAndMaximum( );

DisplayIntegerMinimumAndMaximum( );

...

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!