Q.1
Take as input a natural number, say n. Output all subsets of {1,2,...,n}.
You cannot use functions or recursion.
Q.2
Write a program to read a sequence of non-zero integers till the number zero is entered and at the end display the following:
a) the number of even and odd numbers,
b) sum of all the numbers entered,
c) the length and starting index (or position) of a largest subsequence of consecutive non-decreasing integers entered. Assume that the index of the numbers start from 1.
For example, if the user input is 1 -2 3 17 9 5 -10 -12 0, then the output will be:
No. of even numbers: 3
No. of odd numbers: 5
Sum of the numbers: 11
Length of largest non-decreasing subsequence: 3
Starting index: 2
Note: Do not use arrays.
#ComputerScience
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Answer 2.
I have increased the scope of your problems from C to all other languages by editing "C" out of the discussion.
Hint about 2: How do functions work? What is the underlying data structure that keeps track of where the execution should return to?
Thanks @Agnishom Chattopadhyay Can u post a solution to Question no 1.
Log in to reply
Try answering the hint
Log in to reply
i need to submit my assignment now please post the answer Bro.
i got it @Agnishom Chattopadhyay
Log in to reply
Nice!
Log in to reply
Thanks