You are on page 1of 5

"University Of Sindh Jamshoro"

Name: "Sania Shahid Khan"


Father/Name: "Shahid Khan"
Department: "Information Technology(IT)"
Roll/No: "2k20/IT/105"
Subject: "Programming Fundamentals"
Assign To: "Mam Nazish Basir "

"WEEK#05"

"EXCERCISE: 1"

Write a program that prints the values by using For Loop

"PROGRAM":

#include<iostream>

using namespace std;

int main () {

for (int k=10 ; k<=1000000000 ; k=k*10)

cout << k << " " ;

return 0;

"OUTPUT":

10 100 1000 10000 100000 1000000 10000000 100000000

1000000000

"EXCERCISE:2"

Write a program that uses any loop to computes the nth


fibonacci number where n is a value input by the user
"PROGRAM"

#include<iostream>

using namespace std;

int main () {

int n;

cin>>n;

int first=0, second=1, third;

for (int i=0; i<=n; i++)

if(i==0)

cout<<first<<" "<<second<<" ";

else

third=first+second;

first=second;

second=third;

cout<<third<<" ";

"OUTPUT"

Enter No 10

Fibonacci series till 10th place:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34
"EXCERCISE:3"
Write a program by using any loop to find the sum of the first N
natural numbers,where the value of N is provided by the user

"PROGRAM"

#include<iostream>

using namespace std;

int main () {

int N, i, sum=0;

cout<<"enter N"<<endl;

cin>>N;

for(int i=1; i<=7; i++)

sum=sum+i;

if(i<7)

cout<<i<<" + ";

else

cout<<i;

cout<<" = "<<sum;

return 0;

"OUTPUT"
Enter N: 7

1+2+3+4+5+6+7=28

"EXCERCISE:4"

Write a program which take 3 numbers from users

1. Table number

2. Starting values of table

3. ending values of table

"PROGRAM"

#include<iostream>

using namespace std;

int main () {

int num, start, end;

cout << "Enter Table Number"<<endl;

cin >> num;

cout << "Enter Starting Value"<<endl;

cin >> start;

cout << "Enter Ending Value"<<endl;

cin >> end;

for(int k=start ; k<=end ; k++)

cout<<num<<" * "<<k<<" = "<< (k*num)<<endl;

return 0;

"OUTPUT"
Enter Table Numer 9

Enter Staring Value 4

Enter Ending Value 7

9 * 4 = 36

9 * 5 = 45

9 * 6 = 54

9 * 7 = 63

The end

You might also like