Sunday, September 2, 2012

Guess The output of program

#include<stdio.h>
main()
{
int a=10;
printf("\n %d %d",++a,a++);
getch();
}

Observation: The printf statement get executed from the right side. so first the a will be printed as it is and then it gets incrimented and then again incrimented and the a value is printed means second a incrimented twice before it gets printed.

#include<stdio.h>
main()
{
int *p;
printf("sizeof(*p)=%d ,sizeof(p)=%d",sizeof(*p),sizeof(p));
getch();
}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...