0% found this document useful (0 votes)
25 views

Worksheet 2.1

This document contains details of a student's programming assignment to generate the Fibonacci series up to a user-specified limit. It includes the aim, algorithm, flowchart and code for a C++ program that writes out the Fibonacci series and also lists any missing numbers in the series. The student provides explanations of their code and learning outcomes from completing the assignment.

Uploaded by

pooja malhan
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)
25 views

Worksheet 2.1

This document contains details of a student's programming assignment to generate the Fibonacci series up to a user-specified limit. It includes the aim, algorithm, flowchart and code for a C++ program that writes out the Fibonacci series and also lists any missing numbers in the series. The student provides explanations of their code and learning outcomes from completing the assignment.

Uploaded by

pooja malhan
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/ 14

1

EXPERIMENT NUMBER - 1

STUDENT’S NAME – ABHISHEK MALHAN


STUDENT’S UID – 21BAS1056
CLASS AND GROUP – 21 BAS-301-A
SEMESTER - 2

PRACTICAL – 1.1.1

AIM OF THE EXPERIMENT – To find the average marks of a student of 5 subjects in a class.

ALGORITHM:- 1. Start.
2. Ask the user to enter the marks of the student.
3. Find the sum of the marks and then divide by 5 to find the average.
4. Print the result.
5. Stop.

FLOWCHART -

START

Ask the user


to enter the
marks of the
student.

Find the sum of the marks


and then divide by 5 to find
the average.

Print the
following STOP
results .

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


2

PROGRAM CODE:-

#include<iostream>
using namespace std;
int main()
{
int s1, s2, s3, s4, s5;
float avg,total;
cout<<"Enter marks of student :- ";
cin>>s1>>s2>>s3>>s4>>s5;
total= s1+s2+s3+s4+s5;
cout<<"Total marks of student :- "<<total<<endl;
avg=total/5;
cout<<"Average marks of student :- "<<avg;
return 0;
}

ERRORS OCCURRED – No error occurred.

PROGRAM’S EXPLANATION (in brief) - This program is a simple C++ language program used to
explain, How we can find the average marks of the student. It intends to make calculations faster
and easier for all individuals.

Following steps must be followed to make the program work:

1] Begin by opening a header file.

2] Write the main ( ) function, which is a must-have function.


SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101
3

3] Provide the conditions and find the solution to the problem.

4] To retrieve the output from the arithmetic method, select the print option.

OUTPUT:-

LEARNING OUTCOMES:–

 This practical introduced me to the fundamentals of the C++ programming language.

 Understanding the ways of execution and debugging the programs in C++ language.

 It provides a better outlook of course.

 Helps to build and compile a simple C++ language program to find the average marks of the
student.

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

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


4

PRACTICAL – 1.1.2

AIM OF THE EXPERIMENT – To swap the first and last digit of a number.

ALGORITHM – 1. Start.
2. Take the number from the user.
3. Find the first and last digit of the number provided.
4. Now, swap the first and last digit.
5. Print the new number.
6. Stop.

FLOWCHART -
START

Take the
number
from the
user.

Find the first and


last digit of the
number provided.

Now, swap the first


and last digit.

Print the
results.

STOP

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


5

PROGRAM CODE:–

// WAP to swap first and last digit of a number.


#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int a, b, n, first, last, sum, digit, final;
cout<<"\n Enter any number :- ";
cin>>n;
digit= (int)log10(n);
first= n/pow(10,digit);
last= n%10;
a= first*(pow(10, digit));
b= n%a;
n= b/10;
final= last*(pow(10,digit))+(n*10 + first);
cout<< "\n Number after swapping first and last digit :- "<<final;
return 0;
}

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


6

ERROR OCCURRED – No error occurred

PROGRAM’S EXPLANATION (in brief) - This program is a simple C++ language program, used
for swapping the first and last digit of a number. It intends to make calculations faster and easier for
all individuals.

Following steps must be followed to make the program work:

1] Begin by opening a header file.

2] Write the main ( ) function, which is a must-have function.

3] Take the number and write down the program’s input as well. As well as the variables.

4] To retrieve the output from the arithmetic method, select the print option.

RESULT –

LEARNING OUTCOMES –

 This practical introduced me to the fundamentals of the C++ programming language.

 Understanding the ways of execution and debugging the programs in C++ language.

 It provides a better outlook of course.

 Helps to build and compile a simple C++ language program to swap the first and last digit of a
number provided by the user.

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


7

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

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


8

PRACTICAL – 2.1.3

AIM OF THE PRACTICAL:- Write a program to generate the Fibonacci series up to the
user’s specified limit. Write all the missing terms (e.g. 4, 6, 7, 9, 10, 11, 12, 14, 15…)
also at the end.

ALGORITHM:- 1. Start.
2. Ask the user to enter the limit to generate the Fibonacci series.
3. Write the Fibonacci series between the limits.
4. Find the numbers that are missing from the series.
5. Print the result.
6. Stop.

FLOWCHART:-
START

Ask the
user to
enter the Find the numbers that
limit to are missing from the
generate series.

Write the Fibonacci


series between the
limits.

Print the
results.

STOP

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


9

PROGRAM’S CODE:-
//Write a program to print a series of arm-strong numbers from m to n.
m, n will be inputted by the user.
#include<stdio.h>
int main()
{
int i, j, cur, lastDigit, m, n;
long fact, sum;
printf("\n Enter the lower limit = ");
scanf("%d", &m);
printf("\n Enter the upper limit = ");
scanf("%d", &n);
printf("\n Armstrong numbers between %d to %d are = ", m,n);
for(i=m; i<=n; i++)
{
cur = i;
sum = 0;
while(cur > 0)
{
fact = 1;
lastDigit = cur % 10;
for( j=1; j<=3; j++)
{
fact = fact * lastDigit;
}
sum += fact;
cur /= 10;
}
if(sum == i)
{
printf("\n %d", i);
}
}
return 0;
}

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


10

ERROR OCCURRED:- No error occurred.

PROGRAM’S EXPLANATION (in brief) - This program is a simple C language program, used to
find arm-strong numbers between the limits set by the user.

Following steps must be followed to make the program work:

1] Begin by opening a header file.

2] Write the main ( ) function, which is a must-have function.

3] Take the limits and write down the program’s input as well. As well as the variables.

4] To retrieve the output from the arithmetic method, select the print option.

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


11

RESULT:-

LEARNING OUTCOMES:–

 This practical introduced me to the fundamentals of the C programming language.

 Understanding the ways of execution and debugging the programs in C language.

 It provides a better outlook of course.

 Helps to build and compile a simple C language program to find arm strong numbers
between the two limits.

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

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


12

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


13

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101


14

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-21CSH101

You might also like