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 use the correct limits.h constant). Display the value using printf with %d format. Please refer to this link for more information on constants from limits.h.
Declare a double variable with a value set to positive infinity. Display the value using printf with the %f format.
Prompt the user and accept the following 4 types of values from a single input line: char int char float
Display the values that were read in (d)
Prompt the user and accept the following types of values from a single input line: char float int char
Display the values that were read in (f)
Prompt the user and accept an integer value
Display the value read in (h) in a right-justified field of width 15, with leading zeroes.
Prompt the user and accept a float value
Display the value read in (j) in a right-justified field of width 15, with 2 decimal points of precision, and leading spaces
THIS NEEDS TO BE C, C IS DIFFERENT THAN C++
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
#include<stdio.h>
#include<limits.h>
#include<math.h>
int main(){
//Declare a character variable with value 'a', and display the character
char c='a';
printf("%c\n",c); //using %c
printf("%d\n",c); //using %d
//Declare a short int variable with a value set to the maximum value of a short int
short s=SHRT_MAX;
//displaying the value
printf("%d\n",s);
//Declare a double variable with a value set to positive infinity
double d=INFINITY;
//Display the value using printf with the %f format.
printf("%f\n",d);
char c1, c2;
int i1;
float f1;
//Prompt the user and accept the following 4 types of values from a
//single input line: char int char float
printf("Enter a char, int, char and float: ");
scanf(" %c %d %c %f",&c1,&i1,&c2,&f1);
//Display the values that were read
printf("%c %d %c %f\n",c1,i1,c2,f1);
//Prompt the user and accept the following types of values from a
//single input line: char float int char
printf("Enter a char, float, int and char: ");
scanf(" %c %f %d %c",&c1,&f1,&i1,&c2);
//Display the values that were read
printf("%c %f %d %c\n",c1,f1,i1,c2);
//Prompt the user and accept an integer value
printf("Enter an integer value: ");
scanf("%d",&i1);
//Display the value read in (h) in a right-justified field
//of width 15, with leading zeroes.
printf("%015d\n",i1);
//Prompt the user and accept a float value
printf("Enter a float value: ");
scanf("%f",&f1);
//Display the value read in (j) in a right-justified field of width 15, with 2 decimal
//points of precision, and leading spaces
printf("%15.2f\n",f1);
return 0;
}
/*OUTPUT*/

Create a program (in C, not C++) called lab3.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...
(Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....
Declare the following three variables: char letter; int number; double decimalNumber; Prompt the user to enter a letter. Read the letter into the variable letter Assign to the variable number the value from the variable letter Assign to the variable decimalNumber the value from the variable number Print the values of the three variables using the following format: Character: K Number: 75 Decimal number: 75 Test the program with the input letter a and copy the results into a comment...
Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...
Please, I need help, I cannot figure out how to scan variables
in to the function prototypes!
******This is what the program should look like as it runs but I
cannot figure out how to successfully build the code to do
such.******
My code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <conio.h>
float computeSeriesResistance(float R1, float R2, float R3);
float computeParallelResistance(float R1, float R2, float
R3);
float computeVoltage(int current, float resistance);
void getInputR(float R1, float R2, float R3);
void getInputCandR(int...
C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () { int numDucks,numCats; getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...
Step 2: Create the method specified below. static int GetValidWidth(string prompt) Input parameters prompt: message for user describing the input required Returns A non-zero width entered by the user Step 3: Create the method specified below. static int GetValidHeight(string prompt) Input parameters prompt: message for user describing the input required Returns A non-zero positive height entered by the user Step 4: Create the method specified below. static void DisplayBox(int width, int height, char fillChar) Input parameters width: width of each...
Write a full MIPS that behaves exactly like the following C
program.
The following C code shows the proposed algorithm. The string is
traversed with two indices, called old_index and new_index, where
the latter always takes a value less or equal to the former. When a
non-space character is found, the character at position old_index
is copied to position new_index, and both indices are incremented.
When a space is found, the current character is not copied, and
only old_index is...
Using Unix/Linux Command line in terminal and C programming. (b) Write a basic C program contained in a1q4.c and perform the following tasks in your program’s main() function: (8 marks) • Declare and initialize at least one variable of these types: char, int, unsigned int, float, double and long double. When initializing your variables, ensure the constants you use are of the same type as your variable. See the “Constants” section of Topic 7 for more information. • Use printf(3)...
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...