AD1

Wednesday, 25 January 2017

What will be the output of the following program


#include <stdio.h>
int add(int a,int b){return(a+b);}
int sub(int x,int y){return(x-y);}
int main()
{
add(10,30);
printf("%d",sub-add+main);
return 0;
}
view raw ftp.c hosted with ❤ by GitHub
output

in this program we perform math operations on the base addresses of the functions , so the output is compiler dependant 
assume the base address of sub() is 4199876 and add() 4199856 and main() is 4199894
so the output will be 4199914

No comments:

Post a Comment