Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 3, Problem 1E

Type in and run the five programs presented in this chapter. Compare the output produced by each program with the output presented after each program in the text.

Expert Solution & Answer
Check Mark
Program Plan Intro

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

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?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Ninth Edition Determine Zi, Zo and Av 20 V Zi + 1 ΜΩ 2 ΚΩ HH Z IDSS= 6MA Vp=-6V Yos = 40μS 20 and 47
What is the worst case time complexity of the following algorithm for i = 1 to x do  for j = 2^((i-1)x) to 2^(in) do print(i,j)
Prove for each pair of expression f(n) and g(n) whether f(n) is big O, little o Ω,ω or Θ of g(n). For each case it is possible that more than one of these conditions is satisfied:1. f(n) =log(n2^n), g(n) = log(sqrt(n)2^(n^2))2. f(n) =nsqrt(n) +log(n^n), g(n) =n + sqrt(n)logn

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY