Thursday, February 25, 2010

DESIGN PATTERNS

Write in detail about Design Patterns?

Design Patterns
A design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.
Not all software patterns are design patterns. Design patterns deal specifically with problems at the level of software design. Other kinds of patterns, such as architectural patterns, describe problems and solutions that have alternative scopes. Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns. In order to achieve flexibility, design patterns usually introduce additional levels of indirection, which in some cases may complicate the resulting designs and hurt application performance.
By definition, a pattern must be programmed anew into each application that uses it. Since some authors see this as a step backward from software reuse as provided by components, researchers have worked to turn patterns into components. Meyer and Arnout claim a two-thirds success rate in componentizing the best-known patterns.
Often, people only understand how to apply certain software design techniques to certain problems. These techniques are difficult to apply to a broader range of problems. Design patterns provide general solutions, documented in a format that doesn't require specifics tied to a particular problem.
Structure
Design patterns are composed of several sections. Of particular interest are the Structure, Participants, and Collaboration sections. These sections describe a design motif: a prototypical micro-architecture that developers copy and adapt to their particular designs to solve the recurrent problem described by the design pattern. A micro-architecture is a set of program constituents (e.g., classes, methods...) and their relationships. Developers use the design pattern by introducing in their designs this prototypical micro-architecture, which means that micro-architectures in their designs will have structure and organization similar to the chosen design motif.
 In addition, patterns allow developers to communicate using well-known, well understood names for software interactions. Common design patterns can be improved over time, making them more robust than ad-hoc designs.
 Domain specific patterns
 Efforts have also been made to codify design patterns in particular domains, including use of existing design patterns as well as domain specific design patterns. Examples include User Interface design patterns, Information Visualization and web design.
 The Pattern Languages of Programming Conference (annual, 1994—) proceedings include many examples of domain specific patterns.
 Classification
 Design Patterns originally grouped design patterns into the categories Creational Patterns, Structural Patterns, and Behavioral Patterns, and described them using the concepts of delegation, aggregation, and consultation. For further background on object-oriented design, see coupling and cohesion. For further background on object-oriented programming, see inheritance, interface, and polymorphism. Another classification has also introduced the notion of architectural design pattern which may be applied at the architecture level of the software such as the Model-View-Controller pattern












2:   Explain Design Patterns in Smalltalk MVC.?

The Model/View/Controller (MVC) triad of classes is used to build use interfaces in Smalltalk-80. Looking at the design patterns inside MVC should help you see the meaning of the term pattern.
 MVC consists of three kinds of objects. The Model is the application object, the View is its screen presentation, and the Controller defines the way the user interface reacts to user input. Before MVC, user interface designs tended to lump these objects together. MVC decouples them to increase flexibility and reuse.
MVC decouples views and models by establishing a subscribe/notify protocol between them. A view must ensure that its appearance reflects the state of the model. Whenever the model’s data changes, the model notifies views that depend on it. In response, each view gets an opportunity to update itself. This approach lets you attach multiple views to a model to provide different presentations. You can also create new views for a model without rewriting it.
Another feature of MVC is that views can be nested. For example, a control panel of buttons might be implemented as a complex view containing nested button views. The user interface for an object inspector can consist of nested views that may be reused in a debugger. MVC supports nested views with the Composite View class, a subclass of View. Composite View objects act just like View objects; a composite view can be used wherever a view can be used, but it also contains and manages nested views.
Again, we could think of this as a design that lets us treat a composite view just like we treat one of its components. But the design is applicable to a more general problem, which occurs whenever we want to group objects and treat the group like an individual object. It lets you create a class hierarchy in which some subclasses define primitive objects (e.g. button) and other classes define composite objects (Composite View) that assemble the primitives into more complex objects.
MVC also lets change the way a view responds to user input without changing its visual presentation. You might want to change the way it responds to the keyboard, for example, or have it use a pop-up menu instead of command keys. MVC encapsulates the response mechanism in a Controller object. There is a class hierarchy of controllers, making it easy to create a new controller as a variation on an existing one.
A view uses an instance of a Controller subclass to implement a particular response strategy, to implement a different strategy, simply replace the instance with a different kind of controller. It’s even possible to change a view’s controller at run-time to let the view change the way it responds to user input. For example, a view can be disabled so that it doesn’t accept input by giving it a controller that ignores input events.
The View-Controller relationship is an example of the Strategy design pattern. A Strategy is an object that represents an algorithm. It’s useful when you want to replace the algorithm either statically or dynamically, when you have a lot of variants of the algorithm, or when the algorithm has complex data structures that you want to encapsulate.
MVC uses other design patterns, such as Factory Method to specify the default controller class for a view and Decorator t add scrolling to a view. But the main relationships in MVC are given by the Observer, Composite, and Strategy design patterns

















3:   Explain about t Encapsulating Implementation Dependencies in supporting multiple window systems in designing a document editor?

Encapsulating Implementation Dependencies
The Window class encapsulates the things windows tend to do across window systems:
§  They provide operation for drawing basic geometric shapes.
§  They can iconify and deiconify themselves.
§  They can resize themselves.
§ The can (re)draw their contents ion demand, for example, when they are deiconified or when an overlapped and obscured portion of their screen shapes is exposed. 
The Window class must span the functionality of windows from different window systems. Lets considered two extreme philosophies: 
1. Intersection of functionalities: The window class interface provides only functionality that’s common to all window systems. The problem with this approach is that our window interface points up being only as powerful as the least capable windows system. We cannot take advantage of more advanced features even if most windows systems support them.
2. Union of functionality: Create an interface that incorporates the capabilities of all existing systems. The trouble here is that the resulting interface may well be huge and incoherent. Besides, we will have tio change it anytime a vendor revises it’s window system interface. 
Neither extreme is a viable solution, so our design will fall somewhere between the two. The window class will provide a convenient interface that supports the most popular windowing features. Because Lexi will deal with this class directly, the window class must also support the things Lexi knows about, namely, glyphs. That means Window’s interface must include a basic set of graphics operations that lets glyphs draw themselves in the window. The below table gives a sampling of the operations in the window class interface.










Responsibility Operations
Window Management Virtual void Redraw ( )
Virtual void Raise ( )
Virtual void Lower ( )
Virtual void Iconify ( )
Virtual void Deiconify ( )
. . .
Graphics Virtual void DrawLine (…)
Virtual void DrawRect (…)
Virtual void DrawPolygon (…)
Virtual void DrawText (…)
. . .

Window is an abstract class. Concrete subclasses of window support the different kinds of windows that users deal with. For example, application windows, icons, and warning dialogs are all windows, but they have somewhat different behaviors. So we can define subclasses like Application Window, Icon Window, and Dialog Window to capture these differences. The resulting class hierarchy gives applications like Lexi, a uniform and intuitive windowing abstraction, one that does not depend on any particular
Note that we have defined a window interface for Lexi to work with, where does the real platform-specific window come in? If we’re not implementing our own window system, then at some point our window abstraction must be implemented in terms of what the target window system provides. So where does that implementation live.

 One approach is to implement multiple versions of the window class and its subclasses, one version each for each windowing platform. We’d have to choose the version to use when we build Lexi for a given platform. But imagine the maintenance headaches we would have keeping track of multiple classes, all named ‘Window’ but each implemented on a different window system. Alternatively, we could create implementation-specific subclasses of each class in the window hierarchy and end up with another subclass explosion problem like the one we have when trying to add embellishments. Both of these alternatives have another drawback: neither gives us the flexibility to change the window system we use after we have compiled the program. So we will have to keep several different executables around as well.

 If we encapsulate a window system’s functionality in an object, then we can implement our window class and subclasses in terms of that object’s interface. Moreover if that interface can serve all the window systems we are interested in, then we wont have to change window or any of its subclasses to support different window systems. We can configure window objects to the window systems we want simply by passing them the right window system- encapsulating object. We can even configure the window at a run time.

4:   Discuss about design problems in Lexi’s design.?

Below are the seven problems in Lexi’s design:
§ Document structure: The choice of internal representation for the document affects nearly every aspect of Lexi’s design. All editing, formatting, displaying, and textual analysis will require traversing the representation. The way we organize this information will impact the design of the rest of the application.
§ Formatting: How does Lexi actually arrange text and graphics into lines and columns? What objects are responsible for carrying out different formatting policies? How do these policies interact with the document’s internal representation?
§ Embedding the user interface: Lexi’s user interface includes scroll bars, borders, and drop shadows that embellish the WYSIWYG document interface. Such embellishments are likely to change as Lexi’s user interface evolves. Hence it is important to be able to add and remove embellishments without affecting the rest of the application.
§ Supporting multiple look-and-feel standards: Lexi should adapt easily to different look-and-feel standards such as Motif and Presentation Manager (PM) without major modification.
§ Supporting multiple window systems: Different look-and-feel standards are usually implemented on different window systems. Lexi’s design should be as independent of the window system as possible.
§ User operations: Users control Lexi through various user interfaces, including buttons and pull-down menus. The functionality behind these interfaces is scattered throughout the objects in the application. The challenge here is to provide a uniform mechanism both for accessing this scattered functionality and for undoing its effects.
Spelling checking and hyphenation: How does Lexi support analytical operations such as checking for misspelled words and determining hyphenation points? How can we minimize the number of classes we have to modify to add a new analytical operation?





5:   Write a brief note on template method behavioral pattern.?

Template method behavioral pattern
The Template Design Pattern is perhaps one of the most widely used and useful design patterns. It is used to set up the outline or skeleton of an algorithm, leaving the details to specific implementations later. This way, subclasses can override parts of the algorithm without changing its overall structure.
This is particularly useful for separating the variant and the invariant behavior, minimizing the amount of code to be written. The invariant behavior is placed in the abstract class (template) and then any subclasses that inherit it can override the abstract methods and implement the specifics needed in that context. In the body of Template Method () (see UML diagram below), there are calls to operation1 () and operation2 (). What it is that operation1 () and operation2 () do are defined by the subclasses which override them.
A common example of this is when writing a program that will handle data using various sorting algorithms. The Abstract Class would have a method called Sort () (analogous to Template Method () -- the invariant behavior) which when called, would use the helper methods in the class, which are specified by any class that inherits from it. The helper methods in this case might be compare () (compares two objects and returns the one that is "higher") and sort Pass () (performs one iteration of a particular sorting algorithm) The interesting thing is that the usual control structure of object calls and relations is reversed. It is the parent class that calls the method in the subclass, a behavior which Richard E. Sweet refers to as the "Hollywood Principle" -- "Don't call us, we'll call you." The Template Design Pattern is of particular use in the Factory Design Pattern

