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

  1. If array elements are 2, 4, 6, 8, 10. Then output should be 2, 6, 10.
  2. If array elements are 1, 2, 3, 4, 6. Then output should be 2, 6.
  3. If array elements are 8, 7, 4, 1, 10. Then output should be 8, 10.

INSTRUCTIONS THAT SHOULD BE FOLLOWED

  1. Define a function / procedure print_alternate() to print alternate even numbers;
  2. 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.

  1. Your program should be GENERIC and should not be CASE SPECIFIC
  2. Write specific functions with meaning full identifiers for different input, output and analysis operation
  3. 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:

  1. 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.
  2. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!