Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


void main()
{
int a[]={1,2,3,4,5},i;
for(i=0;i<5;i++)
printf("%d",a++);
getch();
}

Answers were Sorted based on User's Feedback



void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(..

Answer / jaya.vavilala

output is error.because we cannot inrease address of
array.if we increase address can be increased after go on
increasing after 5th position it cannot find where it is
present.so we cannot increase array directly through
pointer we can increase.

Is This Answer Correct ?    13 Yes 1 No

void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(..

Answer / vikas thakur

The answer is error.
The reason is that we can't increment a constant(the
variable int a[] ). The expression int a[] is the address
where the system had placed your array and it will remain
to stay at that address until the program terminates. you
can't increment an address but you can increment a pointer.

.....the correct program would be....

void main()(
int a[]={1,2,3,4,5},i;
for(i=0;i<5;i++)
printf("%d",a[i]);
getch();
}

....in another way.....

void main()(
int a[]={1,2,3,4,5},i;
int *p;
p = a;
for(i=0;i<5;i++)
printf("%d",*(p++));
getch();
}

Is This Answer Correct ?    3 Yes 0 No

void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(..

Answer / chhaya

Here , in program array is given of 5 element. But at d
time of printing output ,increase address not pointer
i.e.
a[i]={1,2,3,4,5}
then u wnat to print array
Printf("%d",i++);
getch();

this sentence is requird. because array is set of element
and element is pointed by "pointer". If u wnt to show
element then use pointer not address of array.....

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

what is the hexidecimal number of 4100?

16 Answers   Google,


Which of the following is not an infinite loop ? a.while(1){ .... } b.for(;;){ ... } c.x=0; do{ /*x unaltered within theloop*/ ... }while(x==0); d.# define TRUE 0 ... while(TRUE){ .... }

7 Answers   TCS,


how to write palindrome program?

3 Answers  


to find the program of matrix multiplication using arrays

6 Answers   Bhel,


a C prog to swap 2 no.s without using variables just an array?

5 Answers   TCS,






Describe wild pointers in c?

0 Answers  


Explain a pre-processor and its advantages.

0 Answers  


input any 4 digit number and find the difference of all the digits?

3 Answers   Google,


What is "Hungarian Notation"?

0 Answers   Celstream,


What is the general form of function in c?

0 Answers  


What is the difference between far and near in c?

0 Answers  


Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

0 Answers   TCS,


Categories