VOC SORTED

abode-dwelling
accumen-sharp
adage-proverb
adhesive = tenacious
Admonish : usurp
admonish = cautious
Alienate : estrange
amiable-friendly
annihilate-destroy
Baffle : Frustrate
bahalf-on behalf of
behest-
belate = too late
belief : conviction
Brim : Border
cajole-coax
caprice - impulsive, whim
capricious-impulsive, whim, unpredictable
Cargo :freight
compunction-remorse
Concur :acquiesce
confiscate = appropriate
Covet : crave
discretion = prudence
disparity-unequality
Dispel : Scatter
dispel = dissipate
divertism-difference
divulge = reveal
Efface : obliterate
effluent-waste
efflugent –radiance
Emancipate : liberate
extricate-free from
fertile-fruitful
florid-ornate, showy
forbid-order
frieze-combine
furtive = stealthy
Hamper : obstruct
Heap : to pile
hover = linger
incentive : ----
inert: passive
Instigate : incite
lament : wail
latent = potential
latitude = scope
lethargy = stupor
mandatory-compulsory
meager(MEAGRE) : scanty
merry = gay
metamorphisis-transformation
mirth-laughter, merriment
misery : distress
momentary = transient
morbid-diseased, unhealthy
mortal-deadly
mortify-humilate
muse-ruminant, ponder
obstinate = stubborn
ordain-command
ordinance-appoint
ovation-applause
persistance-regret, refuse
premonition-fore warning
Pretension : pretentious
pretentious = ostentatious
profound-intense, deep
randy-sexually exciting
rapt-lively
remonstrance-protest, object
renounce = reject
revitance-repeat
scrutiny-done exam
solicit : urge
solicit = beechat
stiffle : sniths
subside : wane
to merit = to deserve
torpid-sluggish
tranquil = serene
turbid-muddy
veer : diverge
volume = quantity
whet-sharpen

Technical Questions in the second round --

---------------------------------------
[1] What are the current trends and areas of focus in IT.
My Ans. Talked about emerging trends of S/W Engg and ISO 9000 stuff
(gave vague ideas about them as I don't know much nor do I care
about these topics myself ;-)). Then mentioned the proliferation of O-O
methodologies and their usefulness in speeding up development process,
code re-usability, ease of maintenance, ease of bug-fixing.
Thirdly, mentioned the work going on in High-Speed N/w - FDDI, ATM,
Fast-Ethernet(100Mbps). Told whatever little I knew about ATM in
response to another question.
[2] What is a Micro-Kernel architecture.
My Ans. This is a developing area in OSs where instead of building the
kernel as a single monolithic structure starting from scratch, it is
built as a set of layers. The micro-kernel provides only the bare-bones
like Device-drivers, rudimentary filesystem support etc. on which,
depending on the intended area of application of the OS, it can be
customized to provide various higher level OS features like
Multiprocessing, IPC, etc.
Personal Questions in the second round --
--------------------------------------
1. Tell us about yourself, your background.
2. What does your father do currently.
3. Your performance in schooling, B.E.
4. Your +/- points.
5. Why do you think Wipro should take you.
6. What qualities do you have that make you a person suitable for going
into the IT industry (a corollary to the previous question).
7. What do your friends opine about you.
8. When do you think you will complete and be able to join.
9. How can you assure that you will join by that time.
10. Anything you want to know about us.
} /* End of for() */
a) Describe the memory management policies in Unix. How is paging
implemented? How page faults are handled?
Seems to be a favorite question for these chaps ---- Maurice Bach.
b) Write a macro in C for swapping two nibbles in a byte.
-Use the shift operators and be careful while defining temporary
variables( if you do so) as you have to write a macro. Otherwise
it is pretty simple.
c) What is the CPU-scheduling policy in Unix? - Round robin scheduling
with multilevel queues.
d) Diffrence between short term, long term and medium term scheduler.
-First two should be peaceful. The last one is also known as
swapper. (See Taenenbaum and/or Peterson)
e) Name various page-replacement policies. Which can be implemented
both with and without pre-emption? - see Peterson.
f) Describe the Sliding window protocol. What is it's advantage
over stop-and-wait? - Saves bandwidth. (Taenenbaum please)
2ND INTERVIEW (Both personal and technical interleaved)
a) Tell us something about yourself.
b) Aren't you going for higher studies abroad? Why?
c) Rank and CGPA. MSites do not have ranks but still they wanted to
know my approx position in my batch.
- Shady question. It is your job to convince them that for
MS, grades do not hold any meaning.
d) What is re-entrant code? --- Non-self modifying code. Can be
shared by many processes simultaneously. Gave e.g. of text-editors
like 'vi'.
Counter Q: But then no code modifies itself. What does 'non-self
modifying' mean? ---- I don't know for sure.
e) Diff between compilers and interpreters. Some fundaes about
how to link code in different files.
f) What would your friends tell us about you if we ask them?
Standard question for everyone.
Second interview: (fully personal) --- This was more interesting;-)
a) What did you feel about the ppt? --- wasn't very impressive
so gave some shady answer.
b) Have you heard of creativity? -- Ya.
Have you heard of Bernard Shaw? -- Ya.
(Then he rattled off some quote of BS regarding creativity)
What do you say? --- I put some shadiest fundaes regarding
visionaries and Leonardo da Vinci conceptualising Helicopters
in his time!
************************************************************************
NOTE: If you have been offered a job previously by any other company
after your BTech/BE or if you have even slightest of work experience
then make it a point to mention about it. It is a major plus point.
The interviewers will be definitely interested in knowing that some
other company also found you good enough to be selected.
************************************************************************
***************************************************************************
Personal Questions asked:
a)question
1. Tell me about urself, family background ..
2. Btech projects and M.S. projects
( spend more time here, even if u have not done much
workl; create a good impression)
3. Significant achievements in life.
( may be paper publications etc. )
4. Why did u leave ur previous company ( If u were working)
5. What do u expect from a company ?
( like how shd be the work environment etc. etc. )
************************************************************************
Technical Questions asked:
1. Explain your project
2. What are your areas of interest in Appli Prog
Personal Questions asked:
1. Introduce yourself
2. Why do you want to join INFOSYS
3. Do you have a passport
4. Have you taken GRE/TOEFL
5. Will you go abroad
6. Which prog is better - MTech or MS
7. Which prog do people prefer - MTech or MS
8. Why
Personal Questions asked:
a)Which other companies are you applying to?
in interview
a)question
my weakness, kinds of friendship, family details
b) response
They are impressed if one presents papers.
I have presented conference papers
in the national level.
Generally most of the companies asks about the project.
Regarding other technical questions, they put questions
on the courses I did.
B) Personal
-----------
i) Tell us something about yourself. (This has to be there)
ii) Strengths and weaknesses (This question also disguised in various
forms is always asked).
iii) Why should we hire you?
iv) Can you describe your project in short?
v) Why did you take 2-1/2 years to complete (My case!)
vi) If given the job when can you join. (Caution: Don't think that if
you give some unreal early deadlines they will offer you the job.
Always play safe and give a deadline by which time you are sure to
complete and join. Asking for extensions is the worst scenario).
Tips: Be confident, frank (But need not give away information which may weigh
against your case), free (use first names while addresing them, so be
alert when they introduce themselves) and cheerful (attend an interview
with a positive frame of mind). Remember you are IITians and you always
have an edge. That may sound arrogant, but its true.

PHYSCOMETRY TEST

Direction:
In this section you will find different questions with the same meaning. In all such questions your answer has to be same. for e.g.:

In being thrown by chance with a stranger, you wait for the person to introduce himself or herself.
(a) Yes (b) No (c) ?

It is difficult for you to chat about things in general with people.
(a) Yes (b) No (c) ?

These two questions have similar meanings. If you answer the first one 'NO' and the second one 'YES', i.e. if you differ in your answers to similar questions you lose marks for every question with the above meaning.

The choices to these questions are:
(a) Yes.
(b) No.
(c) ?

1. You start to work on a project with great deal of enthusiasm.
2. You would rather plan an activity than take part in it.
3. You have more than once taken lead in organizing project or a group of some kind.
4. You like to entertain guests.
5. Your interests change quickly from one thing to another.
6. When you eat a meal with others, you are usually one of the last to finish.
7. You believe in the idea that we should " eat, drink and be merry, for tomorrow we die."
8. When you find that something you have bought is defective, you hesitate to demand an exchange or a
refund.
9. You find it easy to find new acquaintances.
10. You are sometimes bubbling over with energy and sometimes very sluggish.
11. You are happiest when you get involved in some projects that calls for rapid action.
12. Other people think of you as being very serious minded.
13. In being thrown by chance with a stranger, you wait for the person to introduce himself or herself.
14. You like to take part in many social activities.
15. You sometimes feel "just miserable" for no good reason at all.
16. You are often so much " on the go" that sooner or later you may wear yourself out.
17. You like parties you attend to be lively.
18. If you hold an opinion that is radically different that expressed by a lecturer, you are likely to tell the
person about it either during or after the lecture.
19. It is difficult for you to chat about things in general with people.
20. You give little thought to your failures after they are passed.
21. You often wonder where others get all the excess energy they seem to have.
22. You are inclined to stop to think things over before you act.
23. You avoid arguing over a price with a clerk or sales person.
24. You would dislike very much to work alone in some alone place.
25. You often find it difficult to go to sleep at night because you keep thinking of what happened during the
day.
26. You find yourself hurrying to get to places even when there is plenty of time.
27. You like work that requires considerable attention to details.
28. You are satisfied to let some one else take the lead in group activities.
29. You enjoy getting acquainted with people.
30. It takes a lot to get you emotionally stirred up or excited.
31. You work more slowly and deliberately than most people of your sex and age.
32. You are a carefree individual.
33. When people do not play fair you hesitate to say anything about it to them.
34. It bothers you to have people watch you at your work.
35. You have usually been optimistic about your future.
36. You like to have plenty of time to stop and rest.
37. You take life very seriously.
38. You enjoy applying for a job in person.
39. You would like to be a host or hostess for parties at club.
40. You often feel uncomfortable or uneasy.
41. You are the kind of person who is "on the go" all the time.
42. You often crave excitement.
43. The thought of making a speech frightens you.
44. You find it easy to start conversation with strangers.
45. You often feel guilty without a very good reason for it.
46. People think you are a very energetic person.
47. You sometimes make quick decisions that you later wish you hadn't made.
48. You find it difficult to ask people for money or other donations, even for a cause in which you are
interested.
49. You are so naturally friendly that people immediately feel at ease with you.
50. You daydream a great deal.
51. You are quick in your actions.
52. You have a habit of starting things and then losing interest in them.
53. When you were a child many of your playmates naturally expected you to be the leader.
54. You sometimes avoid social contacts for fear of doing or saying the wrong thing.
55. You have frequent ups and downs in mood, sometimes with and sometimes without apparent cause.
56. You always seem to have plenty of vigour and vitality.
57. It is difficult for you to understand people who get very concerned about things.
58. When a clerk in a store waits on others who come after you, you call his or her attention to the fact.
59. You would be very unhappy if you were prevented from making numerous social contacts.
60. There are times when your future looks very dark.
61. You sometimes wish that people would slow down a bit and give you a chance to catch up.
62. Many of your friends think you take your work too seriously.
63. You hesitate to walk into a meeting when you know that everyone's eye will be upon you.
64. You limit your friendships mostly to members of your own sex.
65. You almost always feel well and strong.
66. You seem to lack the drive necessary to get as much as other people do.
67. You make decisions on the spur of the moment.
68. You are rather good at bluffing when you find yourself in difficulty.
69. After being introduced to someone , you just cannot think of things to say to make good conversation.
70. You feel lonesome even when with other people.
71. You are able to work for unusually long hours without feeling tired.
72. You often act on the first thought that comes into your head.
73. At the scene of an accident, you take an active part in helping out.
74. You have difficulty in making new friends.
75. Your mood often changes from happiness to sadness or vice versa without knowing why.
76. You talk more slowly than most people.
77. You like to play practical jokes upon others.
78. You take the lead in putting life into a dull party.
79. You would like to belong to as many clubs and social organizations as possible.
80. There are times when your mind seems to work very slowly and other times when it works very rapidly.
81. You like to do things slowly and deliberately.
82. You are a happy-go-lucky individual.
83. When you are served stale or inferior food in a restaurant, you say nothing about it.
84. You would rather apply for a job by writing a letter than by going through with a personal interview.
85. You are often in low spirits.
86. You are inclined to rush from one activity to another without pausing enough for rest.
87. You are so concerned about the future that you do not get as much fun out of the present as you might.
88. When you are attracted to a person whom you have not met earlier you make an active attempt to get
acquainted even though it may be quite difficult.
89. You are inclined to limit your acquaintances to select few
90. you seldom give your past mistakes a second thought.
91. You are less energetic than many people you know.
92. You often stop to analyzed your thoughts and feelings.
93. You speak out in meetings to oppose those whom you feel sure are wrong.
94. You are so shy it bothers you.
95. You are sometimes bothered by having a useless thought come into your mind over and over.
96. You get things in hurry.
97. It is difficult for you to understand how some people can be so unconcerned about the future.
98. You lie to sell things (i.e. to act as a sales person)
99. You are often "Life of the Party".
100. You find daydreaming very enjoyable.
101. At work or at play other people find it hard to keep up with the pace you set.
102. You can listen to a lecture without feeling restless.
103. You would rather work for a good boss than for yourself.
104. You can express yourself more easily in speech than in writing.
105. You keep in fairly uniform spirits.
106. You dislike to be hurried in your work.
107. You sometimes find yourself "crossing bridges before you come to them".
108. You find it somewhat difficult to say "no" to a sales person who tries to sell you something you do not
really want.
109. There are only a few friends with whom you can relax and have a good time.
110. You usually keep cheerful in spite of trouble.
111. People sometimes tell you to "slow down" or "take it easy".
112. You are one of those who drink or smoke more than they know they should.
113. When you think you recognize people you see in a public place, you ask them whether you have met
them before.
114. You prefer to work alone.
115. Disappointment affect you so little that you seldom think about them twice.
116. You are slow and deliberate in movements.
117. You like wild enthusiasm, sometimes to a point bordering on rowdyism at a football or baseball game.
118. You feel self conscious in the presence of important people.
119. People think of you as being a very social type of person.
120. You have often lost sleep over your worries.
121. You can turn out a large amount of work in a short time.
122. You keep at a task until it is done, even after nearly everyone else has given up.
123. You can think of a good excuse when you need one.
124. Other people say that it is difficult to get to know you well.
125. You daydreams are often about things that can never come true.
126. You often run upstairs taking two steps at a time.
127. You seldom let your responsibility interfere with your having a good time.
128. You like to take on important responsibilities such as organizing a new business.
129. You have hesitated to make or to accept "dates" because of shyness.
130. Your mood is very easily influenced by people around you.
131. Others are often amazed by the amount of work you turn out.
132. You generally feel as though you haven't a care in the world.
133. You find it difficult to get rid of sales person whom you do not care to listen or give your time.
134. You are a listener rather than a talker in a social conversation.
135. You almost always feel that life is very much worth living.
136. It irritates you to have to wait at a crossing for a long freight train to pass.
137. You usually say what you feel like saying at the moment.
138. You like to speak in public.
139. You like to be with people.
140. You generally keep cool and think clearly in exciting situations.
141. Other people regard you as a lively individual.
142. When you get angry, if you let yourself go, you feel better.
143. You seek to avoid all trouble with other people.
144. People seem to enjoy being with you.
145. You sometimes feel listless and tired for no good reason.
146. It is hard to understand why many people are so slow and get so little done.
147. You are fond of betting on horse races and games, whether you can afford it or not.
148. If someone you know has been spreading untrue and bad stories about you, you see the person as
soon as possible and have a talk about it.
149. Shyness keep you from being as popular as you should be.
150. You are generally free from worry about possible misfortunes.

QUANTITATIVE SECTION

Mphasis Quantitative Section Placement Paper



1.In a class composed of x girls and y boys what part of the class is composed of girls
A.y/(x + y)
B.x/xy
C.x/(x + y)
D.y/xy
Ans.C

2.What is the maximum number of half-pint bottles of cream that can be filled with a 4-gallon can of cream(2 pt.=1 qt. and 4 qt.=1 gal)
A.16
B.24
C.30
D.64
Ans.D

3.If the operation,^ is defined by the equation x ^ y = 2x + y,what is the value of a in 2 ^ a = a ^ 3
A.0
B.1
C.-1
D.4
Ans.B

4.A coffee shop blends 2 kinds of coffee,putting in 2 parts of a 33p. a gm. grade to 1 part of a 24p. a gm.If the mixture is changed to 1 part of the 33p. a gm. to 2 parts of the less expensive grade,how much will the shop save in blending 100 gms.
A.Rs.90
B.Rs.1.00
C.Rs.3.00
D.Rs.8.00
Ans.C

5.There are 200 questions on a 3 hr examination.Among these questions are 50 mathematics problems.It is suggested that twice as much time be spent on each maths problem as for each other question.How many minutes should be spent on mathematics problems
A.36
B.72
C.60
D.100
Ans.B

6.In a group of 15,7 have studied Latin, 8 have studied Greek, and 3 have not studied either.How many of these studied both Latin and Greek
A.0
B.3
C.4
D.5
Ans.B

7.If 13 = 13w/(1-w) ,then (2w)2 =
A.1/4
B.1/2
C.1
D.2
Ans.C

8. If a and b are positive integers and (a-b)/3.5 = 4/7, then
(A) b < a
(B) b > a
(C) b = a
(D) b >= a
Ans. A

9. In june a baseball team that played 60 games had won 30% of its game played. After a phenomenal winning streak this team raised its average to 50% .How many games must the team have won in a row to attain this average?
A. 12
B. 20
C. 24
D. 30
Ans. C

10. M men agree to purchase a gift for Rs. D. If three men drop out how much more will each have to contribute towards the purchase of the gift/
A. D/(M-3)
B. MD/3
C. M/(D-3)
D. 3D/(M2-3M)
Ans. D

11. A company contracts to paint 3 houses. Mr.Brown can paint a house in 6 days while Mr.Black would take 8 days and Mr.Blue 12 days. After 8 days Mr.Brown goes on vacation and Mr. Black begins to work for a period of 6 days. How many days will it take Mr.Blue to complete the contract?
A. 7
B. 8
C. 11
D. 12
Ans.C

12. 2 hours after a freight train leaves Delhi a passenger train leaves the same station travelling in the same direction at an average speed of 16 km/hr. After travelling 4 hrs the passenger train overtakes the freight train. The average speed of the freight train was?
A. 30
B. 40
C.58
D. 60
Ans. B

13. If 9x-3y=12 and 3x-5y=7 then 6x-2y = ?
A.-5
B. 4
C. 2
D. 8
Ans. D

Predict the output or error in c language

for the following:
1. void main()
{
int const * p=5;
printf("%d",++(*p));
}

Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
2. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}

Answer:
mmmm
aaaa
nnnn
Explanation:
s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].
3. main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Answer:
I hate U

Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .
4. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

Answer:
5 4 3 2 1

Explanation:
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.
5. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}

Answer:
2 2 2 2 2 2 3 4 6 5

Explanation:
Initially pointer c is assigned to both p and q. In the first loop, since only q is incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.
6. main()
{
extern int i;
i=20;
printf("%d",i);
}

Answer:
Linker Error : Undefined symbol '_i'
Explanation:
extern storage class in the following declaration,
extern int i;
specifies to the compiler that the memory for i is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name i is available in any other program with memory space allocated for it. Hence a linker error has occurred



Predict the output or error(s) for the following:
7.      main()
{
            int i=-1,j=-1,k=0,l=2,m;
            m=i++&&j++&&k++||l++;
            printf("%d %d %d %d %d",i,j,k,l,m);
}

Answer:
                        0 0 1 3 1

Explanation :
Logical operations always give a result of 1 or 0 . And also the logical AND (&&) operator has higher priority over the logical OR (||) operator. So the expression  ‘i++ && j++ && k++’ is executed first. The result of this expression is 0    (-1 && -1 && 0 = 0). Now the expression is 0 || 2 which evaluates to 1 (because OR operator always gives 1 except for ‘0 || 0’ combination- for which it gives 0). So the value of m is 1. The values of other variables are also incremented by 1.
8.      main()
{
            char *p;
            printf("%d %d ",sizeof(*p),sizeof(p));
}
 
Answer:
                        1 2

Explanation:
The sizeof() operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof(p) gives 2.
9.      main()
{
            int i=3;
            switch(i)
             {
                default:printf("zero");
                case 1: printf("one");
                           break;
               case 2:printf("two");
                          break;
              case 3: printf("three");
                          break;
              } 
}

Answer :
three

Explanation :
The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.
10.      main()
{
              printf("%x",-1<<4);
}

Answer:
fff0

Explanation :
-1 is internally represented as all 1's. When left shifted four times the least significant 4 bits are filled with 0's.The %x format specifier specifies that the integer value be printed as a hexadecimal value.
11.      main()
{
            char string[]="Hello World";
            display(string);
}
void display(char *string)
{
            printf("%s",string);
}

Answer:
Compiler Error : Type mismatch in redeclaration of function display

Explanation :
In third line, when the function display is encountered, the compiler doesn't know anything about the function display. It assumes the arguments and return types to be integers, (which is the default type). When it sees the actual function display, the arguments and type contradicts with what it has assumed previously. Hence a compile time error occurs.
12.      main()
{
            int c=- -2;
            printf("c=%d",c);
}

Answer:
                                    c=2;

Explanation:
Here unary minus (or negation) operator is used twice. Same maths  rules applies, ie. minus * minus= plus.
Note:
However you cannot give like --2. Because -- operator can  only be applied to variables as a decrement operator (eg., i--). 2 is a constant and not a variable.
13.      #define int char
main()
{
            int i=65;
            printf("sizeof(i)=%d",sizeof(i));
}

Answer:
                        sizeof(i)=1

Explanation:
Since the #define replaces the string  int by the macro char
14.      main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}

Answer:
i=0

Explanation:
In the expression !i>14 , NOT (!) operator has more precedence than ‘ >’ symbol.  ! is a unary logical operator. !i (!10) is 0 (not of true is false).  0>14 is false (zero).
Predict the output or error(s) for the following:
15.      #include
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}

Answer:
77       

Explanation:
p is pointing to character '\n'. str1 is pointing to character 'a' ++*p. "p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10, which is then incremented to 11. The value of ++*p is 11. ++*str1, str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98.
 Now performing (11 + 98 – 32), we get 77("M");
 So we get the output 77 :: "M" (Ascii is 77).
16.      #include
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}

Answer:
SomeGarbageValue---1

Explanation:
p=&a[2][2][2]  you declare only two 2D arrays, but you are trying to access the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of a is assigned integer pointer. Now q is pointing to starting address of a. If you print *q, it will print first element of 3D array.
17.      #include
main()
{
struct xx
{
      int x=3;
      char name[]="hello";
 };
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}

Answer:
Compiler Error

Explanation:
You should not initialize variables in declaration
18.      #include
main()
{
struct xx
{
int x;
struct yy
{
char s;
            struct xx *p;
};
struct yy *q;
};
}

Answer:
Compiler Error

Explanation:
The structure yy is nested within structure xx. Hence, the elements are of yy are to be accessed through the instance of structure xx, which needs an instance of yy to be known. If the instance is created after defining the structure the compiler will not know about the instance relative to xx. Hence for nested structure yy you have to declare member.
19.      main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}

Answer:
hai

Explanation:
\n  - newline
\b  - backspace
\r  - linefeed
20.      main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}

Answer:
45545

Explanation:
The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the  evaluation is from right to left, hence the result.
21.      #define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}

Answer:
64

Explanation:
the macro call square(4) will substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64
22.      main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s   %s",p,p1);
}

Answer:
ibj!gsjfoet

Explanation:
                        ++*p++ will be parse in the given order
Ø  *p that is value at the location currently pointed by p will be taken
Ø  ++*p the retrieved value will be incremented
Ø  when ; is encountered the location will be incremented that is p++ will be executed
Hence, in the while loop initial value pointed by p is ‘h’, which is changed to ‘i’ by executing ++*p and pointer moves to point, ‘a’ which is similarly changed to ‘b’ and so on. Similarly blank space is converted to ‘!’. Thus, we obtain value in p becomes “ibj!gsjfoet” and since p reaches ‘\0’ and p1 points to p thus p1doesnot print anything.
23.      #include
#define a 10
main()
{
#define a 50
printf("%d",a);
}

Answer:
50

Explanation:
The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value will be taken.
24.      #define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
}

Answer:
100

Explanation:
Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input  program to compiler looks like this :
                        main()
                        {
                             100;
                             printf("%d\n",100);
                        }
            Note:  
100; is an executable statement but with no action. So it doesn't give any problem
Predict the output or error(s) for the following:
25.   main()
{
printf("%p",main);
}

Answer:
                        Some address will be printed.

Explanation:
            Function names are just addresses (just like array names are addresses).
main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers.
26.       main()
{
clrscr();
}
clrscr();
           
Answer:
No output/error

Explanation:
The first clrscr() occurs inside a function. So it becomes a function call. In the second clrscr(); is a function declaration (because it is not inside any function).
27.       enum colors {BLACK,BLUE,GREEN}
 main()
{
 
 printf("%d..%d..%d",BLACK,BLUE,GREEN);
  
 return(1);
}

Answer:
0..1..2

Explanation:
enum assigns numbers starting from 0, if not explicitly defined.
28.       void main()
{
 char far *farther,*farthest;
 
 printf("%d..%d",sizeof(farther),sizeof(farthest));
  
 }

Answer:
4..2 

Explanation:
            the second pointer is of char type and not a far pointer
29.       main()
{
 int i=400,j=300;
 printf("%d..%d");
}

Answer:
400..300

Explanation:
printf takes the values of the first two assignments of the program. Any number of printf's may be given. All of them take only the first two values. If more number of assignments given in the program, then printf will take garbage values.
30.       main()
{
 char *p;
 p="Hello";
 printf("%c\n",*&*p);
}

Answer:
H

Explanation:
* is a dereference operator & is a reference  operator. They can be    applied any number of times provided it is meaningful. Here  p points to  the first character in the string "Hello". *p dereferences it and so its value is H. Again  & references it to an address and * dereferences it to the value H.
31.       main()
{
    int i=1;
    while (i<=5)
    {
       printf("%d",i);
       if (i>2)
              goto here;
       i++;
    }
}
fun()
{
   here:
     printf("PP");
}

Answer:
Compiler error: Undefined label 'here' in function main

Explanation:
Labels have functions scope, in other words The scope of the labels is limited to functions . The label 'here' is available in function fun() Hence it is not visible in function main.
32.       main()
{
   static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
    int i;
    char *t;
    t=names[3];
    names[3]=names[4];
    names[4]=t;
    for (i=0;i<=4;i++)
            printf("%s",names[i]);
}

Answer:
Compiler error: Lvalue required in function main

Explanation:
Array names are pointer constants. So it cannot be modified.
33.     void main()
{
            int i=5;
            printf("%d",i++ + ++i);
}

Answer:
Output Cannot be predicted  exactly.

Explanation:
Side effects are involved in the evaluation of   i
34.       void main()
{
            int i=5;
            printf("%d",i+++++i);
}

Answer:
Compiler Error

Explanation:
The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.
35.       #include
main()
{
int i=1,j=2;
switch(i)
 {
 case 1:  printf("GOOD");
                break;
 case j:  printf("BAD");
               break;
 }
}

Answer:
Compiler Error: Constant expression required in function main.

Explanation:
The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).
            Note:
Enumerated types can be used in case statements.


Predict the output or error(s) for the following:
36.    main()
{
int i;
printf("%d",scanf("%d",&i));  // value 10 is given as input here
}

Answer:
1

Explanation:
Scanf returns number of items successfully read and not 1/0.  Here 10 is given as input which should have been scanned successfully. So number of items read is 1.
37.       #define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
            }

Answer:
100
38.      main()
{
int i=0;
 
for(;i++;printf("%d",i)) ;
printf("%d",i);
}

Answer:
            1

Explanation:
before entering into the for loop the checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).
39.       #include
main()
{
  char s[]={'a','b','c','\n','c','\0'};
  char *p,*str,*str1;
  p=&s[3];
  str=p;
  str1=s;
  printf("%d",++*p + ++*str1-32);
}

Answer:
M

Explanation:
p is pointing to character '\n'.str1 is pointing to character 'a' ++*p meAnswer:"p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10. then it is incremented to 11. the value of ++*p is 11. ++*str1 meAnswer:"str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98. both 11 and 98 is added and result is subtracted from 32.
i.e. (11+98-32)=77("M");
40.       #include
main()
{
  struct xx
   {
      int x=3;
      char name[]="hello";
   };
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

Answer:
Compiler Error

Explanation:
Initialization should not be done for structure members inside the structure declaration
41.       #include
main()
{
struct xx
 {
              int x;
              struct yy
               {
                 char s;
                 struct xx *p;
               };
                         struct yy *q;
            };
            }

Answer:
Compiler Error

Explanation:
in the end of nested structure yy a member have to be declared
42.       main()
{
 extern int i;
 i=20;
 printf("%d",sizeof(i));
}

Answer:
Linker error: undefined symbol '_i'.

Explanation:
extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.
43.       main()
{
printf("%d", out);
}

int out=100;
Answer:
Compiler error: undefined symbol out in function main.

Explanation:
The rule is that a variable is available for use from the point of declaration. Even though a is a global variable, it is not available for main. Hence an error.
Predict the output or error(s) for the following:
44.    main()
{
 extern out;
 printf("%d", out);
}
 int out=100;

Answer:
100     

            Explanation:  
This is the correct way of writing the previous program.
45.       main()
{
 show();
}
void show()
{
 printf("I'm the greatest");
}

Answer:
Compier error: Type mismatch in redeclaration of show.

Explanation:
When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error.
The solutions are as follows:
1. declare void show() in main() .
2. define show() before main().
3. declare extern void show() before the use of show().
46.  main( )
{
  int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
  printf(“%u %u %u %d \n”,a,*a,**a,***a);
        printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);
       }

Answer:
100, 100, 100, 2
114, 104, 102, 3
47.   main( )
{
  int a[ ] = {10,20,30,40,50},j,*p;
  for(j=0; j<5; j++)
    {
printf(“%d” ,*a);
a++;
    }
    p = a;
   for(j=0; j<5; j++)
      {
printf(“%d ” ,*p);
p++;
      }
 }

Answer:
Compiler error: lvalue required.
                       
Explanation:
Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for the any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue.
48.       main( )
{
 static int  a[ ]   = {0,1,2,3,4};
 int  *p[ ] = {a,a+1,a+2,a+3,a+4};
 int  **ptr =  p;
 ptr++;
 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
 *ptr++;
 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
 *++ptr;
 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
 ++*ptr;
       printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);
}

Answer:
            111
            222
            333
            344
49.       main( )
{
 void *vp;
 char ch = ‘g’, *cp = “goofy”;
 int j = 20;
 vp = &ch;
 printf(“%c”, *(char *)vp);
 vp = &j;
 printf(“%d”,*(int *)vp);
 vp = cp;
 printf(“%s”,(char *)vp + 3);
}

Answer:
            g20fy

Explanation:
Since a void pointer is used it can be type casted to any  other type pointer. vp = &ch  stores address of char ch and the next statement prints the value stored in vp after type casting it to the proper data type pointer. the output is ‘g’. Similarly  the output from second printf is ‘20’. The third printf statement type casts it to print the string from the 4th value hence the output is ‘fy’.
50.    main ( )
{
 static char *s[ ]  = {“black”, “white”, “yellow”, “violet”};
 char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
 p = ptr;
 **++p;
 printf(“%s”,*--*++p + 3);
}

Answer:
            ck

Explanation:
In this problem we have an array of char pointers pointing to start of 4 strings. Then we have ptr which is a pointer to a pointer of type char and a variable p which is a pointer to a pointer to a pointer of type char. p hold the initial value of ptr, i.e. p = s+3. The next statement increment value in p by 1 , thus now value of p =  s+2. In the printf statement the expression is evaluated *++p causes gets value s+1 then the pre decrement is executed and we get s+1 – 1 = s . the indirection operator now gets the value from the array of s and adds 3 to the starting address. The string is printed starting from this position. Thus, the output is ‘ck’.
51.    main()
{
 int  i, n;
 char *x = “girl”;
 n = strlen(x);
 *x = x[n];
 for(i=0; i
   {
printf(“%s\n”,x);
x++;
   }
 }

Answer:
(blank space)
irl
rl
l
 
Explanation:
Here a string (a pointer to char) is initialized with a value “girl”.  The strlen function returns the length of the string, thus n has a value 4. The next statement assigns value at the nth location (‘\0’) to the first location. Now the string becomes “\0irl” . Now the printf statement prints the string after each iteration it increments it starting position.  Loop starts from 0 to 4. The first time x[0] = ‘\0’ hence it prints nothing and pointer value is incremented. The second time it prints from x[1] i.e “irl” and the third time it prints “rl” and the last time it prints “l” and the loop terminates
52.     int i,j;
            for(i=0;i<=10;i++)
            {
            j+=5;
            assert(i<5);
            }

Answer:
Runtime error: Abnormal program termination.
                                    assert failed (i<5), ,

Explanation:
asserts are used during debugging to make sure that certain conditions are satisfied. If assertion fails, the program will terminate reporting the same. After debugging use,
            #undef NDEBUG
and this will disable all the assertions from the source code. Assertion
is a good debugging tool to make use of. 
53.       main()
            {
            int i=-1;
            +i;
            printf("i = %d, +i = %d \n",i,+i);
            }

Answer:
 i = -1, +i = -1

Explanation:
Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator).
54. What are the files which are automatically opened when a C file is executed?
Answer:
stdin, stdout, stderr (standard input,standard output,standard error).
55.  what will be the position of the file marker?
            a: fseek(ptr,0,SEEK_SET);
            b: fseek(ptr,0,SEEK_CUR);
 
Answer :
            a: The SEEK_SET sets the file position marker to the starting of the file.
                        b: The SEEK_CUR sets the file position marker to the current position
            of the file.
56.       main()
            {
            char name[10],s[12];
            scanf(" \"%[^\"]\"",s);
            }
            How scanf will execute?
Answer:
First it checks for the leading white space and discards it.Then it matches with a quotation mark and then it  reads all character upto another quotation mark.
57.       What is the problem with the following code segment?
            while ((fgets(receiving array,50,file_ptr)) != EOF)
                                    ;
Answer & Explanation:
fgets returns a pointer. So the correct end of file check is checking for != NULL.
58.   main()
            {
            main();
            }

Answer:
 Runtime error : Stack overflow.

Explanation:
main function calls itself again and again. Each time the function is called its return address is stored in the call stack. Since there is no condition to terminate the function call, the call stack overflows at runtime. So it terminates the program and results in an error.
59.      main()
            {
            char *cptr,c;
            void *vptr,v;
            c=10;  v=0;
            cptr=&c; vptr=&v;
            printf("%c%v",c,v);
            }

Answer:
Compiler error (at line number 4): size of v is Unknown.

Explanation:
You can create a variable of type void * but not of type void, since void is an empty type. In the second line you are creating variable vptr of type void * and v of type void hence an error.
60.       main()
            {
            char *str1="abcd";
            char str2[]="abcd";
            printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
            }

Answer:
2 5 5

Explanation:
In first sizeof, str1 is a character pointer so it gives you the size of the pointer variable. In second sizeof the name str2 indicates the name of the array whose size is 5 (including the '\0' termination character). The third sizeof is similar to the second one.
61.      main()
            {
            char not;
            not=!2;
            printf("%d",not);
            }

Answer:
0

Explanation:
! is a logical operator. In C the value 0 is considered to be the boolean value FALSE, and any non-zero value is considered to be the boolean value TRUE. Here 2 is a non-zero value so TRUE. !TRUE is FALSE (0) so it prints 0.
62.       #define FALSE -1
            #define TRUE   1
            #define NULL   0
            main() {
               if(NULL)
                        puts("NULL");
               else if(FALSE)
                        puts("TRUE");
               else
                        puts("FALSE");
               }

Answer:
TRUE

Explanation:
The input program to the compiler after processing by the preprocessor is,
            main(){
                        if(0)
                                    puts("NULL");
            else if(-1)
                                    puts("TRUE");
            else
                                    puts("FALSE");
                        }
Preprocessor doesn't replace the values given inside the double quotes. The check by if condition is boolean value false so it goes to else. In second if -1 is boolean value true hence "TRUE" is printed.
63.     main()
            {
            int k=1;
            printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
            }

Answer:
1==1 is TRUE

Explanation:
When two strings are placed together (or separated by white-space) they are concatenated (this is called as "stringization" operation). So the string is as if it is given as "%d==1 is %s". The conditional operator( ?: ) evaluates to "TRUE".
64.       main()
            {
            int y;
            scanf("%d",&y); // input given is 2000
            if( (y%4==0 && y%100 != 0) || y%100 == 0 )
                 printf("%d is a leap year");
            else
                 printf("%d is not a leap year");
            }

Answer:
2000 is a leap year

Explanation:
An ordinary program to check if leap year or not.
65.       #define max 5
            #define int arr1[max]
            main()
            {
            typedef char arr2[max];
            arr1 list={0,1,2,3,4};
            arr2 name="name";
            printf("%d %s",list[0],name);
            }

Answer:
Compiler error (in the line arr1 list = {0,1,2,3,4})

Explanation:
arr2 is declared of type array of size 5 of characters. So it can be used to declare the variable name of the type arr2. But it is not the case of arr1. Hence an error.
Rule of Thumb:
#defines are used for textual replacement whereas typedefs are used for declaring new types.
66.       int i=10;
            main()
            {
             extern int i;
              {
                 int i=20;
                        {
                         const volatile unsigned i=30;
                         printf("%d",i);
                        }
                  printf("%d",i);
               }
            printf("%d",i);
            }

Answer:
30,20,10

Explanation:
'{' introduces new block and thus new scope. In the innermost block i is declared as,
            const volatile unsigned
which is a valid declaration. i is assumed of type int. So printf prints 30. In the next block, i has value 20 and so printf prints 20. In the outermost block, i is declared as extern, so no storage space is allocated for it. After compilation is over the linker resolves it to global variable i (since it is the only variable visible there). So it prints i's value as 10.
67.       main()
            {
                int *j;
                {
                 int i=10;
                 j=&i;
                 }
                 printf("%d",*j);
}

Answer:
10

Explanation:
The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i is still allocated space, *j prints the value stored in i since j points i.
68.      main()
            {
            int i=-1;
            -i;
            printf("i = %d, -i = %d \n",i,-i);
            }

Answer:
i = -1, -i = 1

Explanation:
-i is executed and this execution doesn't affect the value of i. In printf first you just print the value of i. After that the value of the expression -i = -(-1) is printed.
69.       #include
main()
 {
   const int i=4;
   float j;
   j = ++i;
   printf("%d  %f", i,++j);
 }

Answer:
Compiler error

Explanation:
i is a constant. you cannot change the value of constant
70.       #include
main()
{
  int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };
  int *p,*q;
  p=&a[2][2][2];
  *q=***a;
  printf("%d..%d",*p,*q);
}

Answer:
garbagevalue..1

Explanation:
p=&a[2][2][2]  you declare only two 2D arrays. but you are trying to access the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of a is assigned integer pointer. now q is pointing to starting address of a.if you print *q meAnswer:it will print first element of 3D array.
71.      #include
main()
  {
    register i=5;
    char j[]= "hello";                    
     printf("%s  %d",j,i);
}

Answer:
hello 5

Explanation:
if you declare i as register  compiler will treat it as ordinary integer and it will take integer value. i value may be  stored  either in register  or in memory.
72.      main()
{
              int i=5,j=6,z;
              printf("%d",i+++j);
             }

Answer:
11

Explanation:
the expression i+++j is treated as (i++ + j)   

Infosys Interview Puzzles

KEEP IN MIND THAT THESE ANSWERS MAY NOT BE 100% CORRECT. TRY TO SOLVE IT YOURSELF.
 
1. You are given two candles of equal size, which can burn 1 hour each. You have
to measure 90 minutes with these candles. (There is no scale or clock). Also u r
given a lighter.
 
Ans: 1. First light up the two ends of the 1st candle. When it will burn out light up
one end of the second candle.   (30+60=90)
 
2. Try the similar problem to measure 45 minutes.
 
Ans: First light-up the two ends of the 1st candle and one end of the 2nd candle.
When the 1st candle will burn out ,then light up the both ends of the 2nd  candle
(15+30=45)
 
3. You r given a thermometer. What can u do by this without measuring the
temperature?
 
Ans: if u put thermometer into a tree it won’t grow anymore, will just die off
 
4. How it is possible to place four points that are equidistance from each other?
 
OR
U r a landscape designer and your boss asked u to design a landscape such
that you should place 4 trees equidistance from each other.
(Distance from each tree to the other must be same)
 
Ans: Only 3 points can be equidistant from each other. But if u place points in the
shape of a pyramid then its possible
 
5. You are given a cake; one of its corner is broken. How will u cut the rest into
Two equal parts?
 
Ans: Slice the cake
 
6. How will you recognize the magnet & magnetic material & non-magnetic material?
 
Ans: Drag one piece of material over another. There is no attractive force in the
middle portion of the magnet.        
 
OR
Get a piece of thread and tie up with the one bar and check for poles. If it iron bar
then it moves freely and if it is magnetic bar then it fix in one direction according to
poles.
 
7. If one tyre of a car suddenly gets stolen.... and after sometime u find the tyre
without the screws how will u make ur journey complete?
 
Ans: Open 3 screws, 1 from each tyre and fix the tyre.
 
8. How can u measure a room height using a thermometer?
 
Ans: temp varies with height. but its dependent on various other factors like
humidity, wind etc.
 
9. What is the height of room if after entering the room with a watch ur head
strikes a hanging bulb?
 
Ans: Oscillate the hanging bulb. Calculate the time period for one complete
oscillation by Simple Harmonic Motion (SHM) of the handing bulb. Put it in the
formula T=2 * 3.14 * (L/G)^1/2
L will be the length of the hanging thread.
Add the L with ur height to get the height of the room.
 
OR
Ans: Drop it from the room and find the time at which it strikes the floor. Using
physics formula  s = (at^2)/2 (IM NOT SURE ABOUT THIS ONE)
 
10. Color of bear.... if it falls from 1m height in 1s.
 
Ans: We get 'g' perfect 10 which is only in poles...hence polar bear...color White
 
11. How will you measure height of building when you are at the top of the building?
And if you have stone with you.
 
Ans: Drop the stone and find the time taken for the stone to reach the ground. find
height using the formula
s = a + gt ( s = height, a= initial velocity=0, g=9.8m/s, t = time taken)
 
12. How wud u catch and receive a ball in same direction? (Dropping is from north
And receiving from bottom not accepted, as it is 2 directions)
 
Ans: ?
 
13. 25 statements given. Some tell truth, some false and some alternators. Find out
the true statements.
 
Ans: ?
 
14. Can u make 120 with 5 zeros?
 
Ans: Factorial (factorial (0)+factorial (0)+factorial (0)+factorial (0)+factorial (0)) =
120
 
15.There are three people A, B, C. Liars are of same type and Truth speaking people
are of same type. Find out who is speaking truth and who is speaking false from the
following statements:
 
a)       A says: B is a liar.
b)       B says: A and C are of same type.
 
Ans: lets assume A is speaking truth. It means B is a liar then it means A and C are
not of same type.
 
16.5 swimmers A, B, C, E, F and many conditions of their positions like there are
Two b/w A & F, B doesn't win etc the question was to find who was b/w like E & D?
 
Ans: ?
 
17. in a race u drove 1st lap with 40kmph and in the second lap at what speed u
must drive so that ur average speed must be 80kmph.
 
Ans: its impossible! if u drove the first lap in 40 kmph, its impossible that the
average speed of both the laps is 80kmph.
 
for eg. consider one lap distance = 80km.
time req. to cover 1 lap = 80km/40kmph = 2 hrs.
 
if the avg. speed is 80kmph, then the total time would have taken =
160kms/80kmph = 2 hrs.
 
same is the case with any other distance u consider. so the avg to be 80kmph is
impossible
 
18. You have to draw 3 concentric circles with a line passing thru their center
without lifting hand. 
 
Ans: Start the line complete one circle move inside circles along the line and then
draw second circle. Like wise rest.
 
19. A rectangular paper is there. At a corner a rectangular size paper is taken from
it. Now you have to cut the remaining paper into two equal halves.
 
Ans: try it on the paper. You must fold the part that has complete paper and select
Half of it and then fold the part that cut and selects half of it and then cut along
the folding. (I DONT UNDERSTAND THIS ONE!!)
 
20. Value of (x-a)(x-b)………..(x-z)
 
Ans: 0 as there’s X-X term
 
21. There are 9 coins. 8 are of 1 gm and 1 is of 2 grams. How will you find out the
heavier coin in minimum number of weighing and how many weighing it will need?
 
Ans: 2 weighing ( Divide the number of coins into 3 parts at each weighing)

First Interview

Me: Good afternoon sir, May I come in?
HR: Yes , and be seated.
Me: Thank you sir.
HR: R u tired for waiting long time?
Me: Not at all sir.
HR: What is the meaning of your name?
Me: Told
HR: Show your group work capability.
Me: Told about the project.
HR: Which quality of a leader do you find in yourself.
Me: Told about my cooperation, taking on challenges, etc.
HR: What was the crucial decision in your life that changed yourself?
Me: Told something. I hadnt prepared. Say anything positive.
Questions on teamwork and leadership.

Second interview
HR: Sorry for taking your second interview.
Me: My pleasure sir. ( Show good behaviour )
HR: What is your week point?
HR: What is your reaction when one rectify ur week points?
HR: How do you react when a misunderstanding happens in group work?
HR: Give some example on you real life.
Etc.
HR: what is your favourite (best) subject?
Now few questions about your best subject. Tell any subject (they dont care much about it)
So they may ask you to tell about anything currently going on in that field.
HR: nice interview.

COBOL QUESTION AND ANSWERS

COBOL QUESTION AND ANSWERS

1.The C language terminator is
a.semicolon
b.colon
c.period
d.exclamation mark
2.What is false about the following
A compound statement is
a.A set of simple statments
b.Demarcated on either side by curly brackets
c.Can be used in place of simple statement
d.A C function is not a compound statement.
3.What is true about the following
C Functions
a.Need not return any value
b.Should always return an integer
c.Should always return a float
d.Should always return more than one value.
4.Main must be written as
a.the first function in the program
b.Second function in the program
c.Last function in the program
d.any where in the program
5.Which of the following about automatic variables within a function
is correct ?
a.its type must be declared before using the variable
b.they are local
c.they are not initialised to zero
d.they are global.
6.Write one statement equalent to the following two statements
x=sqr(a);
return(x);
Choose from one of the alternatives
a.return(sqr(a));
b.printf("sqr(a)");
c.return(a*a*a);
d.printf("%d",sqr(a));
7.Which of the following about the C comments is incorrect ?
a.commentscan go over multiple lines
b.comments can start any where in the line
c.a line can contain comments with out any language statements
d.comments can occur within comments
8.What is the value of y in the following code?
x=7;y=0;
if(x=6)
y=7;
else
y=1;
a.7
b.0
c.1
d.6
9.Read the function conv() given below
conv(int t)
{
int u;
u=5/9 * (t-32);
return(u0;
}
What
a.15
b.0
c.16.1
d.29
10.which of the following represents true statement
either x is inthe range of 10 and 50 or y is zero
a.x>=10 && x<=50 || y==0;
b.
c.
d.
11.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){
....
}
12.what does the following function print?
func(int i)
{
if(i%2)return 0;
eale return 1;
}
main()
{
int =3;
i=func(i);
i=func(i);
printf("%d",i);}
a.3
b.1
c.0
d.2
13.how does the C compiler interpret the following two statements
p=p+x;
q=q+y;
a.p=p+x;
q=q+y
b.p=p+xq=q+y
c.p=p+xq;
q=q+y
d.p=p+x/q=q+y

For questions 14,15,16,17 use the following alternatives

a.int
b.char
c.string
d.float
14.'9'
15."1 e 02"
16.10e05
17. 15

18.read the folllowing code
# define MAX 100
# define MIN 100
....
....
if(x>MAX)
x=1;
else if(x x=-1;
x=50;
if the initial value of x=200,what is the vlaue after executing this code?
a.200
b.1
c.-1
d.50
19.a memory of 20 bytes is allocated to a string declared as char *s
then the following two statements are executed:
s="Etrance"
l=strlen(s);
what is the value of l ?
a.20
b.8
c.9
d.21
20.given the piece of code
int a[50];
int *pa;
pa=a;
to access the 6th element of the array which of the following is incorrect?
a.*(a+5)
b.a[5]
c.pa[5]
d.*(*pa + 5)
21.consider the following structure:
struct num nam{
int no;
char name[25];
};
struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}};
.....
.....
printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1);
What does the above statement print?
a.8,9
b.9,9
c.8,8
d.8,unpredictable value
22.identify the in correct expression
a.a=b=3=4;
b.a=b=c=d=0;
float a=int b=3.5;
d.int a;
float b;
a=b=3.5;
23.regarding the scope of the varibles;identify the incorrect statement:
a.automatic variables are automatically initialised to 0
b.static variables are are automatically initialised to 0
c.the address of a register variable is not accessiable
d.static variables cannot be initialised with any expression
24.cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4;
is equivalent to which of the following?
a.if cond 1
exp 1;
else if cond 2
exp 2;
else if cond 3
exp 3;
else
exp 4;
b.if cond 1
if cond 2
if cond 3
exp 1;
else
exp 2;
else
exp 3;
else
exp 4;
c.if cond 1 && cond 2 && cond 3
exp 1 |exp 2|exp 3|exp 4;
d.if cond 3
exp 1;
else if cond 2
exp 2;
else if cond 3
exp 3;
else
exp 4;
25.the operator for exponencation is
a.**
b.^
c.%
d.not available
26.which of the following is invalid
a.a+=b
b.a*=b
c.a>>=b
d.a**=b
27.what is y value of the code if input x=10
y=5;
if (x==10)
else if(x==9)
elae y=8;
a.9
b.8
c.6
d.7
28.what does the following code do?
fn(int n,int p,int r)
{
static int a=p;
switch(n){
case 4:a+=a*r;
case 3:a+=a*r;
case 2:a+=a*r;
case 1:a+=a*r;
}
}
a.computes simple interest for one year
b.computes amount on compound interest for 1 to 4 years
c.computes simple interest for four year
d.computes compound interst for 1 year
29.a=0;
while(a<5 br=""> printf("%d\n",a++);
how many times does the loop occurs?
a.infinite
b.5
c.4
d.6
30.how many times does the loop iterated ?
for (i=0;i=10;i+=2)
printf("Hi\n");
a.10
b.2
c.5
d.....
31.what is incorrect among teh following
A recursive functiion
a.calls itself
b.is equivalent to a loop
c.has a termination cond
d.does not have a return value at all
32.which of the following go out of the loopo if expn 2 becoming false
a.while(expn 1){...if(expn 2)continue;}
b.while(!expn 1){if(expn 2)continue;...}
c.do{..if(expn 1)continue;..}while(expn 2);
d.while(!expn 2){if(expn 1)continue;..}
33.consider the following program
B
main()
OB {unsigned int i=10;
while(i>=0){
printf("%u",i)
i--;
}
}
how many times the loop wxecuted
a.10
b.9
c.11
d.infinite
34.pick out the add one out
a.malloc()
b.calloc()
c.free()
d.realloc()
35.consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
the value of b[-1] is
a.1
b.3
c.-6
d.none
36.# define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10)); }

the output of the program is
a.8
b.6
c.7
d.none
37.consider the following program sigment
int n,sum=1;
switch(n) {
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;}
if n=2, what is the value of sum
a.0
b.6
c.3
d.none
38.identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a 4.if(c==1)
a.1 only
b.1&3
c.3 only
d.all
39.teh format specified for hexa decimal is
a.%d
b.%o
c.%x
d.%u
40.find the output of the following program
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
a.5
b.6
c.0
d.none
41.consider the following C code
main()
{
int i=3,x;
while(i>0)
{
x=func(i);
i--;
}
int func(int n)
{
static sum=0;
sum=sum+n;
return(sum);
}
the final value of x is
a.6
b.8
c.1
d.3
43.int *a[5] refers to
a.array of pointers
b.pointer to an array
c.pointerto a pointer
d......
46.which of the following statements is incorrect
a.typedef struct new{
int n1;
char n2;
} DATA;
b.typedef struct {
int n3;
char *n4;
}ICE;
c.typedef union {
int n5;
float n6;
} UDT;
d.#typedef union {
int n7;
float n8;
} TUDAT;

********************************************************************************
Only These Are The Questions Avilable For C Paper.

********************************************************************************
ANSWERS:
-----------

1-5 D,C,D,C,C

6-10 D,C,C,A,D

11-15 D,C,A,A,A

16-20 B,C,D,C,A

21-25 C,D,B,D,A

26-30 C,B,B,A,D

31-35 B,C,C,C,B

36-40 A,B,A,B,B

41-45 A,D,D,D,A

46-50 B,C,C,A,A


This the COBOL paper.

01.consider the following piece of code

01 GROSS-PAY
05 BASIC-PAY PIC 9(5)
05 ALLOWENCES PIC 9(3)
if BASIC-PAY has a value 1000 and ALLOWENCES has a value of 250,what will be
displayed by the statement
DISPLAY GROSS-PAY
a.1250
b.01000250
c.01250
d.1.250
02.consider two data items

77 W-A PIC 9(3)V99 VALUE 23.75
77 W-B PIC ZZ9V99 VLAUE 123.45
after the statement
MOVE W-A TO W-B
what will be W-B's value?
a.123.75
b.b23.75 (where b indicates space)
c.023.75
d.invalid move
03.what is the result of the following?

DIVIDE A INTO B GIVING C.

a.C=A/B
b.the reminder of B/A is stored in C
c.C=B/A
d.the reminder of A/B is stored in C
04.consider the statement (incomplete)
IF(A NUMERIC)
DISPLAY A
the variable A can be
a.NUMERIC
b.ALPHABETIC
c.ALPHANUMERIC
d.NUMERIC OR ALPHANUMERIC
05.which of the following can be used as a check protection symbol
a.Z
b.S
c.*
d.+
06.what if any ,is the syntex error in the following piece of code
01 B PIC A(7)
02 C PIC 9(4)
........
IF(B NUMERIC)
ADD 10 TO C
a.the condition in the if statement is wrong
b.noting is wrong
c.because C is initialised.ADD 10 TO C is wrong
d.both B and C shoud have same size.
07.study the following code
01 A1
05 B PIC 99
05 C PIC X(4)
01 A2
05 B PIC 99V99
05 C PIC A(4)
pick out the valid statement from the following
a.A1 and A2 can not have sub-ordinates
b.A1 and A2 can have the same sub-ordinates but must have same PIC clause
c.there is nothing wrong
d.A1 and A2 can have same sub-ordinates provided they are not at 01 level
08.study the following
01 A PIC 99V0 VALUE 5
01 B PIC 9V9 VALUE 6
01 C PIC 99V9 VALUE 2.5
01 D PIC 99 VALUE 3
COMPUTE A ROUNDED B C = A+B*C/D
ON SIZE ERROR PERFORM PRINT-ERROR
the comments of A.B.C after execution of the above statement are
a.A=10 B=0 C=10
b.A=10 B=9.9 C=9.9
c.A=10 B=0 C=9.9
d.A=10 B=6 C=10
09.how many times PARA-A is performed :
PERFORM PARA-A VARYING TIMES-COUNTER FROM 1 BY 1
UNTIL TIMES-COUNTER >0
PARA-A
MOVE P TO Q
MOVE H TO TIMES COUNTER
a.10
b.1
c.11
d.0
10.consider the following piece of code
01 GROUP-ITEM
05 AMOUNT-1 PIC 99V9 USAGE COMP VALUE 50
05 AMOUNT-2 PIC 9(4)V99 USAGE COMP
MOVE ZERO TO GROUP-ITEM
ADD 50 TO AMOUNT-1
what will be the content of AMOUNT-1?
a.50
b.100
c.0
d.unpredictable
11.consider the following progrm statements
MOVE 0 TO SW.NO.OF.REC
PERFORM PRI-OUT UNTIL SW=1
DISPALY NO.OF.REC
STOP RUN
PRE-OUT
READ IN-FILE AT END
MOVE 1 TO SW
WRITE OUO-REC FROM IN-REC
ADD 1 TO NO.OF REC
if the IN-FILE contains 1000 records what value will be displayedafter the
PERFORM is over?assume that N0.OF.REC has PIC 9(4)
a.1000
b.1001
c.1
d.none of the above since there is a syntex error
12.study the data discriptions and answer the questions given below
i)01 ORDER RECORD
05 OUT-HEADER PIC X(50)
05 ITEM-COUNT PIC 99
05 OUT-ITEM PIC X(20) OCCURS 1 TO 20 DEPENDING ON ITEM-COUNT
ii)01 NAME-AND-ADDRESS
05 N-AND-A-LINE OCCURES 5
05 LINE-LENGTH PIC P9
05 N-AND-A-CHAR PIC X OCCURS 1 TO 20 DEPENDING ON LINE-LENGTH
iii)01 SALES-LIST
05 SALESMAN-COUNT PIC 99
05 SALES PIC 9(6) OCCURS 1 TO 100 DEPENDING ON
SALESMAN-COUNT
iv)01 ORDER-RECORD
05 NO-OF-BRANDS PIC 99
05 BRAND-PURCHASED OCCURS 1 TO 15 DEPENDING ON NO-OF-BRANDS
which of the following is true?
a.i) and iii) are valid
b.i) and iv) are valid
c.i) and iii) are not valid
d.all are valid
13.C1 C2 C3 are three conditions whose TRUTH values are as folloes.
C1-TRUE C2-FALSE C3-TRUE
A,B,C are defined as given below
A:C1 AND(NOT C2) OR C3
B.(NOT C1) OR (NOT C2 AND NOT C3)
C.(C1 OR C2)AND C3
D.C1 AND C2 OR C3
given the above information which of the following statements are valid?
a.only A,B and C are TRUE
b.only A,C and D are TRUE
c.A,B,C and D are TRUE
d.only C and D are TRUE
14.consider the following
FD FILE-1
01 REC-1 PIC X(80)
......
WORKING-STORAGE SECTION
01 W-REC PIC X(90)
........
PROCEDURE DIVISION
FIRST-PARA
.......
READ FILE-1 INTO W-REC AT END MOVE 1 TO EOF-FLAG
which of the following is true with respect to the above?
a.REC-1 will contain nothing and W-REC will contain the contains of the
record read
b.REC-1 and W-REC contain the same data
c.syntex is invalid and error will occur
d.REC-1 and W-REC must be of same size
15.PERFORM ACCUMULATE-TOTALS
VARYING A FROM 1 BY 2 UNTIL A >2
AFTER B FROM1 BY 1 UNTIL B>2
AFTER C FROM 2 BY -1 UNTIL C<2 br=""> the paragraph ACCUMULATE-TOTALS would be exicuted
a.18 times
b.4 times
c.8 times
d.24 times
16.there is a file whose ORGANISATION is INDEXED.you want to read the records
from the file in RANDOM fashion as well as sequentially.then which of the
access mode would you specify?
a.SEQUENTIAL
b.RANDOM
c.DYNAMIC
D.ACCESS MODE has nothing to do with it
17.consider the following PROCEDURE DIVISION entry
OPEN EXTEND IN-FILE
identify the correct statement
a.organization of IN-FILE is sequential and records can be added in the
beginning
b.organization of IN-FILE is sequential and records can be added in the
end
c.organization of IN-FILE is indexed and records can be added in the
beginning
d.organization of IN-FILE is indexed and records can be added in the end
18.what is the size of W-REC in the following
01 W-REC
05 A PIC 9(4)V99
05 B READLINES A
10 C PIC XX
10 D PIC S9(4)
05 E OCCURS 7 PIC ZZ.ZZ
05 F OCCURS 5
10 G PIC ZZ.ZZZ99
10 H OCCURS 3
15 J PIC 9(3)
15 K PIC V99
a.177
b.161
c.180
d.none of yhe above
19.consider the following two IF statements:
IF X AND NOT Y MOVE A TO B
IF Z=1 OR 9 MOVE A TO B
select one of the following data divusion entries which gives identical
results for both the above IF statements
a.01 Z PIC 9
88 X VALUE 1.9
88 Y VALUE 0.2 THRU 8
b.01 Z PIC 9
88 X VALUE 0.2 THRU 8
Y VALUE 1.9
c.01 Z PIC 9
88 X VALUE 1.9
88 NOT-Y VALUE 0.2 THRU 1.9
d.none of yhe above
20.consider the following two statements
MOVE 10 TO N
PERFORM PARA-X N TIMES
STOP RUN
PARA-X
MOVE 5 TO N
how many times PARA-X willbe exicuted?
a.10
b.5
c.infinate
d.execution error
21.given the following:
77 A PIC 9V9 VALUE 9.5
77 B PIC 9 VALUE 9.
77 C PIC V9 VALUE 0.8
77 D PIC 9
77 E PIC 9
77 F PIC 9V999
what are the contenta of D E nad F after teh following statements are
executed:
COMPUTE F ROUNDED=A+C/B
MULTIPLY A BY C GIVING E
ADD B C A GIVING D ROUNDED
a.F=9.589 E=8 D=1
b.F=9.589 E=8 D=9
c.F=9.589 E=7 D=9
d.F=9.589 E=7 D=1

22. Consider the follwoing IF condition:

IF A LESS 1200 IF B GREATER 25 MOVE 47 TOC
ELSE MOVE 57 TO C
IF A GREATER 249 MOVE 67 TO C
ELSE NEXT SENTENCE ELSE IF B LESS 67
MOVE 27 TO C

What will be the value of C, when A is 137 and b is 25
(a) 27
(b) 57
(c) 67
(d) none

23. Consider the following:

77 W-NUM PIC 9 VALUE 0
------
MOVE 1 TO W-NUM
PERFORM PARA-X UNTIL W-NUM > 9.
------
PARA-X
ADD 1 TO W-NUM

How many times PARA-X is executed ?
(a) 10
(b) 9
(c) 11
(d) Infinite loop

24. Consider the following code:

77 A PIC 99V99 VALUE 55.35
77 B PIC 99V999 VALUE 32.754

ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!"

What will be the result ?
(a) A=88.10, B=32.754
(b) A=87.00 B=32.754
(c) A=87.10 B=32.754
(d) ERROR!!! will be DISPLAYed on the screen.

25. Consider the following:

77 A PIC 9(10)
77 B PIC 9(10)
77 C PIC 9(19)

MULTIPLY AB BY B GIVING C

Which of the following is true ?

(a) The execution of the above may result in size error.
(b) The execution of the above will result in size error.
(c) The definition of C is invalid resulting in compilation error.
(d) No error will be thee and the program would proceed correctly.

26. A paragraph PARA-X is to be executed when none oof the data names
A, B and C have value of 1. Which of the following will achieve this ?

(a) IF A NOT = 1 OR B NOT = 1 OR C NOT = 1 PERFORM PARA-X
(B) IF NOT A= 1 AND B= 1 AND C = 1 PERFORM PARA-X
(C) IF A NOT =1 IF NOT B = 1 OR C= 1 PERFORM PARA-X
(C) IF A NOT = 1 AND B NOT = 1 AND C NOT = 1 PERFORM PARA-X



27. Study the five expressions and the class to which they belong:
S.N. Expression Class
1 "SPACES" Figurative constant
2. "Depreciation Schedule Non-numeric literal
3. "12%" Non-numeric literal
4. INTEREST-DUE Non-numeric literal
5. ZEROES Figurative constant
Which of the following statement is true?
(a) 1 and 3 are incorrect
(b) 1 and 4 are incorrect
(c) 3 and 4 are incorrect
(d) All are correct

28. Identify the invalid dataname from the following:
(a) SAVINGS-ACCOUNT
(b) ANNUAL-ALLOCATION-FOR-OVERHEAD
(c) SAMOUNT250
(d) 12DEMAND

29. Study the DATA DIVISION entries and the three PROCEDURE DIVISION entries
given below:
01 END-OF-FILE-SWITCH PIC XXX.
88 NO-MORE-RECS VALUE "YES".
88 MORE-RECS VALUE "NO".
(i) READ SAMPLE-FILE AT END MOVE "YES" TO NO-MORE-RECS.
(ii) IF NO-MORE-RECS = "YES" GO TO LAST-PARA.
(iii) IF NO-MORE-RECS GO TO LAST-PARA.
Which are wrong?
(a) (i) and (ii)
(b) (ii) and (iii)
(c) (i) and (iii)
(d) all

30. The following entries appear in the WORKING-STORAGE SECTION:
01 DATE-TODAY.
05 YY PIC XX VALUE "90".
05 MM PIC XX VALUE "12".
05 DD PIC XX VALUE :31".
01 DATE-EDIT PIC XX/XX/XX.
MOVE DATE-TODAY TO DATE-EDIT.
(a) 901231
(b) 90/12/31
(c) 31/12/90
(d) 311290

31. How many bytes will be allocated for the following record description
entries?
01 REC-A.
05 A PIC S9(4).
05 B PIC XXXBXXX.
05 C PIC ____9.99.
05 D PIC S9(5) COMP-3.
05 E PIC 9(3) COMP.
(a) 29
(b) 26
(c) 25
(d) 28

32. What is wrong with the following data declaration?
01 W-DATE PIC X(6).
05 DD PIC 99.
05 MM PIC 99.
05 YY PIC 99.
(a) Nothing is wrong.
(b) Under W-DATE all level 05 items are having a PIC 99 but level
01 has PIC X(6).
(c) PIC can't be specified for a group item.
(d) DD, MM, and YY are invalid datanames.

33. What is the output generated by the following code?
01 GRP-I.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
ELSE
DISPLAY "SPACES"
DISPLAY "END".
(a) SUBFLD1
SUBFLD3
END
(b) SPACES
END
(c) SUBFLD1
END
(d) SUBFLD1
SPACES

34. 88 level entry is used for
(a) data items in WORKING-STORAGE SECTION
(b) items with RENAMES clause
(c) condition-names
(d) None of the above

35. ZEROES and SPACES are _______ constants
(a) Figurative
(b) Numeric
(c) Non-numeric
(d) Alphabete

36. COMPUTE X = A * B - C * D and
COMPUTE X = (A * B) - (C * D)
(a) Are not the same
(b) Are same
(c) Syntactically wrong
(d) Will yield a run time error

37. OCCURS clause is used in the DATA DIVISION on data names at
(a) 01 level
(b) 77 level
(c) 88 level
(d) any level from 02 to 49

38. Consider the following COBOL entries:
05 X PIC 99 VALUE 10.
SUBTRACT 20 FROM X.
The resultant value of X wil be
(a) 10
(b) 00
(c) compile-time error
(d) none of these

39. Consider the following COBOL entries
05 X PIC 99 VALUE 10.
ADD 40 X TO X.
COMPUTE X = 3 * X - 40.
The result in X is
(a) 10
(b) 40
(c) Compile or Run time error
(d) none of these

40. given the following piece of code:
CALL SUB-PGM USING A, B, C.
CALL SUB-PGM USING A, C, C.
(a) Both CALL statements will always produce same result.
(d) Both CALL statements may produce different result.
(c) Compile-time error because SUB-PGM is a dataname.
(d) Compile-time error because A, B, C are used twice.

41. The hierarchy of the execution of logical operators is
(a) NOT AND OR
(b) AND OR NOT
(c) OR AND NOT
(d) OR NOT AND

42. The order of precedence of arithmetic operators in an expression can be
overridden with the use of
(a) []
(b) ()
(c) {}
(d) Any of the above

Consider the following passage for answering questions 43 to 47.

A program is written to accept an answer to the query "enough fo the Day?"
If the respons is "N" then the program accepts quantity purchased and rate
of the item and displays the amount to be collected. Then the above query
is again displayed and the loop continues. At the end of the day, when
the response to the above query is "Y", the day collections are displayed.

The program checks that the quantity purchased is between 25 and 125 and the
rate of the item is between 10.00 and 75.00. If any of these two conditions
are violated, the program displays an appropriate message and asks for next
input. The amounts are displayed with proper editing. The program is written
assuming that there can be a maximum of 1000 transactions a day.

43. How many variables would you declare for the above problem?
(a) 3
(b) 4
(c) 5
(d) 7

44. What should be the PICTURE clause of the variable used to calculate
end of the day collections?
(a) 9(9)v99
(b) 9(8)v99
(c) 995)v99
(d) Information given is insufficient to arrive at the answer

45. What should be the PICTURE clause of the variable used to calculate
to be collected.
(a) 9(9)v99
(b) 9(8)v99
(c) 9(5)v99
(d) Information given is insufficient to arrive at the answer

46. Assuming that the above program is being executed in a Department
Stores in MADRAS which of the following PICTURE clause will be
suitable for DISPLAYing the end of the day collections?
(a) Z(5)V99
(b) Z(5).99
(c) ZZ,ZZ,ZZ,ZZ9.99
(d) Information given is insufficient to arrive at the answer

47. How many _____ statements do you think will be there in the program?
(a) 3
(b) 4
(c) 5
(d) Information given is insufficient to arrive at the answer

48. Which of the following paragraphs is compulsory in every COBOL program?
(a) SPECIAL-NAMES
(b) PROGRAM-ID
(c) FILE-CONTROL
(d) OBJECT-COMPUTER

49. Which of the following files can be OPENed in all the 4 modes? The four
modes are INPUT, I-O, OUTPUT and EXTEND.
(a) INDEXED
(b) RELATIVE
(c) SEQUENTIAL
(d) All of the above

50. Which of the following EDITind and PICTURE symbols is to be used if a
minus(-) is to appear before the value if the value is -ve and a plus(+)
is to appear before the value if the value is +ve?
(a) +
(b) -
(c) + OR
(d) It is not possible

solutions

b,b,c,c,c,a,d,a,b,a,c,c,b,b,b,c,b,d,a,a,c,b,d,a,d,d,b,c,d,b,a,c,a,c,a,b,d,
a,c,b,a,b,b,b,c,c,a,b,c,a