HW2 Solutions

# HW2 Solutions - EC327 Introduction to Software Engineering HW#2 Solutions Problem 1[24 points Please write a short C program that displays the

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EC327 Introduction to Software Engineering HW #2 Solutions Problem 1 [24 points] Please write a short C program that displays the range of values that can be assigned to the following data types. For example, unsigned byte should show a range of 0x00 to 0xFF. Please make sure to include your code. i. char ii. unsigned byte iii. short int iv. int v. unsigned int vi. long vii. float viii. double //HW#2 Problem 1 //Answered by Jiaxi Jin #include <stdio.h> #include <math.h> //We need power function pwr(double, int) to initialize float and double value int main(void) { char charMin = 0x00;//For this problem, I will set the exact min and max values to variables. You can try other values:-) char charMax = 0x7F; printf("A char variable's range is of 0x%x to + 0x%x", charMin, charMax); unsigned byte uByteMin = 0x00; unsigned byte uByteMax = 0xFF; printf("A unsigned byte variable's range is of 0x%x to 0x%x", uByteMin, uByteMax); short int sIntMin = -0x8000; short int sIntMax = 0x7FFF; printf("A short int variable's range is of 0x%x to 0x%x", sIntMin, sIntMax); int intMin = -0x80000000; //For most common 32-bit computers int intMax = 0x7FFFFFFF; //For most common 32-bit computers printf("An int variable's range is of 0x%x to 0x%x", intMin, intMax); unsigned int uIntMin = 0x00000000; //For most common 32-bit computers...
View Full Document

## This note was uploaded on 11/09/2010 for the course ECE 327 taught by Professor Babakkia during the Fall '09 term at BU.

### Page1 / 4

HW2 Solutions - EC327 Introduction to Software Engineering HW#2 Solutions Problem 1[24 points Please write a short C program that displays the

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online