C++ doubts:4 2mrw's xam.. help!

1. char ch;
cin.get(ch).get(ch);//How this statement is valid??-2 get() func.

2."this" pointer, random()function // Is it there in the CBSE syllabus

3.pls. illustrate (pls give eg.)scanf and printf statements(especially
for outputs)

4.Give output-
void main()
{
int x[]={10,20,30,40,50};
int *p, **q, *t;
p=x;
t=x+1;
q=&t;
cout<<*p<<","<<**q<<","<<*t++;
}

5. How to detect end of file without using eof() function.

6.Give the ouput and explain
#include<iostream.h>
void main()
{
int a =32, *ptr=&a;
char ch='A' , &cho=ch;
cho+=a; *ptr+=ch;
cout<<a<<" "<<ch<<endl;
}
7.Convert the infix expression:
A-B+C*D^E*G/H into postfix expression. Evaluate the postfix expresstion showinf the status of stack at every step given
A=5, B=2,C=4,D=2,E=1,G=6,H=5;
//Atleast explain the use of exponential operator here..

8.Why Insertion sort is more efficient than other sorts?

42 Answers

62
Lokesh Verma ·

and I am not sure of the random() function either

I think rand() was there in my time!

62
Lokesh Verma ·

both K maps are correct...

1
sriraghav ·

@vivek,, No it luks lik that, but u hav to do the same with last row 1's...(just like first row 1's in my answer)

1
sriraghav ·

so ,both the answers will b accepted??

1
Vivek ·

oh yeah,both involve 4 pairs

1
sriraghav ·

@thanx ankit.. it was useful...

62
Lokesh Verma ·

oh yeah vivek is right.. i dinsee that..

both will be accepeted :)

1
sriraghav ·

horizontal rollin is more efficient than vertical rollin??//sorry sir-this is just a guess, i donno the exact answer..

1
sriraghav ·

:) sir.. can u pls explain random()

1
sriraghav ·

and 6th answer is
129 a
pls explain...

62
Lokesh Verma ·

6th wala i am a bit confused myself..

i read it long back...now dont remember that one..

1
ankit mahapatra ·

read this : http://www.cppreference.com/wiki/c/io/scanf
that will help you understand.

1
ankit mahapatra ·

ya its the same

1
ankit mahapatra ·

But in 6th value of a=32 is not changed then why will it give 129?

1
Vivek ·

see ptr is attached to a,so if ptr changes by 97,so will a (ASCII code of 'a' =97)

('A' + a = 'A' + 32 = 'a')

1
ankit mahapatra ·

ok thanks.

1
sriraghav ·

7.Convert the infix expression:
A-B+C*D^E*G/H into postfix expression. Evaluate the postfix expresstion showinf the status of stack at every step given
A=5, B=2,C=4,D=2,E=1,G=6,H=5;

62
Lokesh Verma ·

http://targetiit.com/iit_jee_forum/posts/infix_prefix_postfix_3561.html

read this one..

1
Pavithra Ramamoorthy ·

6) i ve a doubt whether assignment operators can b used fr characters.....

1
Philip Calvert ·

wow so many doubts in C++ ..... maybe i should also post some of mine but in free time..

btw let everyone say what they want to i would still say java is much better...(hehe u may say that angoor khatte hain wali baat but still..)

1
Vivek ·

i agree Philip,JAVA is better

62
Lokesh Verma ·

*p++ = *(p++)

sometimes it depends on compilers.. but I think it hsould be this...

To confirm just run a small prog on the compiler.. i dont have a c++ compiler installed

62
Lokesh Verma ·

4.Give output-
void main()
{
int x[]={10,20,30,40,50};
int *p, **q, *t;
p=x;
t=x+1;
q=&t;
cout<<*p<<","<<**q<<","<<*t++;
}

*p=10
*t=20
*t++=30
**q=20

output will be

10,20,30

5. How to detect end of file without using eof() function.

by taking the size of the file and comparing it to the parsed length.. It is a very tedious and not so good method!

1
ankit mahapatra ·

2. yes they are in syllabus
3.scanf and printf are like cin and cout . they are used under header file stdio.h
6. 32 A

21
tapanmast Vora ·

Sir, U r a C++ expert or JAVA or both the languages u know?

33
Abhishek Priyam ·

2. "this" pointer is not in syllabus.. but random is there

62
Lokesh Verma ·

neither..

i havent touched java

and C++ not after class xii

but i did one C course at kgp..

1
sriraghav ·

Sir but the output for 4th is given as 10, 30, 20.. Can u explain the *t++ statement... Wont the size of integer get incremented (ie to 30)??So even q's value will be same as t(ie 20), but in the output t gets inc to 30

1
sriraghav ·

Sir priyam mentioned "this " pointer,rite priyam?? :)

62
Lokesh Verma ·

Read infix post fix

http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm

It is written nicely

Dont mess this in the exam.. this is free ka marks

8.Why Insertion sort is more efficient than other sorts?

Do you know the method used in inserttion sort?

It ihas to do with the order of the program.. ie the number of steps needed to get that done.

Your Answer

Close [X]