Programing C
Create union integer with members char c, short s, int i and long l. Write a program
that inputs values of type char, short, int and long and stores the values in union
variables of type union integer. Each union variable should be printed as a char, a
short, an int and a long.
Make sure that the correct values are printed as shown below in the example
An example interaction:
Enter a char: A
The char is: A
Enter a short int: 12
The short int is: 12
Enter an int: 145678
The int is: 145678
Enter a long int: 23001001034
The long int is: 23001001034
Code:
#include <stdio.h>
union integer {
char c;
short s;
int i;
long l;
} I;
int main()
{
printf("Size of union integer = %lu\n", sizeof(I));
printf("Enter a char: ");
scanf("%c", &I.c);
printf("The char is: %c \n", I.c);
printf("Enter a short int: ");
scanf("%hd", &I.s);
printf("The short int is: %hd \n", I.s);
printf("Enter an int: ");
scanf("%d", &I.i);
printf("The int is: %d \n", I.i);
printf("Enter a long int: ");
scanf("%ld", &I.l);
printf("The long int is: %ld \n", I.l);
return 0;
}
Output:

Programing C Create union integer with members char c, short s, int i and long l....
In "C" Language
(Using Unions) Create union integer with members char c, short s, int i and long b. Write a program that inputs values of type char, short, int and long and stores the values in union variables of type union integer. Each union variable should be printed as a char, a short, an int and a long. Do the values always print correctly:? Sample input/output. To print in hexadecimal, use %x as the formatter. Input must be same...
This is from chapter 10 ex 10.8 in c how to program 6th ed deitelWrite a program that inputs the values of type char, short, int, and long and stores the values in union variables of type union integer. Each union variable should beprinted as a char, a short, an int and a long. D the values always print correctly?. Also create a flow chart or psuedocode of the program .
WRITE THE FOLLOWING IN C (NOT C++ OR JAVA)
Problem 6A (5 points 10.8 (Using Unions) Create union integer with members char c, short s, int i and long b. Write a program that inputs values of type char, short, int and long and stores the values in union variables of type union integer. Each union variable should be printed as a char, a short, an int and a long. Do the values always print correctly? Sample input/output. To print...
WRITE THE FOLLOWING IN C (NOT C++ OR JAVA)
1o.9 (Using Unions) Create union floatingPoint with members float f, double d and long double x. Write a program that inputs values of rype float, double and long double and stores the float, a double and a long double. Do the values always print correctly? Note: The long double result will vary depending on the system (Windows, Linux, MAC) you use. So values in union variables of type union floatingPoint. Each...
using c++
Write a C++ program which reads three values of types char, int, double and string from the keyboard and primis, appropriately formatted, assigned values and variable types. For example, if letter, number, and real are variables of type char, int and double respectively, and if the values assigned to them using cin function are: a, 1, and 3.1415, then the output should be: a is a character 1 is an integen 3.1415 is a real number
Three variables x, y, and z defined as unsigned char, short, and int types in C Programming. What are the maximum values they can take? Compare the following C programs. After execution of this short programs what will be the value of x if printed in function? void foo(void); int main(void){ foo(); foo(); foo(); return 0; } void foo() { int x = 1; x++; } void foo(void); int main(void){ foo(); foo();...
In JAVA
1. Create a class called Rectangle that has integer data members named - length and width. Your class should have a default constructor (no arg constructor) Rectangle() that initializes the two instance variables of the object Rect1. The second overloading constructor should initializes the value of the second object Rect2. The class should have a member function named GetWidth() and GetLength() that display rectangle's length and width. OUTPUT: Rectl width: 5 Rectl length: 10 Enter a width :...
Need help programing this in C.
rinteivsors Print the proper divisors of an integer value The program should read a single integer input value, which you can assume will be positive. It should then print a single line of output with all of the proper divisors of the input value in order from least to greatest. A proper divisor d of an integer n is an integer that evenly divides n: i.e., nld is an integer For example, if the...
Create a program (in C, not C++) called lab3.c that declares the following variables and displays their values: Declare a character variable with value 'a', and display the character using printf with %c format. Then add a second printf that displays the character with a %d format. 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 assignment - so...
Write a C function named date() that receives an integer number of the long date, date form is yyyymmdd, such as 20070412; and the addresses of three variables named month, day, and year. determines the corresponding month, day, and year; and returns these three values to the calling function. For example, if date() is called using the statement longdate=20200411; date(longdate, &month, &day, &year); the number 4 should be returned in month, the number 11 in day, and the number...