0% found this document useful (0 votes)
3 views

comp Fundamental Lab Report 05

Uploaded by

Qasimbutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

comp Fundamental Lab Report 05

Uploaded by

Qasimbutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

WEC DEPARTMENT OF MECHANICAL ENGINEERING TECNOLOGY

WEC/MET/COMP/LAB NO. 05

LAB REPORT (LAB NO.05)


Course Code CS-101 L Reg. No. Student Name
Course Title Computer Fundamental Lab UW-23-MET-BS-017 M. Qasim Butt
Lab Engr. Engr. M. Yaqoob UW-23-MET-BS-005 Shiekh Hassam
GA / Lab Asst. UW-23-MET-BS-003 Touqeer
Group No. UW-23-MET-BS-015 Ziad Ali

Objective:
DEVELOP PROGRAM TO ASSIGN VALUES TO VARIABLES AND
CONSTANTS
Abstract:
In the development process of a program designed to assign values to variables and constants,
various key tasks were accomplished. The project involved creating a structured system to
facilitate the assignment of values to variables and constants within a programming
environment.
The initial phase of the development process focused on defining and declaring variables and
constants, establishing their data types, and allocating memory space accordingly. This step was
crucial for ensuring efficient storage and retrieval of values during program execution.
Following the declaration phase, the program logic was implemented to assign specific values to
the declared variables and constants. This involved the use of assignment operators and
adherence to the programming language's syntax and rules. The development team paid careful
attention to handling data types appropriately to prevent potential errors or inconsistencies.
Procedure:
Step1. Open a Text Editor or an Integrated Development Environment (IDE).
Choose a text editor or an IDE to write your C++ code. Popular choices include Visual Studio Code,
Code::Blocks, or any other C++ IDE you prefer.
Step2. Create a New C++ File.
Start a new C++ source file with a .cpp extension. For example, you can name it main.cpp.
Step3. Include Necessary Headers.
In the beginning of your file, include any necessary header files. For basic input and output operations,
include the <iostream> header.
#include <iostream> using namespace std;
Step4. Declare Variables and Constants.
Declare the variables and constants that you'll be using in your program. Variables hold values that can
change during the program execution, while constants have fixed values.

int main() { const double PI = 3.14159;


// Declare variables
int myInteger; //Your code goes here
double my Double;
return 0;
// Declare constants }

Mechanical Engineering Department, University of Wah, Wah Cantt 1


Step5. Assign Values to Variables and Constants.
Assign values to your variables and constants. You can do this using the assignment operator =.
myInteger = 42; myDouble = 3.14; // Constants cannot be changed once assigned // PI = 3.0; // This
would result in a compilation error
Step6. Use Variables and Constants.
Perform any operations or output involving the variables and constants in your program.
cout << "Integer value: " << myInteger << endl; cout << "Double value: " << myDouble << endl; cout <<
"Value of PI: " << PI << endl;
Step7. Compile and Run.
Save your file and compile it using a C++ compiler. If you're using an IDE, there will be an option to build
and run your program. If you're using a command-line compiler, use commands like g++ to compile and
then run the executable.
Step8. Review and Debug.
Check the output and make sure your program is working as expected. If there are errors, review your
code and make corrections.

Conclusion:
In conclusion, developing a program to assign values to variables and constants in C++ is a
fundamental aspect of programming. This process involves declaring variables and constants,
specifying their data types, and assigning appropriate values to them. The program should
adhere to the principles of good coding practices, such as clarity, readability, and
maintainability.
By creating such a program, you gain a foundational understanding of variable and constant
usage in C++, which is essential for more complex programming tasks. This knowledge lays the
groundwork for further exploration into data manipulation, control flow, and the development of
more sophisticated applications.
In summary, mastering the creation of programs that assign values to variables and constants is a
crucial step in becoming proficient in C++ programming and sets the stage for more advanced
software development endeavors.

THE END

Mechanical Engineering Department, University of Wah, Wah Cantt 2

You might also like