Question
programming language must be C++ Q.No.1: Consider a List of integers (implemented using array) of size N. The list may have both even and odd
programming language must be C++
Q.No.1:
Consider a List of integers (implemented using array) of size N. The list may have both even and odd numbers at any position entered by user at run time.
Write a PROGRAM that finds and print ALTERNATE EVEN NUMBERS. (Marks 12)
FOR EXAMPLE
- If array elements are 2, 4, 6, 8, 10. Then output should be 2, 6, 10.
- If array elements are 1, 2, 3, 4, 6. Then output should be 2, 6.
- If array elements are 8, 7, 4, 1, 10. Then output should be 8, 10.
INSTRUCTIONS THAT SHOULD BE FOLLOWED
- Define a function / procedure print_alternate() to print alternate even numbers;
- The print_alternate() function should print, RULE CANNOT BE APPLIED, if the list have total even numbers less than 3.
FOR EXAMPLE
- If array elements are 1, 4, 6, 3, 9.
- If array elements are 1, 2, 3, 4, 5.
- If array elements are 1, 3, 5, 7, 9.
- If array elements are 2, 4, 1, 3, 9 and so on
In all similar cases, the function should print RULE CANNOT BE APPLIED.
- Your program should be GENERIC and should not be CASE SPECIFIC
- Write specific functions with meaning full identifiers for different input, output and analysis operation
- Your program should handle all the error conditions like Boundary checking and Invalid input etc.
B) Consider a circular linklist (implemented using singly linklist) of integers with 20 nodes. Define a function fun_ques2(int n) that find the square of value stored in nth node only and print its address. (Marks 12)
INSTRUCTIONS:
- The function must check whether the value of n is valid (1 to 20). If n value is invalid, print an error message and return without doing anything.
- The function should handle all the error conditions
Please follow the instruction of the questions and solve both parts as this is single question. Leaving one part will lead to unhelpful rating
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started