0% found this document useful (0 votes)
126 views8 pages

CP Lab 1 Task 1-4

This document contains the code and instructions for 4 programming tasks from a Computer Programming Lab course. The first task involves prompting the user to input their name, age, grade, and GPA, and then displaying it. The second task prompts for a name and age. The third task prompts for a number and uses an if statement to check if it is equal to 1 and less than or equal to 0. The fourth task prompts for a number and uses an if statement to check if it is equal to 1, 2, or 3.

Uploaded by

Yahya Faisal
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)
126 views8 pages

CP Lab 1 Task 1-4

This document contains the code and instructions for 4 programming tasks from a Computer Programming Lab course. The first task involves prompting the user to input their name, age, grade, and GPA, and then displaying it. The second task prompts for a name and age. The third task prompts for a number and uses an if statement to check if it is equal to 1 and less than or equal to 0. The fourth task prompts for a number and uses an if statement to check if it is equal to 1, 2, or 3.

Uploaded by

Yahya Faisal
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/ 8

CSL-113: Computer Programming

Lab
Semester BS (CS) – 01

LAB 1 TASK 1

#include <iostream>
#include <string>
using namespace std;
int main ()
{
string name;
int age;
float CGPA;
char section = 'B', grade;
cout << "Enter your name:";
cin >> name;
cout << "Enter your age:";
cin >> age;
cout << "Enter your grade:";
cin >> grade;
cout << "Enter your CGPA:";
cin >> CGPA;
cout << endl;
cout << "Student Record" << endl;
cout << "Your section is:" << section << endl;
cout << "Your age is:" << age << endl;
cout << "Your name is:" << name << endl;
cout << "Your grade is:" << grade << endl;
cout << "Enter your CGPA:" << CGPA << endl;
system("pause");
return 0;
}

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

TASK 2

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

#include <iostream>
#include <string>
using namespace std;

int main ()
{
string name, age;

cout << "Enter your name:";


cin >> name;
cout << "Enter your age:";
cin >> age;

system("pause");
return 0;
}

TASK 3
#include <iostream>
using namespace std;
Department of Computer Sciences Semester BSCS1
CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

int main ()
{
int number;

cout << "Enter number:";


cin >> number;
if (number == 1 && number <= 0)
{
cout << "Accepted = " << number << endl;
}
else {
cout << "Not Accepted " << endl;
}
cout << "Program Ended " << endl;
system("pause");
return 0;
}

TASK 4
#include <iostream>
using namespace std;

int main ()
Department of Computer Sciences Semester BSCS1
CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

{
int a;
cout << "Enter number:";
cin >> a;

if (a == 1 || a == 2 || a == 3)
{
cout << "Accepted " << endl;
}
else {
cout << "Not Accepted " << endl;
}
system("pause");
return 0;
}

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal
CSL-113: Computer Programming
Lab
Semester BS (CS) – 01

Department of Computer Sciences Semester BSCS1


CSL-113: Computer Programming Lab Journal

You might also like