Hi
Could anybody help me to clear that out. Just go step by step and try to explain it to me. I would appreciate it
Thanks

The answer for that one: At the end: c1 -- 40 (hex) and c2 -- DC (hex)


The answer for that one:
Value c in hex at the end: 1C. (After the exclusive or, c holds
71 hex. When this is right shifted by two bits, we get 1C hex.)

Hi Could anybody go step by step with those short examples so I could understand them. Thank you.

The answer for that one: ------- r r a a i i n n


Output:
-------
1 0
7 3

Hi the code u posted is C code and not C++.

So u would get better help and more replies if u would post it in the right section.

Hi the code u posted is C code and not C++.

So u would get better help and more replies if u would post it in the right section.

Why do you think it is C++? :|

Please find the comments inline

#include <stdio.h>

int main(int argc, char *argv[])
{
	
	int g[] = {-1,1,3,7,2}; /* g is an array of integers */
	int *x = g; /* x is a pointer to integer that points to the 
				array g(basically to the first element) */
	int y;
	y = ++(*x); /* y is now stored with the incremented value pointed by x 
				i.e. g[0]+1 = -1+1 = 0 */
	x++;/* x now points to g[1] */
	printf("%d %d",*x,y);/* will print g[1] as x points to g[1] and 0 */
	y = *(++x); /* y is now stored with the value g[2] (which is 3), 
				++x increments the address and * gets the value */
	x++; /* x now points to g[3] */
	printf("%d %d",*x,y); /* will print g[3] and g[2] i.e. 7 and 3 */
	return 0;
}
#include <stdio.h>

int main(int argc, char *argv[])
{
	char p[]="rain"; /* p is an array of characters storing the string "rain" */
	char *t=p; /* t points to first char of array p which is "r" */
	char *q=t-1; /* q points to a memory location just before the first character "r" */
	while(*t) /* continue until t is null */
		printf("%c %c\n",*(++q),*(t++));/* *(++q) => value of address+1 pointed by q.
			*(t++) => value of address pointed by t and then increment the address pointed by t*/
	return 0;
}

I am not that good at shifting operations... some one else can may be answer the first queries...

Hi the code u posted is C code and not C++.

So u would get better help and more replies if u would post it in the right section.

As per you, it is C, then this is the right forum...
And what makes you say, its c++??...

As per you, it is C, then this is the right forum...
And what makes you say, its c++??...

The actual questions deal with the calculations, not the output statements. They are fully C++ as well as C. And printf() is a C++ function. Check any C++ book/tutorial/standard.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.