SlideShare a Scribd company logo
ASSIGNMENT OF PROGRAMMING
FUNDAMENTS
TOPIC;
PF LAB PROGRAMS
SUBMITTED BY;
MOHAMMAD MINQAD TAHIR
ROLL NO;
08
SEMESTER;
1ST
SUBMITTED TO;
MAM HIRA NAZIR
DEPARTMENT;
COMPUTER SCIENCE (B)
ISLAMIA UNIVERSITY BHAWALPUR
(A): 1. Write a program that inputs a number
from the user and display the factorial of
that number using while loop.?
Solution:
#include<iostream>
using namespace std;
int main()
{ int
n,f=1,i=1;
cout<<"n Enter The positive integer:";
cin>>n;
//LOOP TO CALCULATE THE FACTORIAL
OF
A NUMBER
while(i<=n)
{
f=f*i;
i++;
}
cout<<"n The Factorial of "<<n<<" is
"<<f; return 0; }
OUTPUT:
(B):2. Write a program that display the
Fibonacci series.? Solution:
#include <iostream>
using namespace std;
int main()
{ int n, t1 = 0, t2 = 1, nextTerm
= 0;
cout << "Enter the number of terms: ";
cin >> n;
cout << "Fibonacci Series: ";
for (int i = 1; i <= n; ++i)
{
// Prints the first two terms.
if(i == 1)
{ cout <<
" " << t1;
continue;
} if(i == 2)
{ cout << t2 <<
" "; continue;
}
nextTerm = t1 +
t2; t1 = t2; t2
= nextTerm;
cout << nextTerm << " ";
}
return 0;
}
OUTPUT:
PF LAB ASSIGNMENT
Ad

Recommended

C programming Lab 1
C programming Lab 1
Zaibi Gondal
 
Functions & Procedures [7]
Functions & Procedures [7]
ecko_disasterz
 
Lab 1
Lab 1
emailharmeet
 
Write a complete C++ program that does the following: 1. The program will c...
Write a complete C++ program that does the following: 1. The program will c...
licservernoida
 
Programming fundamentals
Programming fundamentals
Zaibi Gondal
 
C programming session 03
C programming session 03
Dushmanta Nath
 
3. user input and some basic problem
3. user input and some basic problem
Alamgir Hossain
 
2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
test(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
c++ Question
c++ Question
Hamza4467
 
C programming Lab 2
C programming Lab 2
Zaibi Gondal
 
C programming session 04
C programming session 04
Vivek Singh
 
Code quailty metrics demystified
Code quailty metrics demystified
Jeroen Resoort
 
Practical no 1
Practical no 1
Kshitija Dalvi
 
Ankita sharma focp
Ankita sharma focp
AnkitaSharma463389
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
alish sha
 
Concept of c
Concept of c
Rohan Gajre
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
Functions in c++
Functions in c++
Padma Kannan
 
Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 
Operators
Operators
Allah Ditta
 
Practical no 6
Practical no 6
Kshitija Dalvi
 
Ffffffffffff
Ffffffffffff
mohdshanu
 
Pa1 loops
Pa1 loops
aiclub_slides
 
Globalandlocal
Globalandlocal
Jam Catipon
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
C programming session 04
C programming session 04
AjayBahoriya
 
C program to add two numbers
C program to add two numbers
mohdshanu
 
Subject:Programming in C - Lab Programmes
Subject:Programming in C - Lab Programmes
vasukir11
 
Muzzammilrashid
Muzzammilrashid
muzzammilrashid
 

More Related Content

What's hot (20)

test(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
c++ Question
c++ Question
Hamza4467
 
C programming Lab 2
C programming Lab 2
Zaibi Gondal
 
C programming session 04
C programming session 04
Vivek Singh
 
Code quailty metrics demystified
Code quailty metrics demystified
Jeroen Resoort
 
Practical no 1
Practical no 1
Kshitija Dalvi
 
Ankita sharma focp
Ankita sharma focp
AnkitaSharma463389
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
alish sha
 
Concept of c
Concept of c
Rohan Gajre
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
Functions in c++
Functions in c++
Padma Kannan
 
Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 
Operators
Operators
Allah Ditta
 
Practical no 6
Practical no 6
Kshitija Dalvi
 
Ffffffffffff
Ffffffffffff
mohdshanu
 
Pa1 loops
Pa1 loops
aiclub_slides
 
Globalandlocal
Globalandlocal
Jam Catipon
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
C programming session 04
C programming session 04
AjayBahoriya
 
C program to add two numbers
C program to add two numbers
mohdshanu
 
test(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
c++ Question
c++ Question
Hamza4467
 
C programming Lab 2
C programming Lab 2
Zaibi Gondal
 
C programming session 04
C programming session 04
Vivek Singh
 
Code quailty metrics demystified
Code quailty metrics demystified
Jeroen Resoort
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
alish sha
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 
Ffffffffffff
Ffffffffffff
mohdshanu
 
Seminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 
C programming session 04
C programming session 04
AjayBahoriya
 
C program to add two numbers
C program to add two numbers
mohdshanu
 

Similar to PF LAB ASSIGNMENT (20)

Subject:Programming in C - Lab Programmes
Subject:Programming in C - Lab Programmes
vasukir11
 
Muzzammilrashid
Muzzammilrashid
muzzammilrashid
 
Lab 2
Lab 2
Yiian Yeh Kho
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
ayush616992
 
Labsheet1 stud
Labsheet1 stud
rohassanie
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 
Computer P-Lab-Manual acc to syllabus.pdf
Computer P-Lab-Manual acc to syllabus.pdf
sujathachoudaryn29
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
 
Assignment no 5
Assignment no 5
nancydrews
 
C#.net
C#.net
vnboghani
 
Python Programming-I Journal labs manual
Python Programming-I Journal labs manual
AlameluIyer3
 
B.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
Labsheet_3
Labsheet_3
rohassanie
 
Practical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program question
vidhimangal05
 
Programming Fundamentals Functions in C and types
Programming Fundamentals Functions in C and types
imtiazalijoono
 
Labsheet 5
Labsheet 5
rohassanie
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
wkyra78
 
OOPS using C++
OOPS using C++
CHANDERPRABHU JAIN COLLEGE OF HIGHER STUDIES & SCHOOL OF LAW
 
lecture 10 Recursive Function and Macros.ppt
lecture 10 Recursive Function and Macros.ppt
Abhishekkumarsingh630054
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
SAKSHIGAWADE2
 
Subject:Programming in C - Lab Programmes
Subject:Programming in C - Lab Programmes
vasukir11
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
ayush616992
 
Labsheet1 stud
Labsheet1 stud
rohassanie
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 
Computer P-Lab-Manual acc to syllabus.pdf
Computer P-Lab-Manual acc to syllabus.pdf
sujathachoudaryn29
 
Assignment no 5
Assignment no 5
nancydrews
 
Python Programming-I Journal labs manual
Python Programming-I Journal labs manual
AlameluIyer3
 
B.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
Practical File of c++.docx lab manual program question
Practical File of c++.docx lab manual program question
vidhimangal05
 
Programming Fundamentals Functions in C and types
Programming Fundamentals Functions in C and types
imtiazalijoono
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
wkyra78
 
lecture 10 Recursive Function and Macros.ppt
lecture 10 Recursive Function and Macros.ppt
Abhishekkumarsingh630054
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
SAKSHIGAWADE2
 
Ad

Recently uploaded (20)

NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Ad

PF LAB ASSIGNMENT

  • 1. ASSIGNMENT OF PROGRAMMING FUNDAMENTS TOPIC; PF LAB PROGRAMS SUBMITTED BY; MOHAMMAD MINQAD TAHIR ROLL NO; 08 SEMESTER; 1ST SUBMITTED TO; MAM HIRA NAZIR DEPARTMENT; COMPUTER SCIENCE (B) ISLAMIA UNIVERSITY BHAWALPUR
  • 2. (A): 1. Write a program that inputs a number from the user and display the factorial of that number using while loop.? Solution: #include<iostream> using namespace std; int main() { int n,f=1,i=1; cout<<"n Enter The positive integer:"; cin>>n; //LOOP TO CALCULATE THE FACTORIAL OF A NUMBER while(i<=n)
  • 3. { f=f*i; i++; } cout<<"n The Factorial of "<<n<<" is "<<f; return 0; } OUTPUT: (B):2. Write a program that display the Fibonacci series.? Solution:
  • 4. #include <iostream> using namespace std; int main() { int n, t1 = 0, t2 = 1, nextTerm = 0; cout << "Enter the number of terms: "; cin >> n; cout << "Fibonacci Series: "; for (int i = 1; i <= n; ++i) { // Prints the first two terms. if(i == 1)
  • 5. { cout << " " << t1; continue; } if(i == 2) { cout << t2 << " "; continue; } nextTerm = t1 + t2; t1 = t2; t2 = nextTerm; cout << nextTerm << " "; } return 0; } OUTPUT: