Database-MySQL [Redpine Infotech Placement]: Sample Questions 1 - 1 of 1

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 1

Question

MCQ▾

What is output for the following program?

  1. #include<stdio.h>
  2. main ()
  3. {
  4.     int ⚹p, ⚹q, i;
  5.     p=(int⚹)100;
  6.     q=(int⚹)200;
  7.     i=q-p
  8.     printf(“%d” i);
  9. }

Choices

Choice (4)

a.

Compile error

b.

100

c.

0

d.

25

Answer

d.

Explanation

Table Shows the Program
#include < tdio. h >Standard library function
main ()startup after initialization
int ⚹ p, ⚹ q, i;Declare pointer p, pointer q and i
p = (int ⚹) 100;

q = (int ⚹) 200;

p is pointer to int 100 byte from beginning the address space and q is a pointer to int 200 byte from beginning
i = q-pp and q difference are 100 and our architecture has 4-byte ints, so
printf ( “% d” i) ;print i as 25

So, answer is 25

Developed by: