Lab6 (PF)
Lab6 (PF)
Task 1:
#include <iostream>
using namespace std;
int main()
{
int day;
cout << "Enter day: ";
cin >> day;
switch (day)
{
case 1:
cout << "Monday" << endl;
break;
case 2:
cout << "Tuesday" << endl;
break;
case 3:
cout << "Wednesday" << endl;
break;
case 4:
cout << "Thursday" << endl;
break;
case 5:
cout << "Friday" << endl;
break;
case 6:
cout << "Saturday" << endl;
break;
case 7:
cout << "Sunday" << endl;
break;
}
system("pause");
return 0;
}
Task 2:
#include <iostream>
using namespace std;
int main()
{
int day = 4;
switch (day)
{
case 6:
cout << "Today is Saturday";
break;
case 7:
cout << "Today is Sunday";
break;
default:
cout << "Looking forward to the weekend" << endl;
}
system("pause");
return 0;
}
Task 3:
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
cout << "Enter the value of the first number: ";
cin >> num1;
cout << "Enter the value of the second number: ";
cin >> num2;
char operation;
cout << endl;
cout << "Press + for sum" << endl;
cout << "Press - for subtraction" << endl;
cout << "Press * for multiplication" << endl;
cout << "Press / for division" << endl
<< endl;
Task 4:
#include <iostream>
using namespace std;
int main()
{
char alphabet;
cout << "Enter your alphabet: " << endl;
cin >> alphabet;
system("pause");
return 0;
}
Task 5:
#include <iostream>
using namespace std;
int main()
{
char alphabet;
cout << "Enter your alphabet: " << endl;
cin >> alphabet;
Task 6:
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Enter an integer: " << endl;
cin >> num;
switch ((num > 0) - (num < 0))
{
case 1:
cout << "The number is Positive" << endl;
break;
case -1:
cout << "The number is Negative" << endl;
break;
default:
cout << "The number is Zero" << endl;
break;
}
system("pause");
return 0;
}
Task 7:
#include <iostream>
using namespace std;
int main()
{
char grade;
int failed_subjects;
switch (grade)
{
case 'A':
case 'a':
if (failed_subjects <= 3)
{
cout << "The total grace marks are: " << 5 * failed_subjects << endl;
}
else
cout << "No grace marks are awarded" << endl;
break;
case 'B':
case 'b':
if (failed_subjects <= 2)
{
cout << "The total grace marks are: " << 4 * failed_subjects << endl;
}
else
cout << "No grace marks are awarded" << endl;
break;
case 'C':
case 'c':
if (failed_subjects == 1)
{
cout << "The total grace marks are: " << 5 * failed_subjects << endl;
}
else
cout << "No grace marks are awarded" << endl;
break;
default:
cout << "The grade is invalid " << endl;
}
system("pause");
return 0;
}
S