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

Assignment-03 1-1

The document outlines an assignment for the Introduction to Computing and AI course at Ghulam Ishaq Khan Institute, detailing submission guidelines and five programming questions worth a total of 50 marks. Students are instructed to submit both a PDF file and a hard copy of their work by the deadline of November 21, 2024. Each question involves writing functions or programs in C++ related to prime numbers, time display, distance calculation, a guessing game, and Fibonacci series computation.

Uploaded by

sohailkarim74
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Assignment-03 1-1

The document outlines an assignment for the Introduction to Computing and AI course at Ghulam Ishaq Khan Institute, detailing submission guidelines and five programming questions worth a total of 50 marks. Students are instructed to submit both a PDF file and a hard copy of their work by the deadline of November 21, 2024. Each question involves writing functions or programs in C++ related to prime numbers, time display, distance calculation, a guessing game, and Fibonacci series computation.

Uploaded by

sohailkarim74
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ghulam Ishaq Khan Institute (GIKI)

Assignment # 3
Subject: Introduction to Computing and AI Course Code: CS - 101 - I, F - 24
Class: BS DS– 1st Submission Deadline: 21/Nov/2024 - Thu (9:00 - AM)
Course Instructor: Ms. Nazia Shahzadi - Lecturer - Total Marks: 50 (Marks are divided problem-wise)
FCSE
Course TA’s: Ms. Sabahat Gul

Note (Read notes & instructions first) .

First, read the instructions and statements of each exercise/question carefully then write the solution.
• For Handwritten/Printed Form:
o In case of multiple questions, give the heading of each question’s number or the task you are going to
solve
o Mention the page number and your roll number at the corner of each page.
o Then select all pictures in the Cam scanner application and convert them into a PDF file.
o The name of your pdf file should contain your assignment number and your roll number as shown in the
following example, For Example, if your roll number is 2024532 and you have done assignment number 2
then the name of the file should be as → 2024532_2.pdf
o Then upload that pdf file to Microsoft Teams. Remember the sequence of pages should be right.
o Also submit the same original pages/hardcopy (in printed form) in Thursday’s class (21/11/2024).

CHEATING/COPY CASE or LATE SUBMISSION even 1 minute late will be resulted into MARKS
DEDUCTION .So be on time make no excuse.

Based on CLO3 of PLO1 Total Marks:50

Question#1 Points-10
An integer is said to be prime if it’s divisible by only 1 and itself. For example,
2, 3, 5, and 7 are prime, but 4, 6, 8, and 9 are not.
• Write a function that determines whether a number is a prime.
• Use this function in a program that identifies and prints all the prime numbers between 2
and 10,000. How many of these numbers do you really have to test before being sure that
you’ve found all the primes?

Page 1 of 3
Question#2 Points-10

Implement a clock by writing a C++ program that asks the user to enter an hour value and a minute
value. The main () function should then pass these two values to a type void function that displays
the two values in the format shown in the following sample run:
Enter the number of hours: 9
Enter the number of minutes: 28
Time: 9:28

Question#3 Points-10

Write a function that computes the distance between two points (x1, y1) and (x2, y2). All numbers
and return values should be of type double.

Question#4 Points-10

Write a program that plays the game of “guess the number” as follows:
Your program chooses the number to be guessed by selecting an integer at random in the range 1
to 1000. The program then types:

• I have a number between 1 and 1000.


• Can you guess my number?
• Please type your first guess.
• The player then types a first guess.

The program responds with one of the following:

• Excellent! You guessed the number!


• Would you like to play again (y or n)?
• Too low. Try again.
• Too high. Try again.

If the player's guess is incorrect, your program should loop until the player finally gets the number
right. Your program should keep telling the player Too high or too low to help the player “zero
in” on the correct answer.

Question#5 Points-10

The Fibonacci series


0, 1, 1, 2, 3, 5, 8, 13, 21, …
begins with the terms 0 and 1 and has the property that each succeeding term is the sum of
the two preceding terms.

Page 2 of 3
a) Write a function Fibonacci (n) that calculates the nth Fibonacci number.
b) Modify the program of part a) to use double instead of int to calculate and return Fibonacci
numbers and use this modified program to repeat part b).

Page 3 of 3

You might also like