Question & Answer: 5) Consider the following C++ code snippet and what is the ousput of this progan #include usin…..

5) Consider the following C++ code snippet and what is the ousput of this progan #include <iostream> using nanespace stdi int main(0 int arraytl-t5, 7. 10, 9) int p (array1) cout << array+ 10: system(pause)z return 0: a) 11 b) 6 c) 13 d) error 6) Consider the following C code suippet: is the code segneat corfect or emor If correct what is the outpur? al Garbage svalue b): Address ofx c) Error d) None of the above

media%2F16a%2F16a1482a-17b6-488d-9ce9-ea

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

Still stressed from student homework?
Get quality assistance from academic writers!