Q.10 What will be the output of the
following program: a=50 b= 500 print (al/b)
Answers
Answer:
Explanation:
Output of C++ programs | Set 50
Difficulty Level : Easy
Last Updated : 25 Jan, 2019
Predict the output of the following C++ programs:
Question 1:
filter_none
edit
play_arrow
brightness_4
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int ran = rand();
cout << ran << endl;
return 0;
}
Output:
1804289383
Explanation: As the declared number is an integer, It will produce the random number from 0 to RAND_MAX. The value of RAND_MAX is library-dependent but is guaranteed to be at least 32767 on any standard library implementation.
Question 2:
filter_none
edit
play_arrow
brightness_4
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
cout << RAND_MAX << endl;
return 0;
}
Output:
2147483647
Explanation: The output is Compiler Dependent. RAND_MAX is a function used by the compiler to create a maximum random number.
Question 3:
filter_none
edit
play_arrow
brightness_4
#include <iostream>
using namespace std;
int main()
{
void a = 10, b = 10;
int c;
c = a + b;
cout << c;
return 0;
}
Output:
Compile time error
Explanation: void will not accept any values to its type.
Question 4:
filter_none
edit
play_arrow
brightness_4
#include <iostream>
using namespace std;
int array1[] = { 1200, 200, 2300, 1230, 1543 };
int array2[] = { 12, 14, 16, 18, 20 };
int temp, result = 0;
int main()
{
for (temp = 0; temp < 5; temp++) {
result += array1[temp];
}
for (temp = 0; temp < 5; temp++) {
result += array2[temp];
}
cout << result;
return 0;
}
Output:
please mark as brainest answer