An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself),
is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function
isPerfect() that determines whether parameter number is a perfect number. Use this function in a
program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of
each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer
by testing numbers much larger than 1000.
An election is contested by five candidates. The candidates are numbered 1 to 5 and a voting is done by marking the candidate number in a ballot paper. Write a C++ program to read the ballot and count the votes cast for each candidate using an array variable count. In case, a number read is outside the range 1 to 5 the ballot should be considered as a 'spoilt ballot', and the program should also count the number of spoilt ballots
An election is contested by five candidates. The candidates are numbered 1 to 5 and a voting is done by marking the candidate number in a ballot paper. Write a C++ program to read the ballot and count the votes cast for each candidate using an array variable count. In case, a number read is outside the range 1 to 5 the ballot should be considered as a 'spoilt ballot', and the program should also count the number of spoilt ballots
Write a program that dynamically allocates an array large enough to hold a user-defined number of test
scores. Once all the scores are entered, the array should be passed to a function that sorts them in
ascending order. Another function should be called that calculates the average score. The program
should display the sorted list of scores and averages with appropriate headings. Use pointer notation
rather than array notation whenever possible.
Input Validation: Do not accept negative numbers for test scores.
Example
Enter the number of test scores: 4
Enter each test score:
Test#1: 34
Test #2: 73
Test #3: 22
Test #4: 89
Sorted test scores:
Test #1: 22
Test #2: 34
Test #3: 73
Test #4: 89
Average = 54.5
A 1D binary character array is given to you in file “task1.txt”. You are required to find out maximum
consecutive ones in the array.
Note: Read the file and find the exact length of data in a separate function. Use that size to create a
dynamic integer array using pointers. Then, read the file again and insert data into this dynamic array of
exact calculated size. Then You are required to find out maximum consecutive ones in the array.
task1.txt
11010101111110110111010
Expected output:
- maximum consecutive ones are: 111111
- Starting index is: 7
- Length is: 6
10. Consider a two-dimensional array Marks[10][5] having its base address as 2000 and the
number of
bytes per element of the array is 2. Now, compute the address of the element, Marks[8][5],
assuming that the elements are stored in row major order.
Take a real-world scenario of inheritance and implement it in C++ program. Your program should consist of the following:
1. Use Constructors and appropriate access modifier 2. List and draw Base class and Derived class 3. Show polymorphism (function overriding and function overloading) 4. Multiple inheritance 5. Put the user’s data into a file and display a data from a file to the user.
6. Implement Abstract class and interface
Write a C++ program that calculates the nth power of numbers from 1 to k. where n
and k will be input by user.
Expected Output:
Input Power value , n: 3
Input k : 5
3rd power of 1 is 1
3rd power of 2 is 8
3rd power of 3 is 27
3rd power of 4 is 64
3rd power of 5 is 125
NESTED LOOP PROBLEM:)
Design an interactive input loop that scans pairs of integers until it reaches a pair in
which the first integer evenly divides the second. Produce the output in the same format
given below.
Expected Output:
Input number pair 1: 4 7
Input number pair 2: 3 16
Input number pair 3: 14 7
Input number pair 4: 10 100
Your desired number pair is (10,100)
Nested Loop problem:-
Write a C++ program to find first positive even number input. Also tell in how many attempts user input positive even number using do while loop.