0% found this document useful (0 votes)
93 views12 pages

C++ Exp 1.1 Diya 1.A

1. The document contains details of a student's experiment in an Object Oriented Programming lab. It includes the student name, UID, branch, semester and date. 2. The experiment aims to write a program to find the average marks of five subjects for a student. It includes the flowchart and code to take marks as input and calculate the average. 3. The second experiment aims to write a program to swap the first and last digits of a number. It includes the flowchart, code and explanation. 4. The third experiment aims to write a program to generate the Fibonacci series up to a user-specified limit and print missing terms. It includes the flowchart, code, explanation and outputs

Uploaded by

Aswin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views12 pages

C++ Exp 1.1 Diya 1.A

1. The document contains details of a student's experiment in an Object Oriented Programming lab. It includes the student name, UID, branch, semester and date. 2. The experiment aims to write a program to find the average marks of five subjects for a student. It includes the flowchart and code to take marks as input and calculate the average. 3. The second experiment aims to write a program to swap the first and last digits of a number. It includes the flowchart, code and explanation. 4. The third experiment aims to write a program to generate the Fibonacci series up to a user-specified limit and print missing terms. It includes the flowchart, code, explanation and outputs

Uploaded by

Aswin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Student Name: DIYA SANGAR UID: 21BCS2632

Branch: Computer Science & Engineering


Section/Group:206 B
Semester: 2 Date of Performance:14/02/22
Subject Name: Object Oriented Programming using C++

Subject Code: 21CSH103

EXPERIMENT NUMBER – 1.1

Aim of the practical: WAP to find average marks of five subjects of a student
in a class.

FLOWCHART/ ALGORITHM

Step 1: Start

Step 2: Enter the name of Student.

Step 3: Enter the section of Student.

Step 2: Read the marks of 5 subjects from the user.

Step 3: Find the average using the formula avg = (a+b+c+d+e) / 5.

Step 4: Print the average marks of subject.

Step 5: Stop

PROGRAM CODE

#include<iostream>
using namespace std;

int main()
{
int mark[5], i;
float sum=0;
cout<<"\nEnter marks obtained in Physics, Chemistry, Maths, CS, English :: \n";
for(i=0; i<5; i++)
SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103
{
cout<<"\nEnter mark[ "<<i+1<<" ] :: ";
cin>>mark[i];
sum=sum+mark[i];
}

float avg=sum/5;
float perc;
perc=(sum/500)*100;
cout<<"\nAverage Marks of 5 Subjects = [ "<<avg<<" ] \n";
cout<<"\nPercentage in 5 Subjects = [ "<<perc<<"% ] \n";

return 0;
}

ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION


(Kindly jot down the compile time errors encountered)

1. Interchange of Insertion and Extraction operator.

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


PROGRAMS’ EXPLANATION (in brief)

First of all, we have to include the header file <bits/stdc++.h> to use the input(cin) and
output(cout) functions.
Further we have to enter a student’s name and section then we have to enter the marks of 5
subjects from the user using cin function and display their Average using the formula avg =
(a+b+c+d+e)/5.
So, after calculating the Average, we print the result on the output screen using cout
function.

OUTPUT

EXPERIMENT NUMBER – 1.2

Aim of the practical: Write a program to swap first and last digit of any
number

FLOWCHART/ ALGORITHM

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


1. Start the program.

2. Creating a header file for input output stream.

3. Declaration of function for mathematical operations.

4. Function that returns integer value.

5. Print the message and accept the input from the user.

6. Extraction of digits using mathematical operations.

7. Print the message and value after swapping.

8. End the program by returning an integer value.

PROGRAM CODE

#include<iostream>

#include<cmath>

using namespace std;

int main()

int number, firstDigit, lastDigit, count, SwapNum;

cout << "\nPlease Enter Any Number to find First and Last Digit = ";

cin >> number;

count = log10(number);

firstDigit = number / pow(10, count);

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


lastDigit = number % 10;

SwapNum = lastDigit;

SwapNum = SwapNum * (round(pow(10, count)));

SwapNum = SwapNum + number % (int)(round(pow(10, count)));

SwapNum = SwapNum - lastDigit;

SwapNum = SwapNum + firstDigit;

cout << "\nThe First Digit in a Given Number = " <<firstDigit;

cout << "\nThe Last Digit in a Given Number = " << lastDigit;

cout << "\nAfter Swapping First and Last Digit = " << SwapNum;

return 0;

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION
(Kindly jot down the compile time errors encountered)
NO ERRORS

PROGRAMS’ EXPLANATION (in brief)


In this program we have to accept the number from the user and swap the first and last
digit using extraction of digits by mathematical operation and print the message and number
after swapping.

OUTPUT

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


EXPERIMENT NUMBER – 1.3

Aim of the practical: WAP to generate the Fibonacci series up to user


specified limit. Write all the missing terms (e.g. 4, 6, 7, 9, 10, 11, 12, 14, 15…)
also at the end.

FLOWCHART/ ALGORITHM

1. Start the program.

2. Creating a header file for input output stream.

3. Define the context on which name s are defined.

4. Function that returns integer value.

5. Declaration of variables in integer datatype.

6. Print the message and accept the input from the user.

7. Loop is used to enter the terms of Fibonacci series.

8. Check the condition using if else statement and print the message according to it.

9. Print the message and loop is used to find the missing values of series and print it.

10. End the program by returning an integer value.

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


PROGRAM CODE

#include<iostream>
using namespace std;
int main()
{

int n,c,first=0,second=1,next;

int a[20],i,j=0,count=0;

cout<<"Enter the no. of terms of Fibonacci series=";

cin>>n;

cout<<"Terms of Fibonacci series are"<<endl;

for(c=0;c<n;c++)

if(c<=1)

next=c;

else

next=first+second;
first=second;

second=next;
}

cout<<next<<endl;
if(next-first>1)

{
for(i=first+1; i<next; i++)
{

a[j]=i;
count++;
j++;
}

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


cout<<"Missing numbers of the Fibonacci series are:"<<endl;

for(j=0; j<count; j++)


cout<<a[j]<<endl;
return 0;
}

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION
(Kindly jot down the compile time errors encountered)

NO ERRORS

PROGRAMS’ EXPLANATION (in brief)


In this program we have to print the Fibonacci series and the missing values of the series
too by taking the number of terms of the series from the user.

OUTPUT

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103
LEARNING OUTCOMES

• Understand the concepts of object-oriented programming including programming process


and compilation process.

• Apply different techniques to decompose a problem and programmed a solution with its
sub modules.

• Analyze and explain the behavior of simple programs involving the programming
addressed in the course.

• Implement and evaluate the programs using the syntax and semantics of object-oriented
programming.

• Design the solution of real-world problems in order to determine that the program
performs as expected.

EVALUATION COLUMN (To be filled by concerned faculty only)

Sr. No. Parameters Maximum Marks


Marks Obtained
1. Worksheet Completion including writing 10
learning objective/ Outcome
2. Post-Lab Quiz Result 5

3. Student engagement in Simulation/ 5


Performance/ Pre-Lab Questions
4. Total Marks 20

1.

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103

You might also like