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 ?    4 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

How can I read a directory in a c program?

1 Answers   CSC,


What does volatile do?

0 Answers  


What are the different pointer models in c?

4 Answers  


Explain the difference between strcpy() and memcpy() function?

0 Answers  


What is omp_num_threads?

0 Answers  


If input is 123 then how to print 100 and 20 and 3 seperately?

4 Answers  


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

0 Answers   Google,


In which area global, external variables are stored?

3 Answers  


What is the difference between void main() and int main()?

1 Answers  


What is the use of pragma in embedded c?

0 Answers  


What are the 4 types of organizational structures?

0 Answers  


How is null defined in c?

0 Answers  


Categories