skillrack daily challenge, Lecture notes of C programming

coding question, it contains the question which was asked for one of the daily challenge

Typology: Lecture notes

2018/2019

Uploaded on 06/23/2019

tabraze-ali-meyan-m-a
tabraze-ali-meyan-m-a 🇮🇳

4.3

(6)

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
19/06/2019 skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC
skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC 1/2
LeaderBoard & Yesterday's Solution(/faces/candidate/leaderboarddailychallenge.xhtml?RT=DAILYCHALLENGE)
ProgramID- 8836 Solved By 0 Users
Reverse - Odd or Even
The program must accept N integers as the input. The program must print the output based on the following
conditions.
- If the number of even integers is greater than the number of odd integers then the program must print all
the even integers in the reverse order followed by all the odd integers in the given order.
- If the number of even integers is less than the number of odd integers then the program must print all the
odd integers in the reverse order followed by all the even integers in the given order.
- If the number of even integers is equal to the number of odd integers then the program must print all the
integers in the reverse order.
Boundary Condition(s):
1 <= N <= 100
-10^8 <= Each integer value <= 10^8
Input Format:
The rst line contains the value of N.
The second line contains N integers separated by space(s).
Output Format:
The rst line contains either N integers separated by a space or -1 based on the given conditions.
Example Input/Output 1:
Input:
7
21 14 11 13 29 24 15
Output:
15 29 13 11 21 14 24
Explanation:
The number of odd integers is 5.
The number of even integers is 2.
Here 5 is greater than 2, so all the odd integers are printed in reverse order followed by all the even integers
in the given order.
Hence the output is 15 29 13 11 21 14 24
Example Input/Output 2:
Input:
4
-12 45 78 -23
Output:
-23 78 45 -12
Daily Challenge SkillRack
Ambiance
pf2

Partial preview of the text

Download skillrack daily challenge and more Lecture notes C programming in PDF only on Docsity!

19/06/2019 skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC

skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC 1/

LeaderBoard & Yesterday's Solution(/faces/candidate/leaderboarddailychallenge.xhtml?RT=DAILYCHALLENGE)

ProgramID- 8836 Solved By 0 Users

Reverse - Odd or Even

The program must accept N integers as the input. The program must print the output based on the following conditions.

  • If the number of even integers is greater than the number of odd integers then the program must print all the even integers in the reverse order followed by all the odd integers in the given order.
  • If the number of even integers is less than the number of odd integers then the program must print all the odd integers in the reverse order followed by all the even integers in the given order.
  • If the number of even integers is equal to the number of odd integers then the program must print all the integers in the reverse order.

Boundary Condition(s): 1 <= N <= 100 -10^8 <= Each integer value <= 10^

Input Format: The rst line contains the value of N. The second line contains N integers separated by space(s).

Output Format: The rst line contains either N integers separated by a space or -1 based on the given conditions.

Example Input/Output 1: Input: 7 21 14 11 13 29 24 15

Output: 15 29 13 11 21 14 24

Explanation: The number of odd integers is 5. The number of even integers is 2. Here 5 is greater than 2, so all the odd integers are printed in reverse order followed by all the even integers in the given order. Hence the output is 15 29 13 11 21 14 24

Example Input/Output 2: Input: 4 -12 45 78 -

Output: -23 78 45 -

Daily Challenge SkillRack

Ambiance

19/06/2019 skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC

skillrack.com/faces/candidate/dailychallenge.xhtml?k=DC 2/

C ( gcc 8.x) 

Save Run

#include<stdio.h>

#include <stdlib.h>

int main()