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 minimum value: -32768 maximum value: 32767
Void ranges() {
//IMPLEMENT THIS
}
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
VERY IMPORTANT NOTES: These limits may vary depend on the version of the compiler you are using. LLONG_MIN, LLONG_MAX and ULLONG_MAX are introduced in compiler version C99, so old compilers may not support them. In some compilers int & short int have the same range, while in some other compilers, int and long types have the same range. Also, the definitions for format specifiers used in this code are below.
%d – int
%u – unsigned int
%ld – long int
%lu – unsigned long int
%lld – long long int
%llu – unsigned long long int
//CODE
#include<limits.h>
#include<stdio.h>
void ranges(){
//char-signed
printf("signed char\n");
printf("minimum value: %d\n",SCHAR_MIN);
printf("maximum value: %d\n",SCHAR_MAX);
//char-unsigned
printf("\nunsigned char\n");
printf("minimum value: %d\n",0);
printf("maximum value: %d\n",UCHAR_MAX);
//short-signed
printf("\nsigned short\n");
printf("minimum value: %d\n",SHRT_MIN);
printf("maximum value: %d\n",SHRT_MAX);
//short-unsigned
printf("\nunsigned short\n");
printf("minimum value: %d\n",0);
printf("maximum value: %d\n",USHRT_MAX);
//int-signed
printf("\nsigned int\n");
printf("minimum value: %d\n",INT_MIN);
printf("maximum value: %d\n",INT_MAX);
//int-unsigned
printf("\nunsigned int\n");
printf("minimum value: %d\n",0);
printf("maximum value: %u\n",UINT_MAX);
//long-signed
printf("\nsigned long\n");
printf("minimum value: %ld\n",LONG_MIN);
printf("maximum value: %ld\n",LONG_MAX);
//long-unsigned
printf("\nunsigned long\n");
printf("minimum value: %lu\n",0l);
printf("maximum value: %lu\n",ULONG_MAX);
//long long-signed
printf("\nsigned long long\n");
printf("minimum value: %lld\n",LLONG_MIN);
printf("maximum value: %lld\n",LLONG_MAX);
//long long-unsigned
printf("\nunsigned long long\n");
printf("minimum value: %llu\n",0ll);
printf("maximum value: %llu\n",ULLONG_MAX);
//Note: LLONG_MIN,LLONG_MAX and ULLONG_MAX are introduced in compiler version C99
//so old compilers may not support them.
}
int main(){
ranges();
return 0;
}
/*OUTPUT (using one compiler (DevC++))*/
signed char
minimum value: -128
maximum value: 127
unsigned char
minimum value: 0
maximum value: 255
signed short
minimum value: -32768
maximum value: 32767
unsigned short
minimum value: 0
maximum value: 65535
signed int
minimum value: -2147483648
maximum value: 2147483647
unsigned int
minimum value: 0
maximum value: 4294967295
signed long
minimum value: -2147483648
maximum value: 2147483647
unsigned long
minimum value: 0
maximum value: 4294967295
signed long long
minimum value: -9223372036854775808
maximum value: 9223372036854775807
unsigned long long
minimum value: 0
maximum value: 18446744073709551615
/*OUTPUT (using another compiler (online))*/
signed char
minimum value: -128
maximum value: 127
unsigned char
minimum value: 0
maximum value: 255
signed short
minimum value: -32768
maximum value: 32767
unsigned short
minimum value: 0
maximum value: 65535
signed int
minimum value: -2147483648
maximum value: 2147483647
unsigned int
minimum value: 0
maximum value: 4294967295
signed long
minimum value: -9223372036854775808
maximum value: 9223372036854775807
unsigned long
minimum value: 0
maximum value: 18446744073709551615
signed long long
minimum value: -9223372036854775808
maximum value: 9223372036854775807
unsigned long long
minimum value: 0
maximum value: 18446744073709551615
Using C: Implement the function ranges that takes no input and prints the ranges (i.e., the...
***The following is to be written in C:****
****The following is the sizeof.c program that needs to be
modified:****
****Section B11 the question asks to refer to:****
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 data types in a nice table (print one line for each data type). Refer to section B11 in your textbook (page 257) for getting min and max values...
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...
I need to implement a program that requests a x,y point and the radius of a circle. then it figures out the area and circumference using an overloaded operation. The full instructions, what I have and the errors I have are below. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as...
devmem2.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
#define FATAL do { fprintf(stderr, "Error at line %d, file %s
(%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); }
while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
int main(int argc, char **argv) {
int fd;
void *map_base = NULL, *virt_addr = NULL;
unsigned long read_result, writeval;
off_t target;
int access_type = 'w';
if(argc...
Design and implement a C version of the color match program. As a starting point, use the file HW2-1-shell.c. The program should employ a reasonable algorithm that compares all pairings of colors in the palette exactly once. A color should not be compared to itself. Nor should two colors be compared to each other more than once. Your C program should print out the total component color difference for the closest pair using the print string provided in the shell...
1. Implement a tostring() member function. This function will return a string representation of the LargeInteger. You should probably used string streams to implement this function. Note that the digits of the large integer are stored in reverse of their display order, e.g. the 1's place (100 ) is in index 0 of digits, the 10's place (101 ) is in index 1, etc. 2. Implement a second constructor for the LargeInteger. This constructor will be used to construct a...
Task The task for this assignment is to have the following user-defined data type: struct rgb { unsigned char red; unsigned char green; unsigned char blue; }; be able to be: read in from a stream (e.g., std::cin), i.e., write: std::istream& operator >>(std::istream& is, rgb& colour); (see below) written out to a stream (e.g., std::cout), i.e., write: std::ostream& operator <<(std::ostream& os, rgb const& colour); (see below) stored in a container, e.g., std::vector<rgb>, std::array<rgb,16>; (see below) processed via algorithms (and other...
please provide full answer with comments this is just begining
course of c++ so don't use advanced tequenicks I'll put main.cpp,
polynomial.h, polynomial.cpp and Cimg.h at the bottom of pictures.
If you help me with this will be greatly thankful thank
you
main.cpp
#include "polynomial.h"
#include "polynomial.h"
#include "polynomial.h"
#include "polynomial.h"
#include <iostream>
using std::cout;
using std::endl;
int main() {
pic10a::polynomial p1;
p1.setCoeff(0, 1.2);
p1.setCoeff(3, 2.2);
p1.setCoeff(7, -9.0);
p1.setCoeff(7, 0.0);
//degree of polynomial is now 3
cout << p1 <<...
For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...
I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...