Concept explainers
Type in and run the five programs presented in this chapter. Compare the output produced by each
Data types:
The variables use data-type during their declaration.
- The data-type is used to determine the size of memory allocated. Here, the compiler allots the memory.
- All data-type needs different size of memory.
Some of the data-types are:
- Integer
- Boolean
- Character
- Double
- Floating point
Integer data type:
The “int” is a keyword for floating point datatype.
It is a number and it cannot have a fractional part. It may be a positive value, a negative value or zero.
- Integer data type uses 4 bytes of memory.
Boolean data type:
The “_Bool” is a keyword for floating point datatype.
- A Boolean data type is a data type that represents the two values.
- The two values are “true” and “false”.
Character data type:
A “char” is a keyword for character data type.
- Character data type stores the characters.
- Character data type requires one byte memory space.
- The character should always place inside the single quotes.
Double data type:
The “double” is a keyword for floating point datatype.
The size of the double variable contains 8 bytes.
It can represent real numbers, minus and decimal numbers.
Floating point data type:
The “float” is a keyword for floating point datatype.
- The data type “float” stores single precision floating point decimal values.
- The memory space used for float is “four” bytes.
Explanation of Solution
Program:
Consider the five programs presented in the given chapter.
Program 3.1:
//include the header file
#include <stdio.h>
//definition of main method
int main (void)
{
/*declare and initialize the value to the required variables*/
int integerVar = 100;
float floatingVar = 331.79;
double doubleVar = 8.44e+11;
char charVar = 'W';
_Bool boolVar = 0;
//display the result
printf ("integerVar = %i\n", integerVar);
printf ("floatingVar = %f\n", floatingVar);
printf ("doubleVar = %e\n", doubleVar);
printf ("doubleVar = %g\n", integerVar);
printf ("charVar = %c\n", charVar);
printf ("boolVar = %i\n", boolVar);
//return statement
return 0;
}
Explanation:
In the above program, declare the variables with different data types and assign values to that variables. Then display the values using “printf” function on the output screen.
Sample Output for program 3.1:
integerVar = 100
floatingVar = 331.790009
doubleVar = 8.440000e+11
doubleVar = 8.44e+11
charVar = W
boolVar = 0
Want to see more full solutions like this?
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects
Computer Science: An Overview (12th Edition)
Modern Database Management
Java: An Introduction to Problem Solving and Programming (8th Edition)
Database Concepts (7th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- Read the following program and answer the questions given at the end.arrow_forwardProblem 1: Design an algorithm/flowchart using Raptor that displays the product of first n even numbers. Submit raptor files along with your report. Your report should include the screenshot of your flowchart including sample input and output.arrow_forwardQuestion : By using Python Google Colab Programming Language, Experiment trials input text file is given below from which you have to answer. Calculate the median reaction time of all 75 trials. Calculate the % of ‘match’ trials in the first half of trials with reaction time less than or equal to the median reaction time. Next, calculate the % of ‘match’ trials in the second half of trials with reaction time greater than the median reaction time. Report both percentages. Based on a comparison of the two ‘match’ percentages what can be concluded about the relationship between the ‘match’ % and reaction time in your experimental data? Please share screenshot of code as well Output. Text.txt File Data is given Below. Please save it as Text.txt file name or You can Download it from this link sendanywhe.re/XXJ3M068 : 1 1 0 1 0 0 0 3000 3 8 8 01 2 0 1 0 0 0 3000 2 2 2 81 3 0 1 0 0 0 3000 3 3 3 21 4 0 1 0 0 0 3000 2 1 1 31 5 0 1 0 0 0 3000 2 11 11 11 6 1 1 1 0 0 469 1 1 1 111…arrow_forward
- (Heat transfer) The formula developed in Exercise 5 can be used to determine the cooling time, t, caused only by radiation, of each planet in the solar system. For convenience, this formula is repeated here (see Exercise 5 for a definition of each symbol): t=Nk2eAT3fin A=surfaceareaofasphere=4r2 N=numberofatoms=volumeofthespherevolumeofanatom Volume of a sphere sphere=43radius3 The volume of a single atom is approximately 11029m3 . Using this information and the current temperatures and radii listed in the following chart, determine the time it took each planet to cool to its current temperature, caused only by radiation.arrow_forward4. The car license (number) plate has 3 letters and 4 digits. Determine following. (a) no letter or digit can be repeated (without repetitions) (b) with repetitions allowedarrow_forward*Using C language and by using Arrays Develop a program to input the marks of 10 (ten) different subjects of a student through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100arrow_forward
- What do parentheses do in mathematical equations? a. Ensure addition functions are performed before subtraction functions b. Ensure multiplication functions are performed before division functions c. Ensure multiplication functions are performed before addition functions d. Ensure that whatever operation is inside the parentheses is performed firstarrow_forwardProduce the following program.arrow_forwardThe Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Two doctors, Dr. Best and Dr. Cushing, have formed a partnership.a. Design the logic that produces a merged list of patients' names in ascending order by birth year. (flowchart or pseudocode)b. Modify the program so that it does not display patients' names, but only produces a count of the number of patients born each year. (flowchart or pseudocode)arrow_forward
- Review the code below. Fig 1 The output of the code is: Fig 2arrow_forwardProblem B Musical Key ConversionThe chromatic scale is a 12-note scale in music in which all notes are evenly spaced: that is, the ratio of the frequency between any two consecutive notes is constant. The notes are typically labeled in the following sequence: A, A#, B, C, C#, D, D#, E, F, F#, G, G# After G#, the labels loop back and start over with A (one octave higher). To convert between musical keys, you can shift all notes in a piece of music a constant number of steps along the scale above. For example, the sequence of notes E, E, F, G, G, F, E, D, C, C, D, E, E, D, D can be converted to another musical key by shifting everything up three steps: E, E, F, G, G, F, E, D, C, C, D, E, E, D, D G, G, G#, A#, A#, G#, G, F, D#, D#, F, G, G, F, F Notice that G was converted to A#, since going three steps up required us to loop off of the top of the scale back to the bottom: G -> G# -> A -> A#. Technically we should note that this would be A# of the next octave up, but we’ll…arrow_forwardMatlab Application. Suppose that x, y, and z are the last 3 digits of your student number. 2020151955, the last 3 digits are 955 Write a script to declare your x, y and z: paste your script on the space provided below:arrow_forward
- 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