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

Lab #3

Uploaded by

Mugheera Malik
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)
5 views

Lab #3

Uploaded by

Mugheera Malik
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/ 4

LAB NO.

3 DD/MM/YYYY

IDENTIFIERS AND KEYWORDS (RESERVED WORDS)


Lab outcomes:
After completing this lab, students will be able to:
 Understand Identifiers.
 Understand keywords.

Corresponding CLO and PLO:


 CLO-1, PLO-2 (Engineering Knowledge)
Theory:
IDENTIFIERS: Identifiers in C++ are names given to entities such as variables, functions,
classes, and namespaces. These names are used to identify and refer to the entities in the code.
An identifier is a sequence of letters (both uppercase and lowercase), digits, and underscores,
which must begin with a letter or an underscore. Identifiers are case-sensitive, which means that
uppercase and lowercase letters are considered different.
Here are some examples of valid identifiers in C++:
 myVariable
 myFunction
 MyClass
 my_namespace
 var1
 _myVar
 My_Class
Identifiers should be chosen carefully to make the code easy to read and understand. They should
be descriptive and convey the purpose of the entity they are identifying.
KEYWORDS: Keywords are reserved words that have a specific meaning and purpose within the
language. They cannot be used as identifiers (variable names, function names, etc.) and are used
to define the syntax and structure of programs. Here are the definitions of some commonly used
keywords.
Example:
Here are some commonly used keywords in C++ programming language:
 auto: used to deduce the data type of a variable automatically
 break: used to exit a loop prematurely
 case: used in a switch statement to define a particular condition to be evaluated
 char: used to define a character data type
 const: used to define a variable as constant, which cannot be modified
 continue: used to skip the current iteration of a loop and move on to the next iteration
 double: used to define a double-precision floating-point data type
 else: used in an if statement to specify a block of code to be executed if the condition is
false
 for: used to create a loop that executes a block of code for a specified number of times
 if: used to test a condition and execute a block of code if the condition is true
 int: used to define an integer data type
 namespace: used to define a scope of identifiers
 return: used to return a value from a function
 static: used to define a variable or function as static, which means it retains its value
between function calls
 struct: used to define a user-defined data type
 switch: used to create a multiple-branch statement
 void: used to indicate that a function does not return any value
 while: used to create a loop that executes a block of code as long as the specified
condition is true.

Activities:
Activity 2.1: Write a program in C++ that will declare two variables of integer type and
assign value to them.
Code:
Please write or paste your code snap here.
Output:
Please paste your output screenshot here with your Name and CMS mentioned in it.
Activity 2.2: Declare a variable with identifier that will contain _ symbol only.
Code:
Please write or paste your code snap here.
Output:
Please paste your output screenshot here with your Name and CMS mentioned in it.
Activity 2.3: Is the following identifier valid for variable, if yes, then explain why:
decimal @abstract;
Code:
Please write or paste your code snap here.
Output:
Please paste your output screenshot here with your Name and CMS mentioned in it.
Activity 2.4: Is the following identifier valid, if not explain why:
long my data;
int price$;

Code:
Please write or paste your code snap here.
Output:
Please paste your output screenshot here with your Name and CMS mentioned in it.
Activity 2.4: Write a computer program that takes two integers as inputs from user and
display their values:
Code:
Please write or paste your code snap here.
Output:
Please paste your output screenshot here with your Name and CMS mentioned in it.

Observations:
Please write your observation after conducting this lab, you have to write in few lines, what did
you learn in this lab.
Rubrics
Absent Student is Student can Student has Student has Student
unable to understand followed constructed perfectly
follow the the instructions the implemented
provided provided to construct functional/ a working
instructions laboratory the working model/
properly. instructions fundamenta schematic/ logic/
The student and familiar l schematic/ model/ circuit/
can name the with the lab block block block
hardware or environmen diagram/ diagram/ diagram/
simulation t (Trainer/ code/ code, and code and
Demonstratio
platform, but software/ model on have successfully
n
unable to IDE), but the successfull executed the
implement cannot protoboard/ y executed lab objective
anything implement trainer/ the in Realtime
practically or on the simulation program/ or in a
on the platform software. run circuit simulation
software practically on software environment
or on the platform and
software produced the
desired
results
Category Ungraded Very Poor Poor Fair Good Excellent
Percentage [0] [1-20] [21-40] [41-60] [61-80] [81-100]
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
Date Total Instructor’s Signature
Marks

Report Plagiarized Requirement Observation Appropriate Correctly


not content s are listed s are computation drawn
submitted presented or and recorded s or conclusion
incomplete experimental along with numerical with
Laboratory
submission procedure is detailed analysis is exact results
Reports
presented procedure performed and
complete
report in all
respects
Category Ungrade Very Poor Poor Fair Good Excellent
d
Percentage [0] [1-20] [21-40] [41-60] [61-80] [81-100]
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
Date Total Instructor’s Signature
Marks

You might also like