Pages : 2649780070077928 Price : Rs.
250.
00
Professional
July 2009
CRACKING THE C, C++CRACKING THE C, C++
AND JAVA INTERVIEWAND JAVA INTERVIEW
9780070077928
Pages : 264
Price : Rs.
250.
00
S G Ganesh is currently
working at Siemens,
Bangalore.
He has also
authored the book 60 Tips
on Object Oriented
Programming.
PRIVACY NOTICE:...
Mehr
Pages : 2649780070077928 Price : Rs. 250. 00 Professional July 2009 CRACKING THE C, C++CRACKING THE C, C++ AND JAVA INTERVIEWAND JAVA INTERVIEW 9780070077928 Pages : 264 Price : Rs. 250. 00 S G Ganesh is currently working at Siemens, Bangalore. He has also authored the book 60 Tips on Object Oriented Programming. PRIVACY NOTICE: Tata McGraw-Hill Education Pvt. Ltd. values your Privacy. From time to time The through this with other companies whose products or services we feel may be of interest to you. If you would like your name removed from these lists, please mail a written request to Tata McGraw-Hill Education Pvt. Ltd. B-4, Sector-63, Dist. Gautam Budh Nagar, Noida, UP-201 301 or email us at suman_datta@mcgraw-hill. com. For questions about our privacy ractices or to confirm the accuracy of your information, please contact Roystan La Porte, Privacy Official at Tata McGraw-Hill Education Pvt. Ltd. B-4, Sector-63, Dist. Gautam Budh Nagar, Noida, UP-201 301 or call at+9
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Sept. 2nd 2009
Seiten: 1
Aufrufe: 113
Downloads: 0
www.
linuxforu.
com | LINUX FOR YOU | APRIL 2007
C M Y K
73
It is assumed that the underlying implementation follows
2’s complement representation for integers.
Assume that i, j and r are integers.
Q1: What does the expression “(i & (i – 1))” do?
A: It checks if i is a power of 2 or not!
Q2: What does the expression (i &...
Mehr
www. linuxforu. com | LINUX FOR YOU | APRIL 2007 C M Y K 73 It is assumed that the underlying implementation follows 2’s complement representation for integers. Assume that i, j and r are integers. Q1: What does the expression “(i & (i – 1))” do? A: It checks if i is a power of 2 or not! Q2: What does the expression (i & (-i)) do? A: It returns the lowest bit set in an integer (which is a power of 2)! Q3: How can you express ~i in terms of other (preferably bit-wise) operators? A: (i ^ (~0)) and –(i + 1). Q4: What does the expression (j + ((i - j) & -(i < j)) do? A: This code results in the maximum of two integers i and j. Q5: How can you express the expression (i + j) in terms of bit-wise ‘&’ and ‘|’ operations? A: ((i & j) + (i | j)) Q6: What is the significance of the expression r = (i ^ j ^ r)? A: If r is equal to i, r will be reset to j; else if r is equal to j, r will be reset to i! That’s enough; let’s see the explanation. Q1. When i is a value that’s a power of 2, only a
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 1
Aufrufe: 1
Downloads: 0
An Overview of MSIL
The .
NET architecture addresses an important need - language interoperability.
Instead of generating
native code that is specific to one platform, programming languages can generate code in MSIL
(Microsoft Intermediate Language) targeting the Common Language Runtime (CLR) to reap the rich
benefits provided by ....
Mehr
An Overview of MSIL The . NET architecture addresses an important need - language interoperability. Instead of generating native code that is specific to one platform, programming languages can generate code in MSIL (Microsoft Intermediate Language) targeting the Common Language Runtime (CLR) to reap the rich benefits provided by . NET. Advanced programmers occasionally peek into MSIL code when they are in doubt of what is happening under the hood (using the Ildasm tool). Therefore, it is essential that the C# programmer understands the basics of MSIL. This beginner-level article gives an overview of MSIL and debugging with the Ildasm tool. System Requirements The programming examples in this article use C# as the source language for generating MSIL code, and so the reader is expected to have some basic understanding of C#. No prior exposure to MSIL is necessary. In addition, the reader is assumed to know what a stack data structure is. It is preferable that the reader has acce
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 4
Aufrufe: 5
Downloads: 0
110 may 2008 | LINUX For yoU | www.
openITis.
com
I
n March 2007, we covered the basics of code
obfuscation.
For those who missed reading it,
obfuscation is, “The art of concealing the meaning of
communication by making it more confusing and harder
to interpret.
” Here is an obfuscated (almost) one-line
program.
Can you decipher...
Mehr
110 may 2008 | LINUX For yoU | www. openITis. com I n March 2007, we covered the basics of code obfuscation. For those who missed reading it, obfuscation is, “The art of concealing the meaning of communication by making it more confusing and harder to interpret. ” Here is an obfuscated (almost) one-line program. Can you decipher it and find out what it does? main(int c,char**v){c=0;int n,i=(strlen(v[1])1);while(i>=0){n=v[1][i]-’0’;if(!(i%2))n=(n>4)?(n*2%10)+1: n*2;c+=n;i--;}return((c%10)==0);} Okay, it is difficult, so let me help you and explain what it does. This program checks if your credit card number is valid or not! No, I am not kidding, it is true; just give your credit card number as the argument to the executable and if it returns 1, the given number is valid, else it isn’t. Assume that the file name of the program is obfus. oneline. c. Compile it using your favourite C compiler. Run it and give your credit card number as the argument. If the program returns 1, the car
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 1
Aufrufe: 0
Downloads: 0
Unleashing the power of C++ Templates
An Introduction to Metaprogramming
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 49
Aufrufe: 1
Downloads: 0
Inside .
NET
Introduction
The .
NET architecture addresses an important need - language interoperability.
As more than one
language can be converted to the same intermediate language (MSIL - Microsoft Intermediate
Language), the code compiled through two different high-level languages can interact at an
intermediate code level.
This...
Mehr
Inside . NET Introduction The . NET architecture addresses an important need - language interoperability. As more than one language can be converted to the same intermediate language (MSIL - Microsoft Intermediate Language), the code compiled through two different high-level languages can interact at an intermediate code level. This gives you the ability to work in different languages depending on your requirements, and still benefit from the unified platform to which the code for any . NET compliant language is compiled. To understand the internals of . NET, it is essential to keep this core idea in mind. Also, understanding the internal details of . NET is essential to exploit the advanced features like runtime code generation and reflection. Visual Studio . NET is shipped with many tools, such as an assembly linker, that are best understood and used only when the programmer has a good understanding of the internals of . NET. When you understand how the runtime executes, the st
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 21
Aufrufe: 20
Downloads: 0
The Joy of Programming
Allocation of Local Variables in Stack
It is always fun to understand the low-level details of a program and to explore how compilers
work.
In this column, we’ll see some details on how local variables are allocated in stack and
some interesting issues on how compilers handle it.
Every month, I get lots of...
Mehr
The Joy of Programming Allocation of Local Variables in Stack It is always fun to understand the low-level details of a program and to explore how compilers work. In this column, we’ll see some details on how local variables are allocated in stack and some interesting issues on how compilers handle it. Every month, I get lots of mails and queries from LFY readers. This column seems to have become popular, particularly among students. This month, we’ll cover an interesting question from Saravanan swamy (GCT, Coimbatore). His question is: Why does the following program print 10? int i = 10; printf(“%d”); Note that the printf doesn’t obviously have i as matching argument for the format string “%d”. So, the program is incorrect and you can reasonably expect the program to print some garbage value. But note that it is equally possible that you might get 10 as output. Why? To understand this, let us see how compiler might transform these statements to low-level executable code. Loca
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 2
Aufrufe: 1
Downloads: 0
Professional
9780070656703
244 Pages
Rs.
250/Noida:B-4,Sector-63,Dist.
GautamBudhNagar,Noida-201301Ph:+91-120-4383435
Fax:+91-120-4383401-403E-mail:rekha_dhyani@mcgraw-hill.
com
Bangalore:3310,IstFloor,8thCross(Off12thMain),H.
A.
L.
IIStage,IndiraNagar, Bangalore-560038
Ph....
Mehr
Professional 9780070656703 244 Pages Rs. 250/Noida:B-4,Sector-63,Dist. GautamBudhNagar,Noida-201301Ph:+91-120-4383435 Fax:+91-120-4383401-403E-mail:rekha_dhyani@mcgraw-hill. com Bangalore:3310,IstFloor,8thCross(Off12thMain),H. A. L. IIStage,IndiraNagar, Bangalore-560038 Ph. :080-25263097Fax:080-25272797E-Mail:murali_krishna@mcgraw-hill. com Bhopal:BuildingNo. 49,1stFloor,Zone-1,MajorShoppingCentre, MPNagar,Bhopal, MadhyaPradesh-462011 Ph. :0755-4075638/4075637Email:pritam_bisht@mcgraw-hill. com, E-mail:rahul_arora@mcgraw-hill. com Bhubaneswar:52,ForestPark,2ndFloor,Bhubaneswar–751009 Ph. :0674-6531259,2595228E-mail:sudipto_banerjee@mcgraw-hill. com Chennai: 444/1,SriEkambara,Naicker,IndustrialEstate,Alapakkam, Porur,Chennai-600116Ph. :044-24769557-62(6Lines) E-Mail:sushil_mathews@mcgraw-hill. com Hyderabad:IstFloor,"KalaNilayam",E-6,VikrampuriColony,Karkhana, Secunderabad-500009 Ph. :040-27842412,Telefax:27842436E-Mail:sampath_erukulla@mcgraw-hill. com Kolkata: AE-641,SaltLakeCity,Sec
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 1
Aufrufe: 15
Downloads: 0
12 | February 2009 | LINuX For you | www.
openITis.
com
S.
G.
Ganesh
The Joy of Programming | Guest Column
H
ow does one calculate the average of two integers,
say i and j? Trivial you would say: it is (i + j) / 2.
Mathematically, that’s correct, but it can overflow
when i and j are either very large or very...
Mehr
12 | February 2009 | LINuX For you | www. openITis. com S. G. Ganesh The Joy of Programming | Guest Column H ow does one calculate the average of two integers, say i and j? Trivial you would say: it is (i + j) / 2. Mathematically, that’s correct, but it can overflow when i and j are either very large or very small when using fixed-width integers in C-based languages (like Java). Many other languages like Lisp and Python do not have this problem. Avoiding overflow when using fixed-width integers is important, and many subtle bugs occur because of this problem. In his popular blog post [1], Joshua Bloch (Java expert and author of books on Java intricacies) writes about how a bug [2] in binarySearch and mergeSort algorithms was found in his code in java. util. Arrays class in JDK. It read as follows: 1: public static int binarySearch(int[] a, int key) { 2: int low = 0; 3: int high = a. length - 1; 4: 5: while (low <= high) { 6: int mid = (low + high) / 2; 7: int midVal = a[mid];
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 1
Aufrufe: 4
Downloads: 0
www.
linuxforu.
com | LINUX FOR YOU | MAY 2007
C M Y K
73
IIIII
t is assumed that the underlying machine follows 2’s
complement representation for integers and IEEE 754
floating point standard for floating point numbers.
Let us look at a well-known trick of swapping two integers
without using any temporary variables, which uses...
Mehr
www. linuxforu. com | LINUX FOR YOU | MAY 2007 C M Y K 73 IIIII t is assumed that the underlying machine follows 2’s complement representation for integers and IEEE 754 floating point standard for floating point numbers. Let us look at a well-known trick of swapping two integers without using any temporary variables, which uses arithmetic operators + and -: void swap(int *i, int *j){ *i = *i + *j; *j = *i - *j; *i = *i - *j; } Yes, we know it works. But does it really work in all cases? How about this code: int arr[5] = {10,20,30,40,50}; int *ip = &arr[3]; swap(ip,&arr[3]); for(int i = 0; i<5; i++) printf(“%d “, arr[i]); // output: 10 20 30 0 50 So, when the elements to be swapped happen to refer to the same location, swapping fails. In the statement ‘*i= *i + *j;’, the implicit assumption is that *i and *j point to two different locations; this trick will not work if the results of + and – operations are over-written. Here is a small test case just to demonstrate that: int x = 10;
Weniger
Ab sgganesh
Adobe PDF Dokument
Veröffentlicht am Juni 7th 2009
Seiten: 1
Aufrufe: 5
Downloads: 0