PF Lab 1 Manual
PF Lab 1 Manual
Instructions:
You must submit CPP files of the program in a folder, named your Registration
Number.
You must upload your lab tasks on CMS.
All program codes should be written in C/C++. Students should use Visual studio
compiler for coding.
Indent and comment your code.
Use meaningful variable names
Plan your code carefully on a piece of paper before you implement it.
Learning Objectives:
Demonstrate knowledge of basic arrays in programming C++. (Revision)
Blooms
CLO NO CLO STATEMENT Taxonomy PLO
Level
Lab 01
Topic ITC-Revision
Introduction & Review
o Program Execution Flow, Concept of TYPE, Identifier, Declaration,
Initialization, Expression, Assignment, Selection, Loop, Arrays
Objective Array
o Integer, Character, C-String
o Declaration, Initialization, one by one Input/Output.
______________________________________________________________________________
______________________________________________________________________________
TASK TO DO
Task 1:
Debug the code line by line and understand it’s working.
#include <iostream>
using namespace std;
int main()
{
int arr[] = {10, 20, 30, 40, 50};
int size = 5;
cout << "Array elements are:" << endl;
for (int i = 0; i < size; i++)
{
cout << "arr[" << i << "] = " << arr[i] << endl;
}
arr[2] = 100;
cout << " New Array is:" << endl;
for (int i = 0; i < size; i++)
{
cout << "arr[" << i << "] = " << arr[i] << endl;
}
return 0;
}
______________________________________________________________________________
Task 2:
Write a C++ program that reads an integer representing a student's grade (between 0 and 100)
and classifies it into one of the following categories:
The program should then output the letter grade (A, B, C, D, or F).
Sample Input:
Enter marks= 85
Sample Output:
Grade = B
Task 3:
Write a C++ program that prints all even numbers from 1 to a given number n.
Sample Input:
Enter a number = 10
Sample Output:
Even numbers are = 2 4 6 8 10
_____________________________________________________________________________
Task 4:
Write a C++ program that prints a right-angled triangle pattern of stars (*) with n rows. The
number of stars in each row is equal to the row number.
Sample Input :
Enter number of rows = 5
Sample Output :
*
**
***
****
*****
Task 5:
Write a C++ program that takes an integer input and checks whether the number is positive,
negative, or zero.
Sample Input:
Enter number= -5
Sample Output:
Number is negative
______________________________________________________________________________
Task 6:
Write a C++ program to print a diamond pattern using stars (*). The program should take the
number of rows as input (which should be odd to create a symmetric pattern).
Sample Input:
Enter the number of rows: 5
Sample Output:
*
**
***
**
*
Task 7:
Debug the given code line by line and understand it’s working.
#include <iostream>
using namespace std;
int main()
{
int n, m;
return 0;
}
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
End of LAB 1 😊