0% found this document useful (0 votes)
4 views7 pages

Inbound 4328309183199004818

The document contains programming activities by Dave T. Tenerife, focusing on data types in C, including their sizes and the use of stddef.h. It includes pseudo code for simple and not-so-simple C programs that convert centimeters to meters and kilometers based on user input. The document also discusses the sizeof() function and its application in determining memory usage for different data types.

Uploaded by

Dave Dave
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

Inbound 4328309183199004818

The document contains programming activities by Dave T. Tenerife, focusing on data types in C, including their sizes and the use of stddef.h. It includes pseudo code for simple and not-so-simple C programs that convert centimeters to meters and kilometers based on user input. The document also discusses the sizeof() function and its application in determining memory usage for different data types.

Uploaded by

Dave Dave
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

ES 3 – COMPUTER FUNDAMENTALS AND PROGRAMMING

Chapter 6 Activity #2 Programming

Name: Dave T. Tenerife Student Number: 2024-72443


Yr./Blk.: 1/D

“SIZEOF”
Questions:

1. What is the size of datatype char?

-1

2. What is the size of datatype int?

-4

3. What is the size of datatype double?

-8

4. What is the size of datatype float?

-4

5. What is stddef.h? Why do we have to include it in the code(preprocessor


directive)?

-This header contains definitions for basic data types and macros for working
with memory. It defines the types ptrdiff_t, size_t, wchar_t, etc., and the
macros NULL and offsetof(). In short, it is used for purposes relating to the
memory and basic data types.

6. When do you use the following types: ptrdiff_t, wchar_t

- ptrdiff_t is used to store the result of subtracting two pointers, while


wchar_t is used to represent wide characters, often used in
internationalization and Unicode handling.

7. What is the sizeof() function?

Sizeof

-The sizeof operator applied to a type name yields the amount of memory
that can be used by an object of that type, including any internal or trailing
padding. Using the sizeof operator with a fixed-point decimal type results in
the total number of bytes that are occupied by the decimal type.
ES 3 – COMPUTER FUNDAMENTALS AND PROGRAMMING

Chapter 6 Activity #3 Programming

Name: Dave T. Tenerife Student Number: 2024-72443


Yr./Blk.: 1/D

“A VERY SIMPLE C PROGRAM”

Pseudo code:

Start

Declare double variables: centimeters, meters, kilometers

Display the message: “Enter measurement in centimeters:”

Input the value of centimeters

Calculate meters: meters = centimeters / 100

Calculate kilometers: kilometers = centimeters / 100000

Display the results: “The measurement is: meters meters and kilometers
kilometers”

End
Flow chart:
ES 3 – COMPUTER FUNDAMENTALS AND PROGRAMMING

Chapter 6 Activity #4 Programming

Name: Dave T. Tenerife Student Number: 2024-72443


Yr./Blk.: 1/D

“NOT SO SIMPLE C PROGRAM”

Pseudo code:
Start

Declare float: centimeters, meters, kilometers

Declare int: choice, valid_choice = 0

Display "Enter the measurements in centimeters:"

Input centimeters

Repeat

Display "Do you want to convert it to:"

Display "(1) meters"

Display "(2) kilometers"

Display "Please specify unit:"

Input choice

If choice == 1 then

meters = centimeters / 100

Display result in meters

Set valid_choice = 1

Else if choice == 2 then

kilometers = centimeters / 100000

Display result in kilometers

Set valid_choice = 1

Else

Display "Invalid choice!!!"

End if

Until valid_choice == 1

End

Flow chart:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy