Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

varsha valli g.'s Avatar
Blazing goIITian

Joined: 31 Jan 2007
Post: 515
30 Mar 2008 09:53:56 IST
0 People liked this
5
621 View Post
give output ,take rates!!!!!!!
None

1) find output:
void main()
{
struct
{int x,y;
}*p,sg[4]={{9,8},{7,6},{5,4},{3,2}};
p=&sg[0];
for(int i=0;i<4;i++,p++)
cout<<(p+i)->x<<"\t"<<(p+i)->y<<endl;
}
is the output????:    7  6
                              5  4
                              3  2
                              9  8
 
2) whatis d difference between a[x++] and a[x]++,xplain!!!!!!!
 
3)  find output:
void main()
{
struct point
{ int x,y;
}ob[]={ {1,7},{15,25},{35,45},{55,65}};
point *a;
a=ob;
a++;
a->x++;
a++;
a->y++;
cout<<ob->x<<" "<<a-y<<endl;
cout<<ob->y<<" "<<a->y<<endl;
}
plz reply soon
rates assured!!!!!!!!!!!!!!!!!!


Share this article on:

Comments (5)

RyuAmakusa's Avatar

Blazing goIITian

Joined: 21 Mar 2008
Posts: 776
30 Mar 2008 16:38:07 IST
1 people liked this

9 8
5 4
 
then some crap will be printed because the pointer goes beyond the scope  of the array.
RyuAmakusa's Avatar

Blazing goIITian

Joined: 21 Mar 2008
Posts: 776
30 Mar 2008 16:40:22 IST
1 people liked this

I hope to find some better questions. hear I go again  a[x++] is like a[x] but later x is incrimented .in a[x]++ the a[x] is incrimented.
RyuAmakusa's Avatar

Blazing goIITian

Joined: 21 Mar 2008
Posts: 776
30 Mar 2008 16:45:21 IST
0 people liked this

3) 1 46
    7 46
varsha valli g.'s Avatar

Blazing goIITian

Joined: 31 Jan 2007
Posts: 515
30 Mar 2008 18:08:49 IST
0 people liked this

r u sure it is 1 46 i think its 1 16.
dint get ur 2nd one ,plz xplain
!!!!!!!!!
RyuAmakusa's Avatar

Blazing goIITian

Joined: 21 Mar 2008
Posts: 776
31 Mar 2008 19:18:26 IST
1 people liked this

 
ob[]={ {1,7},{15,25},{35,45},{55,65}};
point *a;
a=ob;   // now a will contain the adress of ob[0].
a++;   // now a will contain the adress of ob[1]. 
a->x++; // now ob[1]->x is incrimented ie.15 becomes 16
a++;   // now a will contain the adress of ob[2]. ----------(1)
a->y++; // now ob[2]->y is incrimented ie.45 becomes 46
cout<<ob->x<<" "<<a-y<<endl;//ob contains adress of ob[0] so ob->x is 1
and a->y is 46 from (1)
cout<<ob->y<<" "<<a->y<<endl; //now ob->y is 7 and a->y is 46 from (1)
  so it is
 
 1 46
 7 46
 
I hope it's clear If not ask;



Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads