1,417 views
–2 votes
–2 votes
int main

{

int * str ="2017";

printf("%d", madeEasy(str));

return 0;

}

int maseEasy(int * p1)

{

int * p2 = p1;

while(*++p1);

return (p1-p2);

}

assume object of data type int occupies 2 bytes then output of the program is.............??

2 Answers

1 votes
1 votes
My ans is 4 ,bcoz ptr differnce = (p1 -p2) / size of datatype = 8 /2 = 4
0 votes
0 votes

Ans is 4

due to address arithmatic (P1-p2)/sizeof(char)

Related questions

763
views
2 answers
0 votes
logan1x asked May 19, 2019
763 views
A default catch block catches,[A]. all thrown objects[B]. no thrown objects[C]. any thrown object that has not been caught by an earlier catch block[D]. all thrown object...
411
views
1 answers
0 votes
go_editor asked Sep 18, 2018
411 views
What will be the output of the following C program? If you think it will give a runtime error, you need to mention it. In either case, your answer must include proper jus...
498
views
1 answers
2 votes
Prayag asked Jul 16, 2018
498 views
#include <stdio.h void f(char ); int main() { char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" }; f(argv); return 0; } void f(char p) { char *t; t...
500
views
1 answers
2 votes
Sugumaran asked Feb 7, 2018
500 views
#include<stdio.h int main() { int x=191; char *p; p=(char*)&x; printf("%d",*p); }explain it