Computer Science, asked by krutikavalanj99, 9 months ago

For this problem, you have to write a program that reads integers from the standard input (until it gets a negative number) and puts them into an array. After that it finds the highest number in the array that is less than 100 and prints that to the standard output. It should return 0 if the array has no numbers less than 100. Note: your program must not print anything else to the standard output.

For example, if these numbers were provided on the standard input:

95
817
3
51
-1
When your program is run, it should output 95 (and nothing else).

Answers

Answered by manthansarkar1983
7

Answer:

It is simple stacking behaviour of compiler for single line short hand expressions.

Stacking here is happening as :

1) a

2) ++a

3) a++

Now value of a is 10, and for stacks its LIFO: hence order of output will be

3) a++ (value 10 printed, then incremented to 11)

2) ++a ( value incremented to 12, then printed 12)

1) a (value 12 printed)

Hence ordered output is:

1) 12

2) 12

3) 10

Answered by tofailahmad379
28

Answer:

#include<iostream>

using name's pace std;

int main()

{

int i, j, m, n;

n[i] =0;

m[j] =0;

for(int i=0;i>=0; i++)

{

cin>>n[i] ;

if(n[i] < 0)

break;

for (int j=0; j<i;j++)

{

if (n[i] <100)

m[j]=n[i] ;

if(n[i+1]>=m[j])

m[j+1]=n[i+1];

}

}

cout<<m[j+1];

return 0;

}

Similar questions