Skip to content

Mayankyadav-018/Hello-World-and-Calculator-program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Experiment No. 1

  • Aim: To understand and implement the basic structure and syntax of a C++ program, including input/output operations, variables, and arithmetic operations.

  • Theory: C++ is a high-level, general-purpose programming language that supports both procedural and object-oriented programming. It is an extension of the C language and is widely used for system/software development and game programming. A basic C++ program helps beginners understand the foundational building blocks required for developing more complex applications. These building blocks include:

🔹 1. Header Files: The line #include is a preprocessor directive used to include the input/output stream library for using cin and cout.

🔹 2. Namespace: using namespace std; allows the program to use standard C++ objects (like cout and cin) without prefixing them with std::.

🔹 3. Main Function: Every C++ program must have a main() function. It is the entry point where execution begins.

🔹 4. Variables and Data Types: Variables are used to store data.

🔹 5. Input and Output: cout is used for output (printing to the screen). cin is used for input (taking user input from the keyboard).

🔹 6. Return Statement

Basic Arithmetic Operations(Calculator)

This program performs basic arithmetic operations (addition, subtraction, multiplication, division) using two integers entered by the user. It uses basic C++ features like cin, cout, variables, and arithmetic operators.

ALGORITHM

1> Start

2> Declare two integer variables: a, b

3>Take input for a and b using cin

4> Perform and display: Addition: a + b Subtraction: a - b Multiplication: a * b Division: a / b (assume b ≠ 0)

5> End

Conclusion: Through this experiment, we learned the basic structure and syntax of a C++ program. We understood how to use input/output statements (cin, cout), declare variables, and apply arithmetic operators. By creating a simple calculator, we practiced performing basic operations like addition, subtraction, multiplication, and division. This experiment strengthened our foundational understanding of programming logic and the use of core C++ functions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages