What is the output of the following code 1 2 3 4 What is the

What is the output of the following code? 1 2 3 4 What is the output of the following program? a b be segmentation fault str is an object that is located in which memory region? code global data stack heap

Solution

4ans. C)3

#include<stdio.h>
int main(void)
{
   int a[2] = {1,0};
   int b[2][2] = {{1,2},{3,4}};
   printf(\"%d\",b[1][a[1]]);
   return 0;
}

__________________________________

5ans. A)a

#include<stdio.h>
char *f(char *);
int main(void)
{
   char *str = \"abc\";
   printf(\"%c\", *f(str));
   return 0;
}
char *f(char *p)
{
   return p++;
}

___________________________

6ans.(B)Global data

When you initialize a string literal to a character pointer, char * str = \"abc\", the string \"abc\" is somewhere filled in a read only section of the data segment.

 What is the output of the following code? 1 2 3 4 What is the output of the following program? a b be segmentation fault str is an object that is located in wh

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site