C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 1E
Program Plan Intro
- Initialize the header files and main() function.
- To write the statements for printing the ranges of data types int, long, char, short, char, signed, and unsigned using the header file limits.h.
- Use the printf() statement to print all these.
Summary Introduction- The program prints the range of data types int, long, char, short, char, signed, and unsigned.
Program Description- The purpose of the program is toprint the range of data types int, long, char, short, char, signed, and unsigned.
Expert Solution & Answer
Explanation of Solution
Test Program:
/* Program: The program to display the range of data types. */ #include <stdio.h> #include <limits.h> intmain() { printf("bits: %d\n", CHAR_BIT); printf("unsigned char max: %d\n", UCHAR_MAX); printf("char max: %d\n", CHAR_MAX); printf("char min: %d\n", CHAR_MIN); printf("\n"); printf("unsigned int max: %u\n", UINT_MAX); printf("int min: %d\n",INT_MIN); printf("int max: %d\n",INT_MAX); printf("\n"); printf("unsigned short int max: %u\n", USHRT_MAX); printf("short int min: %d\n", SHRT_MIN); printf("short int max: %d\n", SHRT_MAX); printf("\n"); printf("unsigned long int max: %lu\n", ULONG_MAX); printf("long int min: %ld\n",LONG_MIN); printf("long int max: %ld\n",LONG_MAX); printf("\n"); return0; }
Sample Output -
bits: 8
unsigned char max: 255
char max: 127
char min: -128
unsigned int max: 4294967295
int min: -2147483648
int max: 2147483647
unsigned short int max: 65535
short int min: -32768
short int max: 32767
unsigned long int max: 4294967295
long int min: -2147483648
long int max: 2147483647
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
In C#, Compute the binomial expression (a+b)^2 using the following rubric:
Write code for computing the formula (a+b)^2 which expands into the following expression. In your code
•Compute squares of double type variables a and b. •Compute the product 2*a*b•Add the squares and the product together
•Use Math.POW library to compute the squares of the variables a and b. •Other functional code.
The C language standard (C99 standard) specifies the minimum field width of each variable type. The actual size of a variable type varies by implementations. Find out the minimum size of the following variable types in terms of bytes.
char
short
signed short int
int
long
unsigned long int
long long
unsigned long long
float
double
Note: Some data types above are the same type but with different names.
Please use C++ for the problem below
Chapter 2 Solutions
C Programming Language
Ch. 2 - Prob. 1ECh. 2 - Write a loop equivalent to the for loop above...Ch. 2 - Write the function htoi(s), which converts a suing...Ch. 2 - Write an alternate version of squeeze(s1,s2) that...Ch. 2 - Prob. 5ECh. 2 - Prob. 6ECh. 2 - Prob. 7ECh. 2 - Prob. 8ECh. 2 - Prob. 9ECh. 2 - Rewrite the function lower, which converts upper...
Knowledge Booster
Similar questions
- (Practice) Write specification statements for the following: a. An array of integers with 6 rows and 10 columns b. An array of integers with 2 rows and 5 columns c. An array of characters with 7 rows and 12 columns d. An array of characters with 15 rows and 7 columns e. An array of double-precision numbers with 10 rows and 25 columns f. An array of double-precision numbers with 16 rows and 8 columnsarrow_forwardCODE USING C++ We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate where among the 5-digit integer is the largest one. There are only 4 possible cases for this mission: if the largest digit is the first digit, print "Leftmost" if the largest digit is the third digit, print "Middle" if the largest digit is the last digit, print "Rightmost" if none of the above is correct, print "Unknown" Now, show me how far you've understood your lessons! Input A line containing a five-digit integer. 14632 Output A line containing a string. Middlearrow_forwardThis is a C programming question. Please use functions for answer. I am asking this: A program that finds the sum of the left and right diagonals of a 5 * 5 integer array (The program that finds the sums of the left and right diagonals of a 5 * 5 integer array entered on the keyboard separately and writes it on the screen)arrow_forward
- Can you help me with the highighted portion please?arrow_forwardWith the aid of c++, write a program which utilizes a random number generator to bring out(generate) a 2 digits +(positive) integer and permits the user to do 1 or more of the operations listed below.Solve /expresss the following. i.Reverse digits of the number ii.If the number has an exponent of 2,3 or 4 ii.Considering the number is a 3 digits number with its last digit <=4 and the exponent of the 1st 2 digits being that of the last digit N.b The 'number' word used above represents the randomly generated 2 digits +(positive) integer. a.In case the random number generated is less than 10,add ten to the number. b.Check if the number is a prime after each operation c.The code shouldn't be made up of global variables and also each of these operations should be implemented by a separate function d.Code should be menu driven and each successive operation must be performed on the number generated by the last operation. e.There should be a creation of an enumeration type called selection…arrow_forwardHello i need help with this problem. I keep getting it wrong. The program is in python,arrow_forward
- With the aid of c++, write a program which utilizes a random number generator to bring out(generate) a 2 digits +(positive) integer and permits the user to do 1 or more of the operations listed below.Find i.Sum of the digits of the number ii.double of the number In case the random number generated is less than 10,add ten to the number. N.b The 'number' word used above represents the randomly generated 2 digits +(positive) integer.arrow_forwardWrite C code that calculates and prints the volumes of different shapes (Sphere and Frustumarrow_forwardWrite a C program with two separate functions to determine 3 people' average score and highest score for user given data. Use array size of 5 to store marks and pass array to two separate functions for the average and highest score. (Note: the use of flag and bool is not allowed)The program output should look like this:Enter person 1’s Name: AvyaanEnglish score: 50Math score: 75Spanish score: 60Enter person 2's Name : Advik....Name : AvyaanHighest Score : 75Average Score : 61.6arrow_forward
- Programing C Just with #include Matrix Addition and Subtraction (Associatively) Write a program that performs matrices addition and subtraction. As shown in the example below, you have to ask the user for the number of rows and number of columns that both matrices should have (they both have to be the same size, that is why you only ask once). You will then ask the user for the values of each matrix. Then, you will print the values that the user inputted, the added values of both matrices, and the subtracted values (matrix 2 should be subtracted from matrix 1). In this challenge Guidelines/steps: • The number of rows and the number of columns should be global variables. • Once you get these two from the user, you should declare your two matrices in main. • Then, from main, you will call function aaa twice; first, you will send matrix 1 and populate it with values inputted by the user. You will call the function a second time, send matrix 2 and populate it. In other words, function aaa…arrow_forwardWrite array declarations for the ff: A. A list of 100 floating point voltages B. A list of 30 characters, each representing a code C. A list of 100 integer years D. A list of 1000 floating point distances E. A list of 32 floating point velocityarrow_forwardUsing C++ Write a program to output the sum of the first 50 prime numbers. Your output should allow the user to format. For example, the user should have the option of outputting 1.34 x 106 or choose to write the number as an integer or floatarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning