Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

Lab 4 – Classes

Part 1
If statement
if (x==0)
cout<<x<<" is equal to zero"<<endl;
else if (x%2==0)
cout<<x<<"is an even number"<<endl;

else cout<<x<<" is an odd number"<<endl;

}
Ternary operations
string result = (x==0) ? "is equal to zero"
: (x%2==0) ? "is an even number"
: "is an odd number";
Loops

for (int i =0; i<rows; i++)


{
int j=0;
while (j<=i)
{
cout<<"* ";
j++;
}
cout<<endl;
}
Functions
Struct
Class declaration
Class constructor
Class functions
Separating classes

You might also like