just provide right option. thanks
5) Consider the following C++ code snippet and what is the ousput of this progan #include using nanespace stdi int main(0 int arraytl-t5, 7. 10, 9) int p (array1) cout
Expert Answer
Answer:
5)Correct Answer is Option d i.e error
Explanation:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int array[]={5,7,10,9};
int **p=(array +1);
cout<<**array+10;
system(“pause”);
return 0;
}
Output :
If we execute the program above we get the below error
error: cannot convert ‘int*’ to ‘int**’ in initialization
error: invalid type argument of unary ‘*’ (have ‘int’)
6)Correct Answer is Option C i.e Error
Explanation :
#include <iostream>
using namespace std;
int main()
{
int *p;
int l=p,k;
k=realloc(p,2*sizeof(char));
printf(“%d”,k);
return 0;
}
Output:
If we execute the program above we get the below error
error: invalid conversion from ‘int*’ to ‘int’
error: invalid conversion from ‘void*’ to ‘int’
7)Correct Answer is Option C i.e -10
Explanation:
class SampleCode
{
public static void main(String args[])
{
int i,j;
i=0;
j=–i;
System.out.println(i++ + –i + i– + j– + –i +i);
}
}
Output :
-10