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

Assignment II

a computer programming assignment
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment II

a computer programming assignment
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Fundamentals of Computer Programming Assignment-II (10%)

Instruction: Write a C++ code for the following questions, show each steps clearly and include the
output screenshot while submitting. Submission deadline: - July 20, 2024.
1. Find Largest Number from N numbers entered by the user.
(hint :- if user enter 7,17,9,23,65 and 1, the output will be 65).
2. To find the Fibonacci series till term≤100.
(hint:- F0 = 0 (applies only to the first integer) F1 = 1 (applies only to the second integer) Fn =
Fn-1 + Fn-2 (applies to all other integers))
3. Find Sum of Series 1 + 1/2 + 1/3 + ... + 1/N where N is a natural number entered by user.
4. Receive three (3) numbers from the user and display them in ascending order.
5. Write a program that swaps the values of two variables without using a third (usually called
temp) variable.

6. Write a program that accepts a number and checks if it is Armstrong number or not.
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is
equal to the number itself. For example, 371 is an Armstrong number since 33 + 73 + 13 = 371.
Sample input: 371 output: Armstrong number , Sample input: 101 output: Not
Armstrong number
7. Write a program that implements the C++ builtin function strcmp. The function should accept two
strings and then compare them and return the result 0 if they are equal or negative number if the
first is less than the second or positive number if the first is larger than the second.
sample input: abc, abc output: 0 (equal)
sample input: abc, xy output: -23 (the difference between the letters a and x)
sample input: mnp, lm output: 1 (the difference between the letters l and m)
8. The largest integer which can perfectly divide two integers is known as GCD (Greatest Common
Divisor) of those two numbers. Write a program that accepts two numbers from user and then
display their GCF.
Sample input: 10, 15 output: 5 Sample input: 45, 30 output: 15
9. You are given an array with integers between 1 and 1000. Some of the numbers are repeated
multiple times in the array. Count its occurence in the array and display it.
int num[] = {2, 3, 5, 4, 1, 20, 3, 4, 5, 4, 6, 7, 8};
Output: 2 – 1, 3 – 2, 5 – 2, 4 – 3, 1–1, 20 – 1, 6 – 1, 7 – 1, 8 – 1
10. Write a program that accepts a number in decimal and convert into binary. The decimal number
accepted could have a fraction. After converting to binary, display the result.
Sample input: 100.25 output: 110 0100.01
11. Displays a Butterfly Pattern which looks like the following diagram.

You might also like