| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|||||||
| ds. c , c++ Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too. |
![]() |
|
|
LinkBack | Thread Tools | Rate Thread | Display Modes |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Sep 2007
Age: 25
Posts: 16
Thanks: 1 Thanked 0 Times in 0 Posts Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2
|
/*PLEASE SEND ME THE REASON*/
#include<stdio.h> #include<conio.h> void main() { int aa[]={1,2,3}; printf("\n%d %d",aa,aa+1); /* for this the out put something like: 8874 9239*/ printf("\n%d..........",aa); printf("\n%d..........",aa+1); /*and for this output is 8874 and 8876*/ } /* the same thing is present in three printf () one single printf and other twos are in separate printf()...then why the outputs are different */ |
|
|
|
|
|
#2 (permalink) |
|
Super Moderator
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117 Thanked 241 Times in 198 Posts Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51
|
Re: urgent help...required please..PLEASE SEND ME THE REASON
gouriproutray,
I don't have C compiler installed in my system. If you can send that to me, it will be nice help for me to do some R&D around this. My initial observation says, the issue could be because of the declaration. C can't accommodate dynamic arrays and in this case you didn't specify the size of the array. Thats why I guess compiler is behaving peculiarly. Thanks, Krishna
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation. |
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Join Date: Aug 2007
Age: 25
Posts: 16
Thanks: 0 Thanked 0 Times in 0 Posts Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: urgent help...required please..PLEASE SEND ME THE REASON
I dont think it is a case of not specifying the size of array because if we dont provide the size but if we mention the members of array then also it will accept without any error.......
ie int arr[2]={1,2,3}; int arr[]={1,2,3}; //Both the above statement are same and valid... Gouriproutray try to execute the the abv prog using Turbo C compiler, you will find that all the time you will get the same output...... |
|
|
|
|
|
#4 (permalink) |
|
Junior Member
Join Date: Sep 2007
Age: 25
Posts: 16
Thanks: 1 Thanked 0 Times in 0 Posts Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: urgent help...required please..PLEASE SEND ME THE REASON
In that question science aa is a array name, so only specifying the array name(like aa what i mentioned in the question) gives the address of the 1st element if it is a 1-d array. And simply specifying aa+1 gives the address of the 2nd element (if 1st one is 100,then 2nd one is 102).but what my compiler shows i mentioned in the question..now i am asking that is my compiler is a wrong one anything theory behind this.that shows the different out put
Actually i have a c++ compiler.but that's not a turbo compiler.. |
|
|
|
|
|
#5 (permalink) |
|
Super Moderator
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117 Thanked 241 Times in 198 Posts Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51
|
Re: urgent help...required please..PLEASE SEND ME THE REASON
Every compiler has its own implementation and each react differently for different situations/statements.
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation. |
|
|
|
|
|
#6 (permalink) |
|
Junior Member
Join Date: Aug 2007
Age: 25
Posts: 16
Thanks: 0 Thanked 0 Times in 0 Posts Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: urgent help...required please..PLEASE SEND ME THE REASON
There is nothing like ur "Compiler is wrong"....I do agree with Keerthi that different Compiler n Interpreter react according to the resources available n the statements executed .....thats why when u want to execute n get the desirable results u must make sure that ur compiler is the one which gives u the best resuls....Hence I suggested u to use Turbo C.
Hope now ur query has got the desirable answer.. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GOOD OPPURTUNITY.GRAB IT | Rena | HOT JOBS | 13 | 03-10-08 08:37 PM |
| IT company address | abeetha.m | Companies Info & Recruitment Process | 7 | 11-02-08 06:13 PM |
| Walkin for J2EE Professionals on 3rd / 4th February 2007 | sridhar | Walk-ins | 0 | 03-02-07 01:18 PM |
| urgent C#, .Net Professionals Required | sridhar | FRESHER JOBS | 0 | 12-01-07 08:48 PM |
| urgent C#, .Net Professionals Required | sridhar | EXPERIENCED JOBS | 0 | 11-01-07 06:30 PM |