Computer Science, asked by pendemsrujan7, 9 months ago

An island called “Wonderland” is filled with treasures. Raj is trying to get the treasure. To get it, he has to reach the end of the snow land in the island but got puzzled in the mid-way by a hint he got there. The hint is stating that to cross the snow land he has to jump on the ice stones which is of pairs else he will be drowned in the cold river. He has to check whether the number of ice stones is in pairs or not. Suggest him a logic to check the pairs of stones and say whether he can get the treasure or not.

Answers

Answered by SyedWilayathKhadari
38

Answer:

You need to check whether the input is a pair or not.

Explanation:

#include<iostream>

int main()

{

 int num;

 std::cin>>num;

 (num%2==0)?std::cout<<"Possible":std::cout<<"Not possible";

}

Answered by shreta4567
0

Answer:

A pair is always divisible by '2' and leaves remainder as '0'(zero)

Explanation:

Using C program

#include <stdio.h>

int main()

{

int n;

printf("enter the no.of ice stones:\n ");  

scanf("%d", &n); //reading the input value of 'n'//

if (n%2==0) //checking the condition of pairs with remainder '0' when divided with '2'//

{

printf("Getting treasure is possible");

}

else

{

printf("Getting treasure is not possible");

}

}

#SPJ3

Similar questions