Learning Objectives: After completing this lab the student will be able to:
Use the relational and logical operators to write conditional expressions.
Write if statements to select a block to be executed when a conditional expression is true.
Write ifelse statements to select one block or a different block to execute based on the result of a conditional
expression.
Part Relational Operators and the If Statement
In your C IDE, create a new project named Lab Part or something similar. Add a C source code file named lab
cpp to the project. Then copyandpaste the code below into labcpp
PROJECT: Lab Part
FILE: labcpp
DESCR: This project will help you learn the difference between the C
assignment operator and the C relational equality operator
They are completely different operators and they work in completely
different ways.
AUTHOR: Your Name
DATE: The date the project is completed or published
#include
using namespace std;
int main
int num; num is not initialized
int num; num has been initialized to
cout "Please enter an integer" endl;
cin num;
cout "num num and num num endl;
if num num
cout "Hey, thats a coincidence!" endl;
if num num
cout "The values are not the same" endl;
return ;