Question: 1.What is the output of this C code? #include void main() { int a[3] = {1, 2, 3}; int *p = a; printf(%pt%p, p, a);

1.What is the output of this C code?

#include void main() { int a[3] = {1, 2, 3}; int *p = a; printf("%p\t%p", p, a); }

a) Different address is printed.

b) Compile time error.

c) Nothing.

d) Same address is printed.

2.What is the output of this C code?

 void main() 
 { 
 char *s = "hello"; 
 char *p = s; 
 printf("%p\t%p", p, s); 
 } 

a) Same address is printed.

b) Different address is printed.

c) Nothing.

d) Run time error.

3. What is the output of this C code?

 #include  
 void main() 
 { 
 char *s= "hello"; 
 char *p = s; 
 printf("%c\t%c", p[0], s[1]); 
 } 

a) h e

b) h h

c) h l

d) Run time error.

4.What is the output of this C code?

 #include  
 void main() 
 { 
 char *s= "hello"; 
 char *p = s; 
 printf("%c\t%c", *(p + 3), s[1]); 
 } 

Question 4 options:

a) l l

b) le

c) he

d) lo

5. What is the output of this C code?

 #include  
 void main() 
 { 
 char *s= "hello"; 
 char *p = s; 
 printf("%c\t%c", 1[p], s[1]); 
 } 

a) h h

b) e e

c) l l

d) Run time error.

6. What is the output of this C code?

 #include  
 void foo( int[] ); 
 int main() 
 { 
 int ary[4] = {1, 2, 3, 4}; 
 foo(ary); 
 printf("%d ", ary[0]); 
 } 
 void foo(int p[4]) 
 { 
 int i = 10; 
 p = &i; 
 printf("%d ", p[0]); 
 } 

a) Compile time error

b) Undefined behavior

c) 10 1

d) 10 10

7.What is the output of this C code?

 #include  
 int main() 
 { 
 int ary[4] = {1, 2, 3, 4}; 
 int *p = ary + 3; 
 printf("%d ", p[-2]); 
 } 

a) 2

b) 1

c) Some garbage value

d) Compile time error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!