Computer Science Practical
Computer Science Practical
Examination 2025
PRACTICAL JOURNAL
Computer Science
For Class XII-AKU-E
Programming
DEPARTMENT OF COMPUTER SCIECNE
CERTIFICATE
Seat No
S/O,D/O
Date
PRACTICAL # 01
SLO # 12.1.2
#include <iostream>
using namespace std;
int main() {
int age;
cout<<"Enter Your Age: "<<endl;
cin>>age;
if (age >= 18) {
cout << "You are Eligible for Vote." << endl;}
return 0;}
if-else Statement:
#include <iostream>
using namespace std;
int main() {
int n;
cout<<"Enter a Integer: "<<endl;
cin>>n;
if (n > 0) { cout << "You Entered a Positive Number.";}
else { cout << "You Entered a Negative Number.";}
return 0;}
else-if Statement:
#include <iostream>
using namespace std;
int main() {
int marks;
cout<<"Enter your Obtained Marks (out of 100): "<<endl;
cin>>marks;
if (marks >= 90) {cout << "Grade: A" << endl;}
else if (marks >= 80) {cout << "Grade: B" << endl;}
else if (marks > 60) {cout << "Grade: C" << endl;}
else if (marks <= 60) {cout << "You are Pass." << endl;
return 0;}
PRACTICAL # 02
12.1.3:
Write a program using a nested if statement.
#include <iostream>
using namespace std;
int main() {
int rows = 5;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
cout << "*";}
cout << endl;}
return 0;}
PRACTICAL # 03
SLO # 12.1.5
Write a program using the switch statement.
#include <iostream>
using namespace std;
int main() {
int day;
cout << "Enter a number (1-7):"<<endl;
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;
default:
cout << "Invalid input!"<< endl; }return 0;}
PRACTICAL # 04
SLO # 12.2.2
Write a C++ program that uses for loop.
#include <iostream>
using namespace std;
int main(){
for (int i = 1; i <= 5; i++) {
cout<< "PAKISTAN" <<endl;}
return 0;}
PRACTICAL # 05
SLO # 12.2.3
Write a C++ program that uses while loop.
#include <iostream>
using namespace std;
int main() {
int number = 1;
while (number <= 10) {
cout << " " << number << endl;
number++;}
return 0;}
PRACTICAL # 06
SLO # 12.2.4
Write a C++ program that uses do while loop.
#include <iostream>
using namespace std;
int main() {
int number = 0;
do {
cout << " " << number<< endl;
number=number+2;}
while (number <= 10);
return 0;}