logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Connor BlackStatistics
(5/5)

892 Answers

Hire Me
expert
Ivan BlankBusiness
(5/5)

839 Answers

Hire Me
expert
Jon CulshawwComputer science
(5/5)

511 Answers

Hire Me
expert
Garardd BerwickData mining
(5/5)

902 Answers

Hire Me
C Programming

Implement function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of integer types char, short, int, long, and long long, both signed and unsigned

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS
  1. Implement function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of integer types char, short, int, long, and long long, both signed and unsigned. You should do this by printing appropriate constants defined in header file <limits.h> located in directory /usr/include. Your output should be similar to:

signed char
minimum value: -128
maximum value: 127

unsigned char
minimum value: 0
maximum value: 255

signed short
minimum value: -32768
maximum value: 32767

... (and so on)

Note: The conversion specifiers for signed and unsigned long are li and lu, respectively. The conversion specifiers for signed and unsigned long long are lli and llu, respectively. The minimum value for unsigned integers is always 0 and therefore not defined in header file <limits.h>.

  1. Implement function types that takes no input, declares 3 variables of type char, 3 of type short, 3 of type int, and 3 of type double---in that order---and prints the addresses of the 12 variables---in the same order---in both hex (use %p conversion specifier) and unsigned long format.

&a1 = 0x7ffd45e3ac0f, 140725776002063
&a2 = 0x7ffd45e3ac0e, 140725776002062
&a3 = 0x7ffd45e3ac0d, 140725776002061
&b1 = 0x7ffd45e3ac0a, 140725776002058
&b2 = 0x7ffd45e3ac08, 140725776002056
...

  1. Implement function input_output that prompts the message "Enter your name: ", takes a name from the user as input, and then prints Hello <name> (replace <name> with the name that the user entered). You should use the function printf to display the message, allocate memory for a null-terminated string of length up to 31 characters using char name[32], and then use the function fgets to read the input into the string, e.g. fgets(name, sizeof(name), stdin). To find out more information on the usage of fgets, you can read the Linux online manual page with the command man fgets. Below is a sample execution of the function:

Enter your name: John
Hello John

  1. Implement function area that prompts the user for the height and width of a rectangle, and then calculates and prints the area of the rectangle. You should allocate a string called height_string for the height, a string called width_string for the width, and use fgets to read user's input into height_string and width_string, respectively. To calculate the area of the rectangle, you need to convert the strings into integers and then multiply the integers. You should allocate an integer called height for the height and an integer called width for the width using int height, width, and then do the conversions using the function strtol, e.g. height=strtol(height_string, NULL, 10). A sample execution of the function is as below:

What is the height? 15
What is the width? 20
The area is 300.

  1. Implement function sum. In the function, make an array of integers containing integers from 1, 2, 3, ..., 10 and store it in a variable data. You can create the array and declare a variable data_len that contains the length of the array with the following code:
  1. int data[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  • size_t data_len = sizeof (data) / sizeof(data[0]);

Then declare an integer variable sum, use a for loop to print each integer in data, sum up all the numbers in data into sum, and print out the value of sum like below:

  

1

2

3

4

5

6

7

8

9

10

sum: 55

       

Note that the C for loop is different from the Python for loop. The C for loop contains three expressions: an initializer such as int j = 0, a test such as j < data_len, and an update such as j++. The initializer is executed once initially. The test is run before each iteration of the body, and the body is only executed if the test succeeds. The update is run after each iteration of the body.

 

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme