Question

***The following is to be written in C:****

Modify the sizeof.c program (in the sizeof folder on github) and show the data range (min and max) in addition to the size of

****The following is the sizeof.c program that needs to be modified:****#include <stdio.h> int main() char c; unsigned char uc; short s unsigned short us; int i; unsigned int ui; long 1; unsigned l

****Section B11 the question asks to refer to:****

B11. Implementation-defined Limits: <limits.h> and <float.h> The header «limits.h> defines constants for the sizes of integra

decimal digits of precision smallest number x such that 1.0 + x number of base FLT RADIx digits in mantissa maximum double fl

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<limits.h>
#include<float.h>

int main()
{

printf(" Data type | size | Min | Max |\n");
printf("------------------------------------------\n");
char c;
printf(" char %lu %d %d \n",sizeof(c),SCHAR_MIN,SCHAR_MAX);


printf("------------------------------------------\n");
unsigned char uc;
printf("unsigned char %lu 0 %d \n",sizeof(uc),UCHAR_MAX);
printf("------------------------------------------\n");
short s;
printf(" short %lu %d %d \n",sizeof(s),SHRT_MIN,SHRT_MAX);
printf("------------------------------------------\n");
unsigned short us;
printf("unsigned short %lu 0 %d \n",sizeof(us),USHRT_MAX);
printf("------------------------------------------\n");
int i;
printf("int %lu %d %d \n",sizeof(i),INT_MIN,INT_MAX);
printf("------------------------------------------\n");
unsigned int ui;
printf("unsigned int %lu 0 %u \n",sizeof(ui),UINT_MAX);
printf("------------------------------------------\n");
long l;
printf("long %lu %ld %ld \n",sizeof(l),LONG_MIN,LONG_MAX);
printf("------------------------------------------\n");
unsigned long ul;
printf("unsigned long %lu 0 %lu \n",sizeof(ul),ULONG_MAX);
printf("------------------------------------------\n");
long long ll;
printf("long long %lu %ld %lld \n",sizeof(ll),LLONG_MIN,LLONG_MAX);
printf("------------------------------------------\n");
unsigned long ull;
printf("unsigned long long %lu 0 %llu \n",sizeof(ull),ULLONG_MAX);

printf("------------------------------------------\n");
float f;
printf("float %lu %f %f |\n",sizeof(f),FLT_MIN,FLT_MAX);
printf("------------------------------------------\n");
double d;
printf("double %lu %lf %lf |\n",sizeof(d),DBL_MIN,DBL_MAX);


}

output depends upon compilers:

Add a comment
Know the answer?
Add Answer to:
***The following is to be written in C:**** ****The following is the sizeof.c program that needs...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C: Implement the function ranges that takes no input and prints the ranges (i.e., the...

    Using C: Implement the function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of the types char, short, int, long, and long long, both signed and unsigned. You should do this by printing appropriate constants defined in the header file /usr/include/limits.h (this is why hw1.c starts with #include <limits.h>). This should print something like: signed char minimum value: -128 maximum value: 127 unsigned char minimum value: 0 maximum value: 255 signed short...

  • In c++ programming, can you please edit this program to meet these requirements: The program that...

    In c++ programming, can you please edit this program to meet these requirements: The program that needs editing: #include <iostream> #include <fstream> #include <iomanip> using namespace std; int cal_avg(char* filenumbers, int n){ int a = 0; int number[100]; ifstream filein(filenumbers); if (!filein) { cout << "Please enter a a correct file to read in the numbers from"; }    while (!filein.eof()) { filein >> number[a]; a++; } int total = number[0]; for (a = 0; a < n; a++) {...

  • Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be...

    Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be compatible with Visual Studio 2015.asm file): (10 points) Write an assembly program to find the largest element by searching an array int aryll-[11, 15,-3,-4, 0,60.11,-9,18) int index-l; int max- 0; int arraySize-sizeof array /sizeof max while (index < arraySize) if (ary[index] > max) max = ary[index]; - Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • Prints out the size of (there’s a hint, by the way) variables with the following C...

    Prints out the size of (there’s a hint, by the way) variables with the following C data types – int, long, unsigned, long long, char, float and double. This is how many bytes of memory a variable of that type occupies on this machine, using your chosen compiler. (Xcode) Answer the following question: Does adding the static keyword to the declaration of these variables in your program change their size? Answer the following question: What is the largest number and...

  • Problem overview. There are a number of ways to normalize, or scale, a set of values....

    Problem overview. There are a number of ways to normalize, or scale, a set of values. One common normalization technique scales the values so that the minimum value goes to 0, the maximum value goes to 1, and the other values are scaled accordingly. Using this normalization technique, the values of the array below are normalized. Original Array Values -1 -2 2 Normalized Array Values 0.25 0.01.0 0.5 The equation that computes the normalized value from a value xe in...

  • Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code...

    Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array. 2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table. 3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table. C++ Program #include <stdio.h> #include <iostream> int...

  • Create a C program that: Within main, declares a linear array consisting of 10 double values....

    Create a C program that: Within main, declares a linear array consisting of 10 double values. You can assign values to the array when it is declared or fill them items manually using scanf () - your choice. Also, declare three doubles: min, max, and average. Then from within main, a function is called. The function should take a pointer to the array declared above and then finds the maximum value, the minimum value, and calculates the average of the...

  • Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays...

    Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays their values: 1. Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the character with a %d format. 2. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your...

  • C programming course. Cannot use global variables. This is the assignment: In this project you will...

    C programming course. Cannot use global variables. This is the assignment: In this project you will calculate the maximum profit you could have made by trading a single stock over a period of one month. You will assume that you bought rounded stock units (usually in hundreds, or tens) worth between $3000 and $5000 at the best possible“closing” price during the period and sold it at the best possible “closing” price. You will assume that you are permitted to buy...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT