15 July, 2011

Case study: Lvalue error

Try the below programs and analyse the output.

A)
int main()
{
int n = 5;
int j;

j = ++n++;

printf("j = %d\n", j);
return 0;
}
o/p = ?

B)
int main()
{
int n = 5;
int *p = &n;
int j;

j = ++*p++;

printf("j = %d\n", j);
return 0;
}
o/p = ?

C)
int main()
{
int n = 5;
int *p = &n;
int j;

j = ++(*p)++;

printf("j = %d\n", j);
return 0;
}
o/p = ?

PS: First of all, U need to know operator precedence and associativity to understand the program.

14 July, 2011

String Palindrome - Recursive function

Hi all,

Write a program to find whether the given string is palindrome or not with the help of recursive functions.

NOTE: There are many ppl who are not active in this forum, i request them to wake up and reply to the questions posted or atleast to post some questions. Else those ppl will be removed from this forum.

07 July, 2011

Ternary Operator

main()
{
int a = 10, b = 7;
a >= 5 ? b = 100 : b = 200;
printf("B = %d\n",b);
}
When we compile this prg, I am getting an error like this:
3: error: lvalue required as left operand of assignment

What does this mean and how to resolve it?

13 June, 2011

Simple but not Simple!!!!!!

#include
main(){
int x=20;
printf("\n%d\t%d\t%d\n",x,x++,++x);
}

What is the o/p of the above prg and plz explain the logic???

02 June, 2011

Simple one!!!!!!

Whats the difference between "typedef"s and MACROs(#define)????

02 May, 2011

Const pointer Vs Pointer to a const

Does any one remember the difference between constant pointer and pointer to a constant.

I have three declaration:

const int *ptr;
int const *ptr;
int *const ptr;