0% found this document useful (0 votes)
49 views8 pages

CP Lab 08

This document outlines 3 programming tasks completed as part of a computer programming lab, including writing code to generate the Fibonacci series using a while loop, repeatedly printing a decreasing variable until it becomes negative, and calculating and printing the square roots of the first 25 odd positive integers. The document provides the code and output for each task completed as part of Lab Experiment 07.

Uploaded by

Talha Khan
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)
49 views8 pages

CP Lab 08

This document outlines 3 programming tasks completed as part of a computer programming lab, including writing code to generate the Fibonacci series using a while loop, repeatedly printing a decreasing variable until it becomes negative, and calculating and printing the square roots of the first 25 odd positive integers. The document provides the code and output for each task completed as part of Lab Experiment 07.

Uploaded by

Talha Khan
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/ 8

Lab No.

7 COMPUTER PROGRAMMING LAB

Bahria University,
Karachi Campus

COURSE: CSC-113 COMPUTER PROGRAMMING


TERM: FALL 2019, CLASS: BSE- 1 (A)

Submitted By:

_______________________________________________
(Name)Muhammad Attique (Reg. No.) 02-131212-034
Submitted To:

Engr.Muhammad Faisal/ Engr. Ramsha Mashood


Lab No.7 COMPUTER PROGRAMMING LAB

Signed Remarks: Score:

INDEX
SNO DAT LAB LAB OBJECTIVE SIGN
E NO
13TH 08 WHILE LOOPS
01 NOV
2020
Lab No.7 COMPUTER PROGRAMMING LAB

SNO DAT LAB LAB OBJECTIVE SIGN


E NO
Lab No.7 COMPUTER PROGRAMMING LAB

Bahria University,
Karachi Campus

LAB EXPERIMENT NO.


__07_
LIST OF TASKS
TASK NO OBJECTIVE
01 FIBONACCI SERIES(0,1,1,2,3,5,8…..) WHILE LOOP
02 REPEATEDLY PRINT THE VALUE OF THE VARIABLE XVALUE, DECREASING IT BY
0.5
EACH TIME,AS XVALUE REMAIN POSITIVE.
03 PRINT THE SQ.ROOTS OF FIRST 25 ODD POSITVE INTEGERS

Submitted On:
_02/12/2021_
(Date: DD/MM/YY)
Lab No.7 COMPUTER PROGRAMMING LAB

Task No. 1: FIBONACCI SERIES(0,1,1,2,3,5,8…..) WHILE LOOP

CODE:
int previous1 = 0;

int current = 1;

int next;

int n1 = 10;

Console.WriteLine("0,1,");

while (n1 > 0)

next = previous1 + current;

previous1 = current;

current = next;

n1--;

Console.Write("{0} , ", next);

Console.WriteLine();

Output:
Lab No.7 COMPUTER PROGRAMMING LAB

Task No. 2: REPEATEDLY PRINT THE VALUE OF THE VARIABLE XVALUE, DECREASING IT BY 0.5
EACH TIME,AS XVALUE REMAIN POSITIVE.

CODE:
double x;

double y = 0.5;

x = Convert.ToDouble(Console.ReadLine());

while (x >= 0)

Console.WriteLine(x);

x = x - y;

Output:
Lab No.7 COMPUTER PROGRAMMING LAB

Task No. 3:PRINT THE SQ.ROOTS OF FIRST 25 ODD POSITVE INTEGERS

CODE:
double x = 1;

double result;

Console.WriteLine("ENTER FIRST TWENTY FIVE ODD INTEGER NUMBERS");

while (x < 50)

result = Math.Sqrt(x);

Console.WriteLine(x + "=" + result);

x = x + 2;

Output:
Lab No.7 COMPUTER PROGRAMMING LAB

You might also like