Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions