Skip to content

reetikasinghh/c-program-Datatypes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

c-program-Datatypes

Program Aim: The aim of this program is to demonstrate the declaration and use of different data types in C++, including integers, floating-point numbers, double-precision floating-point numbers, characters, and booleans. It prompts the user to input values for these data types and then displays the entered values.

Program Theory:

#include: This line includes the necessary header file to enable input and output operations in the program.

int main(): This is the entry point of the program. All C++ programs start execution from the main function.

using namespace std;: This line allows us to use the standard C++ library (std) without explicitly specifying it in the code. It simplifies the code by eliminating the need to prefix elements from the standard library with "std::".

Declaration of variables:

int myintvar;: Declares an integer variable to store whole numbers. float myfloatvar;: Declares a float variable to store numbers with decimals. double mydoublevar;: Declares a double variable to store larger numbers with decimals. char mycharvar;: Declares a character variable to store single letters or symbols. bool myboolvar;: Declares a boolean variable to store true or false values. cout and cin statements: These statements are used to display prompts to the user and read values from the user for each variable.

Displaying the entered values: After reading values from the user, the program displays the entered values for each data type using cout.

return 0;: This statement indicates the successful termination of the program with a return value of 0.

Program Algorithm:

Declare variables for each data type: integer, float, double, character, and boolean. Prompt the user to enter values for each data type. Read the user's input for each variable. Display the entered values for each data type. Program Conclusion: This C++ program demonstrates the declaration and use of various data types, including integers, floating-point numbers, double-precision floating-point numbers, characters, and booleans. It prompts the user to enter values for each data type and then displays the entered values. This program serves as a basic introduction to data types and input/output operations in C++.

Program Aim: The aim of this program is to determine and display the sizes (in bytes) of different data types in C++, including integers, floats, doubles, characters, and booleans.

Program Theory:

#include: This line includes the necessary header file to enable input and output operations in the program.

int main(): This is the entry point of the program. All C++ programs start execution from the main function.

using namespace std;: This line allows us to use the standard C++ library (std) without explicitly specifying it in the code. It simplifies the code by eliminating the need to prefix elements from the standard library with "std::".

Declaration of variables:

int myintvar;: Declares an integer variable to store whole numbers. float myfloatvar;: Declares a float variable to store numbers with decimals. double mydoublevar;: Declares a double variable to store larger numbers with decimals. char mycharvar;: Declares a character variable to store single letters or symbols. bool myboolvar;: Declares a boolean variable to store true or false values. cout and cin statements: These statements are used to display prompts to the user and read values from the user for each variable.

Displaying the sizes of data types: The program uses the sizeof operator to determine and display the sizes of data types in bytes.

return 0;: This statement indicates the successful termination of the program with a return value of 0.

Program Algorithm:

Declare variables for each data type: integer, float, double, character, and boolean. Prompt the user to enter values for each data type. Read the user's input for each variable. Use the sizeof operator to determine and display the size of each data type in bytes. Program Conclusion: This C++ program demonstrates how to determine and display the sizes of different data types in bytes. It prompts the user to enter values for each data type and then calculates and displays the size of each data type. The size of a char variable is always 1 byte, while the sizes of other data types may vary depending on the system and compiler used.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages