0% found this document useful (0 votes)
165 views

Yash Sir Sanchit Sir: Visit Our Website

The document discusses visiting a website and downloading an app. It provides a call to action to visit the website and download the KG App. The document is promoting these two actions through brief instructions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

Yash Sir Sanchit Sir: Visit Our Website

The document discusses visiting a website and downloading an app. It provides a call to action to visit the website and download the KG App. The document is promoting these two actions through brief instructions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Visit our website

Download KG App

SANCHIT SIR YASH SIR


PROGRAMMING DAILY PRACTICE PAPER 16
1.What will be the output of following code :
// Assume all header files are included
main()
{
int *ptr;
ptr=(int*)malloc(256*256-1);
if(ptr==NULL)
printf("Memory allocation fails");
else
printf("Memory allocation successful");
}

A. Memory allocation fails


B. Memory allocation successful
C. Compilation Error
D. Runtime Error
[tcs 2019]

2. What will be the output of following code :


// Assume all header files are included
int main(){
while(!printf(“KNOWLEDGEGATE”));
return 0;
}

TCS NQT Superset course

Programming Course for Placements, GATE and Interview


SANCHIT SIR YASH SIR
A.Awesome
B. Error
C. Infinite loop
D.None of these
[Infosys 2019]

3.What will be the output of following code :


// Assume all header files are included
main()
{
int *ptr;
ptr=(int*)malloc(256*256L-1);
if(ptr==NULL)
printf("Memory allocation fails");
else
printf("Memory allocation successful");
}
A. Memory allocation fails
B. Memory allocation successful
C. Compilation Error
D. Runtime Error
[hexaware 2019]
4.What will be the output of following code :
// Assume all header files are included
main()
{

Learn all about Python Programming

University Exam Preparation Course


VINAY SIR SANCHIT SIR
typedef static int i;
i var=200;
printf("The value of variable is %d",var);
}
A.The value of variable var is 0
B.The value of variable var is 200
C. Compilation Error
D. Runtime Error
[Wipro 2019]

5.What will be the output of following code :


// Assume all header files are included
void main(){
int const * p=5;
printf("%d",++(*p));
}
A. 5
B. 6
C. 0
D. Compilation Error
[Accenture 2019]

Learn all about Python Programming

University Exam Preparation Course


VINAY SIR SANCHIT SIR
ANSWERS

1 (A) 2 (A) 3 (B) 4 (C) 5(D)

Ans. A

256*256=65536 exceeded the range of integer and hence wrap around takes
place and value of 256*256 becomes 0. Now (256*256-1) will become (0-1) = -1.
So the malloc in line ptr=(int*)malloc(-1) becomes fail to create memory as the
size is negative, and returns NULL.
Ans. A

Explanation : Above code will just print “KNOWLEDGEGATE” as the message.

Ans. B

256*256L=65536 can be stored in long int. Here 256L means long int. Hence
(65536-1) = 65535 bytes (64KB-1) memory will be allocated by malloc()
successfully.
Ans. C

Too many identifiers in type definition


Ans. D
Explanation :

p is a pointer to a “constant integer”. But we tried to change the value of the


constant integer.

Competitive Programming for beginners

SANCHIT SIR Top 20 Coding questions for placements CHIRAYU SIR


To get 10% discount on GATE 2022 Full
course,
Use referral code

KGYT
on

SUBSCRIBE FOR FULL


COURSE

Telegram group links

Placement group GATE discussion group

VISIT OUR WEBSITE


YASH SIR SANCHIT SIR

You might also like