A rope ladder was left down from a ship. 12 steps of the ladder were exposed at 10:00 am. The queen
who was going to visit the ship, said she would visit at 1:00 pm as she would have to climb lesser number
of steps then. The tide in the sea increases from morning to afternoon at the rate of 1.2 meters per hour.
The distance between any 2 steps of the ladder is 0.4 mts. How many steps will the queen have to climb?
Monday, January 31, 2011
[Algorithm]
Alice and Liu had some berries. The total of Alice's berries and square of number of berries with Liu
is 62. The total of Liu's berries and square of number of berries with Alice is 176. How many berries does
each of them have?
is 62. The total of Liu's berries and square of number of berries with Alice is 176. How many berries does
each of them have?
Labels:
Data Structures and Algorithms
[Algorithm]
A contribution of Rs. 500 was raisedfrom 500 people. The fee was as follows:
Men: Rs.3.00 each
Women: Rs. 2.00 each
Childern: 0.48 each
If number of women is more than number of men, how many childern are there?
Men: Rs.3.00 each
Women: Rs. 2.00 each
Childern: 0.48 each
If number of women is more than number of men, how many childern are there?
Labels:
Data Structures and Algorithms
[Algorithm]
Consider the following statements:
Albert: Dave did it.
Dave: Tony did it.Gug: I did not do it.
Tony: Dave lied when he said that i did it.
(a)If only one out of all above statements is true, who did it?
(b)If only one out of all above statements is false, who did it?
Albert: Dave did it.
Dave: Tony did it.Gug: I did not do it.
Tony: Dave lied when he said that i did it.
(a)If only one out of all above statements is true, who did it?
(b)If only one out of all above statements is false, who did it?
Labels:
Data Structures and Algorithms
[Algorithm]
There was a race between 3 people. Me, Doug and Anne. When I take 21 steps the distance covered
is equal to Doug's 24 steps and Anne's 28 steps. I take 6 steps to every 7 steps of Doug and 8 steps of
Anne. Who won the race?
is equal to Doug's 24 steps and Anne's 28 steps. I take 6 steps to every 7 steps of Doug and 8 steps of
Anne. Who won the race?
Labels:
Data Structures and Algorithms
[Algorithm]
A and B play a game of dice between them. The dice consists of colors on their faces instead of
numbers. A wins if both dice show same color. B wins if both dice show different colors. One dice
consists of 1 red and 5 blue. What must be the color in the faces of other dice.( i.e how many blue and
how many red?). Chances of winning for A and B are even.
numbers. A wins if both dice show same color. B wins if both dice show different colors. One dice
consists of 1 red and 5 blue. What must be the color in the faces of other dice.( i.e how many blue and
how many red?). Chances of winning for A and B are even.
Labels:
Data Structures and Algorithms
[Algorithm]
This problem is of time and work type. Some A and some B are able to produce so many tors in so
many hours.(for example 10 A and 20 B are able to produce 30 tors per hour). Like this one more
sentence was given. We have to find out the rate of working of A and B in tors/hour.
many hours.(for example 10 A and 20 B are able to produce 30 tors per hour). Like this one more
sentence was given. We have to find out the rate of working of A and B in tors/hour.
Labels:
Data Structures and Algorithms
[Algorithm]
5 couples are there.
MEN: L, M, N, O, P.
WOMEN: S, T, U, V, W.
10 seats are in one row. Odd numberd seats are reserved for MEN only Like that many conditions are
there. This problem is from GRE-BARRONS BOOK.
MEN: L, M, N, O, P.
WOMEN: S, T, U, V, W.
10 seats are in one row. Odd numberd seats are reserved for MEN only Like that many conditions are
there. This problem is from GRE-BARRONS BOOK.
Labels:
Data Structures and Algorithms
[Algorithm]
4 persons are there caledd JOHN, JACOB, PITER, and WILLIAMS. 4 laungages are there namedENGLISH, ITALIAN, GERMAN, FRENCH. Conditions:-
a. There is no common language for all.
b. Except one language, no language is spoken by more than two.
c. One can know either German or FRENCH but not both.
d. John can't speak ENGLISH But John can act as interpreter between JACOB and PITER. Jacob knows
GERMAN but he can tailk with WILLIAM who doesn't know a word of GERMAN.
e. No common language between JOHN, PITER, and WILLIAMS.
Which two languages does each person speaks?
Hint: ITALIAN IS SPOKEN BY THREE PERSONS (This hint is given in Question paper)
a. There is no common language for all.
b. Except one language, no language is spoken by more than two.
c. One can know either German or FRENCH but not both.
d. John can't speak ENGLISH But John can act as interpreter between JACOB and PITER. Jacob knows
GERMAN but he can tailk with WILLIAM who doesn't know a word of GERMAN.
e. No common language between JOHN, PITER, and WILLIAMS.
Which two languages does each person speaks?
Hint: ITALIAN IS SPOKEN BY THREE PERSONS (This hint is given in Question paper)
Labels:
Data Structures and Algorithms
[Algorithm]
A merchant in the last day sells 2 lamps for Rs.12 price. He finds that he has got 25 % gain on one
and 20% lost on the other. Did he loose or gain overall? If so how much?
Ans: 60 paise Loss.
and 20% lost on the other. Did he loose or gain overall? If so how much?
Ans: 60 paise Loss.
Labels:
Data Structures and Algorithms
[Algorithm]
A hill of 440 yards is there. Two competitors JACK and JILL go up the hill, first JACK reaches the
topmost and immediatly starts back and meet JILL 20 yards from the topmost point. Finally JACK reaches
the starting point 0.5 minutes earler than JILL. Speed while coming down is 1.5 times the speed of going
up. Find the time taken by JACK for whole journey (880 yards)?
Ans: 6.3 minutes.
topmost and immediatly starts back and meet JILL 20 yards from the topmost point. Finally JACK reaches
the starting point 0.5 minutes earler than JILL. Speed while coming down is 1.5 times the speed of going
up. Find the time taken by JACK for whole journey (880 yards)?
Ans: 6.3 minutes.
Labels:
Data Structures and Algorithms
[Algorithm]
Find a five digit number subject to following conditions:-
a. It contains 2 prime no digits.
b. 3rd digit is the lagest.
c. 1st digit = (3 rd digit - 1).
c. Sum of 4th digit and 5th digit is less than 1st digit.
d. Value of the 5th digit lies between the value of 1st digit and 2nd digit, 5th digit is one half of the 4th
digit.
Ans: 71842
a. It contains 2 prime no digits.
b. 3rd digit is the lagest.
c. 1st digit = (3 rd digit - 1).
c. Sum of 4th digit and 5th digit is less than 1st digit.
d. Value of the 5th digit lies between the value of 1st digit and 2nd digit, 5th digit is one half of the 4th
digit.
Ans: 71842
Labels:
Data Structures and Algorithms
[Algorithm]
Two people X & Y walk on the wall of a godown in opposite direction.
They meet at a point on one side and then go ahead. X after walking for some time,
walks in opposite direction for 15 mtrs.Then again he turns back and walks
in the original direction. What distance did Y walk before they met again,
if X walks 11 mtrs by the time Y walks
8 mtrs.
They meet at a point on one side and then go ahead. X after walking for some time,
walks in opposite direction for 15 mtrs.Then again he turns back and walks
in the original direction. What distance did Y walk before they met again,
if X walks 11 mtrs by the time Y walks
8 mtrs.
Labels:
Data Structures and Algorithms
[Algorithm]
There are some chicken in a poultry. They are fed with corn One sack of corn
will come for 9 days.The farmer decides to sell some chicken and wanted to hold
12 chicken with him. He cuts the feed by 10% and sack of corn comes for 30 days.
So initially how many chicken are there?
will come for 9 days.The farmer decides to sell some chicken and wanted to hold
12 chicken with him. He cuts the feed by 10% and sack of corn comes for 30 days.
So initially how many chicken are there?
Labels:
Data Structures and Algorithms
[Algorithm]
There are five thieves, each loot a bakery one after the other such that
the first one takes 1/2 of the total no. of the breads plus 1/2 of a bread.
Similarly 2nd, 3rd,4th and 5fth also did the same. After the fifth one no.
of breads remained are 3. Initially how many breads were there?
ans : 31.
the first one takes 1/2 of the total no. of the breads plus 1/2 of a bread.
Similarly 2nd, 3rd,4th and 5fth also did the same. After the fifth one no.
of breads remained are 3. Initially how many breads were there?
ans : 31.
Labels:
Data Structures and Algorithms
[Algorithm]
There is a 5digit no. 3 pairs of sum is eleven each.Last digit is 3 times the first one.
3 rd digit is 3 less than the second. 4 th digit is 4 more than the second one.
Find the digit.
ans : 25296.
3 rd digit is 3 less than the second. 4 th digit is 4 more than the second one.
Find the digit.
ans : 25296.
Labels:
Data Structures and Algorithms
[Algorithm]
2 * * |
3 * * | No. 7 does not occur in this
---------------- |
5 * * | multiplication.
* 4 * |
* * 3 | Find the product.
---------------- |
* * * * * |
------------- |
--------------------------------------------------
ans 2 8 1
3 2 2
-----
5 6 2
5 6 2 0
8 4 3 0 0
---------
9 0 4 8 2
---------
3 * * | No. 7 does not occur in this
---------------- |
5 * * | multiplication.
* 4 * |
* * 3 | Find the product.
---------------- |
* * * * * |
------------- |
--------------------------------------------------
ans 2 8 1
3 2 2
-----
5 6 2
5 6 2 0
8 4 3 0 0
---------
9 0 4 8 2
---------
Labels:
Data Structures and Algorithms
[Algorithm]
In a soap company a soap is manufactured with 11 parts.For making one soap you will get 1 part as
scrap. At the end of the day u have 251 such scraps. From that how many
soaps can be manufactured? ans: 22 + 2+ 1 = 25.
scrap. At the end of the day u have 251 such scraps. From that how many
soaps can be manufactured? ans: 22 + 2+ 1 = 25.
Labels:
Data Structures and Algorithms
[Algorithm]
No. of animals is 11 more than the no. of birds. If the no. of birds were
the no. of animals and no. of animals were the no. of birds( ie., interchanging no.s
of animals and birds.), the total no. of legs get reduced by one fifth (1/5).
How many no. of birds and animals were there?
ans: birds:11,animals:22
the no. of animals and no. of animals were the no. of birds( ie., interchanging no.s
of animals and birds.), the total no. of legs get reduced by one fifth (1/5).
How many no. of birds and animals were there?
ans: birds:11,animals:22
Labels:
Data Structures and Algorithms
[Algorithm]
A family I know has several children. Each boy in this family has as many sisters as brothers but each
girl has twice as many brothers as sisters. How many brothers
and sisters are there?
ans: 4 boys and 3 girls.
girl has twice as many brothers as sisters. How many brothers
and sisters are there?
ans: 4 boys and 3 girls.
Labels:
Data Structures and Algorithms
[Algorithm]
There are 8 courses to be handled by faculty in 2 semesters. 4 in 1st semester and 4 in 2nd semester.
The candiadates hired for the post are k, l, m, n, o. The courses are Malvino, Shakespeare, Joyce,
Chauncer........... Some conditions will be given like,
1. L and N handle Shakespeare and Malvino.
2. M and O handle Malvino and Joyce.
The candiadates hired for the post are k, l, m, n, o. The courses are Malvino, Shakespeare, Joyce,
Chauncer........... Some conditions will be given like,
1. L and N handle Shakespeare and Malvino.
2. M and O handle Malvino and Joyce.
Labels:
Data Structures and Algorithms
[Algorithm]
There are 5 positions-Clerk, Buyer, Cashier, Manager, Floorwalker. There are 5 persons- Mrs.Allen,
Mrs.CLark, Twain, Ewing, Bernett. Conditions:
1. Clerk and cashier lunch time 11.30.to12.30.
2. Others 12.30 to 1.30.
3. Mrs.Allen and Bernett play durind lunch time.
4. Clerk and cashier share Bachlor rooms.
5. Ewing and Twain are not in good terms because one day when Twain retuned early from lunch he saw
Ewing already sitting for lunch and reported about him to the manager. Find out which person holds
which post.
Mrs.CLark, Twain, Ewing, Bernett. Conditions:
1. Clerk and cashier lunch time 11.30.to12.30.
2. Others 12.30 to 1.30.
3. Mrs.Allen and Bernett play durind lunch time.
4. Clerk and cashier share Bachlor rooms.
5. Ewing and Twain are not in good terms because one day when Twain retuned early from lunch he saw
Ewing already sitting for lunch and reported about him to the manager. Find out which person holds
which post.
Labels:
Data Structures and Algorithms
[Algorithm]
Consider a beauty contest. 3 persons participate. Their names are Attractive, Delectable, Fascinating.
They are from 3 tribes Pukkas, Wottas, Summas. Pukkas - Always speak truth. Wottas - Always speak lies.
Summas - Speak truth and lies alternatively. Each of the 3 persons make 2 statements. The person who
speaks truth is the least beautiful. From the statements they give and the character of the 3 tribal types,
find out which person belongs to which tribe. Also find out the persons in the Ascending order of their
beauty.
They are from 3 tribes Pukkas, Wottas, Summas. Pukkas - Always speak truth. Wottas - Always speak lies.
Summas - Speak truth and lies alternatively. Each of the 3 persons make 2 statements. The person who
speaks truth is the least beautiful. From the statements they give and the character of the 3 tribal types,
find out which person belongs to which tribe. Also find out the persons in the Ascending order of their
beauty.
Labels:
Data Structures and Algorithms
[Algorithm]
Consider a beauty contest. 3 persons participate. Their names are Attractive, Delectable, Fascinating.
They are from 3 tribes Pukkas, Wottas, Summas. Pukkas - Always speak truth. Wottas - Always speak lies.
Summas - Speak truth and lies alternatively. Each of the 3 persons make 2 statements. The person who speaks truth is the least beautiful. From the statements they give and the character of the 3 tribal types,find out which person belongs to which tribe. Also find out the persons in the Ascending order of their beauty.
They are from 3 tribes Pukkas, Wottas, Summas. Pukkas - Always speak truth. Wottas - Always speak lies.
Summas - Speak truth and lies alternatively. Each of the 3 persons make 2 statements. The person who speaks truth is the least beautiful. From the statements they give and the character of the 3 tribal types,find out which person belongs to which tribe. Also find out the persons in the Ascending order of their beauty.
Labels:
Data Structures and Algorithms
[Algorithm]
Imagine 4 persons A,B,C,D. (It is a strength determining game). A found it hard, but could pull 'C'
and 'D' to his side. AC and BD pairs on opposite sides found themselves equally balanced. When A and B
exchanged thier positions to form pairs AD and BC, BC pair could win and pull AD to thier side. Orderthe 4 persons in Ascending order according to thier strengths.
and 'D' to his side. AC and BD pairs on opposite sides found themselves equally balanced. When A and B
exchanged thier positions to form pairs AD and BC, BC pair could win and pull AD to thier side. Orderthe 4 persons in Ascending order according to thier strengths.
Labels:
Data Structures and Algorithms
[Algorithm]
Consider a pile of Diamonds on a table. A thief enters and steals 1/2 of th e total quanity and then
again 2 extra from the remaining. After some time a second thief enters and steals 1/2 of the remaining+2.
Then 3rd thief enters and steals 1/2 of the remaining+2. Then 4th thief enters and steals 1/2 of the
remaining+2. When the 5th one enters he finds 1 diamond on the table. Find out the total no. of
diamonds originally on the table before the 1st thief entered.
again 2 extra from the remaining. After some time a second thief enters and steals 1/2 of the remaining+2.
Then 3rd thief enters and steals 1/2 of the remaining+2. Then 4th thief enters and steals 1/2 of the
remaining+2. When the 5th one enters he finds 1 diamond on the table. Find out the total no. of
diamonds originally on the table before the 1st thief entered.
Labels:
Data Structures and Algorithms
[Algorithm]
2 persons are doing part time job in a company say A and B. THe company is open for all the 7 days
of the week. 'A' works every second day. 'B' works every 3rd day. If 'A'works on first june and 'B' works on second june. Find out the date on which both 'A' and 'B' will work together.
of the week. 'A' works every second day. 'B' works every 3rd day. If 'A'works on first june and 'B' works on second june. Find out the date on which both 'A' and 'B' will work together.
Labels:
Data Structures and Algorithms
[Algorithm]
Imagine a rectangle. Its length = 2*width. A square of 1 inch is cut on all corners so that the
remaining portion forms a box when folded. The volume of the box is _____ cubic inches. Find the
original dimensions of the box.
remaining portion forms a box when folded. The volume of the box is _____ cubic inches. Find the
original dimensions of the box.
Labels:
Data Structures and Algorithms
[Algorithm]
A boy picks up the phone and asks "Who are you?". The voice from the other side answers "I am
your mother's mother-in-law". What is the relation of the boy with the fellow speaking at the other end.
your mother's mother-in-law". What is the relation of the boy with the fellow speaking at the other end.
Labels:
Data Structures and Algorithms
[Algorithm]
there were five hunters A,B,C,D,E and five animals A,B,C,D,E. Hunter
having the same name with the animal didn't kill it. Each hunter has
missed some animal.
A animal was hunt by the hunter whose name matches with animal hunt by
hunter B.
C animal was hunt by the hunter whose name matches with animal hunt by
hunter D.
E has hunt C and missed D .find out animals hunted by A,B,C. 6m.
having the same name with the animal didn't kill it. Each hunter has
missed some animal.
A animal was hunt by the hunter whose name matches with animal hunt by
hunter B.
C animal was hunt by the hunter whose name matches with animal hunt by
hunter D.
E has hunt C and missed D .find out animals hunted by A,B,C. 6m.
Labels:
Data Structures and Algorithms
[Algorithm]
Joe started from bombay towards pune and her friend julie in opposite
direction.they meet at a point .distance travelled by joe was 1.8 miles
more than that of julie.after spending some both started there way.
joe reaches in 2 hours while julie in 3.5 hours.Assuming both were travelling
with constant speed.Wath is the distance between the two cities.
direction.they meet at a point .distance travelled by joe was 1.8 miles
more than that of julie.after spending some both started there way.
joe reaches in 2 hours while julie in 3.5 hours.Assuming both were travelling
with constant speed.Wath is the distance between the two cities.
Labels:
Data Structures and Algorithms
[Algorithm]
there were three suspects for a robbery that happend in a bank, tommy,
joy and bruceEach of them were saying that I haven't done anything and the
other two has done it.police found that tommy was lying .who is the thief.
3M (MARKS).
joy and bruceEach of them were saying that I haven't done anything and the
other two has done it.police found that tommy was lying .who is the thief.
3M (MARKS).
Labels:
Data Structures and Algorithms
[Algorithm]
There are 3 women ,they having three jewells, named diamond emerald, ruby
3 women A,B,C 3 thiefs D,E,F each they had taken one jewel from each of the women
following conditions
one who had taken diamond is the bachelor and most dangerous
D 's brother in law E who is less dangerous than the thief who had
stolen emerald
(this is the key from this e had stolen ruby)
D did nt stolen from B
one more condition is there
3 women A,B,C 3 thiefs D,E,F each they had taken one jewel from each of the women
following conditions
one who had taken diamond is the bachelor and most dangerous
D 's brother in law E who is less dangerous than the thief who had
stolen emerald
(this is the key from this e had stolen ruby)
D did nt stolen from B
one more condition is there
Labels:
Data Structures and Algorithms
[Algorithm]
ther are four persons A,B,C,D and for languages english ,french,german,italian.
conditions
1 only one language is spoken by more than two men
2 A dont know english
3 a man can speak either french or german but not both
4 all man cannot spek in a group(no common language)
5 A can mediate when B and C want to speak with each other
6 each men can speak two languages
ans:
A french italian
B english french
C german italian
D german italian
conditions
1 only one language is spoken by more than two men
2 A dont know english
3 a man can speak either french or german but not both
4 all man cannot spek in a group(no common language)
5 A can mediate when B and C want to speak with each other
6 each men can speak two languages
ans:
A french italian
B english french
C german italian
D german italian
Labels:
Data Structures and Algorithms
[Algorithm]
Conversation between two employees is as follows:-
EMPLOYEE-1: Hello! Now your experience is twice the my experience.
EMPLOYEE-2: Exactly two times.
EMPLOYEE-1: But at the last meet, you said that your experience is thrice of my experience.
EMPLOYEE-2: That is when we met at 2 years back, your experience is thrice that of yours.
What is the experience of two employess with the company?
Ans: EMPLOYEE-1: 4 years EMPLOYEE-2: 8 years.
EMPLOYEE-1: Hello! Now your experience is twice the my experience.
EMPLOYEE-2: Exactly two times.
EMPLOYEE-1: But at the last meet, you said that your experience is thrice of my experience.
EMPLOYEE-2: That is when we met at 2 years back, your experience is thrice that of yours.
What is the experience of two employess with the company?
Ans: EMPLOYEE-1: 4 years EMPLOYEE-2: 8 years.
Labels:
Data Structures and Algorithms
What is source route?
It is a sequence of IP addresses identifying the route a datagram must follow. A source route may optionally be included in an IP datagram header.
Labels:
Computer Networks
What is RIP (Routing Information Protocol)?
It is a simple protocol used to exchange information between the routers.
Labels:
Computer Networks
What is SLIP (Serial Line Interface Protocol)?
It is a very simple protocol used for transmission of IP datagrams across a serial line.
Labels:
Computer Networks
What is Proxy ARP?
It is using a router to answer ARP requests. This will be done when the originating host believes that a destination is local, when in fact is lies beyond router.
Labels:
Computer Networks
What is OSPF?
It is an Internet routing protocol that scales well, can route traffic along multiple paths, and uses knowledge of an Internet's topology to make accurate routing decisions.
Labels:
Computer Networks
What is Kerberos?
It is an authentication service developed at the Massachusetts Institute of Technology. Kerberos uses encryption to prevent intruders from discovering passwords and gaining unauthorized access to files.
Labels:
Computer Networks
What is a Multi-homed Host?
It is a host that has a multiple network interfaces and that requires multiple IP addresses is called as a Multi-homed Host.
Labels:
Computer Networks
What is NVT (Network Virtual Terminal)?
It is a set of rules defining a very simple virtual terminal interaction. The NVT is used in the start of a Telnet session.
Labels:
Computer Networks
What is Gateway-to-Gateway protocol?
It is a protocol formerly used to exchange routing information between Internet core routers.
Labels:
Computer Networks
What is BGP (Border Gateway Protocol)?
It is a protocol used to advertise the set of networks that can be reached with in an autonomous system. BGP enables this information to be shared with the autonomous system. This is newer than EGP (Exterior Gateway Protocol).
Labels:
Computer Networks
What is autonomous system?
It is a collection of routers under the control of a single administrative authority and that uses a common Interior Gateway Protocol.
Labels:
Computer Networks
What is EGP (Exterior Gateway Protocol)?
It is the protocol the routers in neighboring autonomous systems use to identify the set of networks that can be reached within or via each autonomous system.
Labels:
Computer Networks
What is IGP (Interior Gateway Protocol)?
It is any routing protocol used within an autonomous system.
Labels:
Computer Networks
What is Mail Gateway?
It is a system that performs a protocol translation between different electronic mail delivery protocols.
Labels:
Computer Networks
What is wide-mouth frog?
Wide-mouth frog is the simplest known key distribution center (KDC) authentication protocol.
Labels:
Computer Networks
What are Digrams and Trigrams?
The most common two letter combinations are called as digrams. e.g. th, in, er, re and an. The most common three letter combinations are called as trigrams. e.g. the, ing, and, and ion.
Labels:
Computer Networks
What is silly window syndrome?
It is a problem that can ruin TCP performance. This problem occurs when data are passed to the sending TCP entity in large blocks, but an interactive application on the receiving side reads 1 byte at a time.
Labels:
Computer Networks
What is region?
When hierarchical routing is used, the routers are divided into what we will call regions, with each router knowing all the details about how to route packets to destinations within its own region, but knowing nothing about the internal structure of other regions.
Labels:
Computer Networks
What is multicast routing?
Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.
Labels:
Computer Networks
What is traffic shaping?
One of the main causes of congestion is that traffic is often busy. If hosts could be made to transmit at a uniform rate, congestion would be less common. Another open loop method to help manage congestion is forcing the packet to be transmitted at a more predictable rate. This is called traffic shaping.
Labels:
Computer Networks
What is packet filter?
Packet filter is a standard router equipped with some extra functionality. The extra functionality allows every incoming or outgoing packet to be inspected. Packets meeting some criterion are forwarded normally. Those that fail the test are dropped.
Labels:
Computer Networks
What is virtual path?
Along any transmission path from a given source to a given destination, a group of virtual circuits can be grouped together into what is called path.
Labels:
Computer Networks
What is logical link control?
One of two sublayers of the data link layer of OSI reference model, as defined by the IEEE 802 standard. This sublayer is responsible for maintaining the link between computers when they are sending data across the physical network connection.
Labels:
Computer Networks
What is virtual channel?
Virtual channel is normally a connection from one source to one destination, although multicast connections are also permitted. The other name for virtual channel is virtual circuit.
Labels:
Computer Networks
What is the difference between routable and non- routable protocols?
Routable protocols can work with a router and can be used to build large networks. Non-Routable protocols are designed to work on small, local networks and cannot be used with a router
Labels:
Computer Networks
Why should you care about the OSI Reference Model?
It provides a framework for discussing network operations and design.
Labels:
Computer Networks
Explain 5-4-3 rule?
In a Ethernet network, between any two points on the network ,there can be no more than five network segments or four repeaters, and of those five segments only three of segments can be populated.
Labels:
Computer Networks
What is difference between baseband and broadband transmission?
In a baseband transmission, the entire bandwidth of the cable is consumed by a single signal. In broadband transmission, signals are sent on multiple frequencies, allowing multiple signals to be sent simultaneously.
Labels:
Computer Networks
What is mesh network?
A network in which there are multiple network links between computers to provide multiple paths for data to travel.
Labels:
Computer Networks
What are the data units at different layers of the TCP / IP protocol suite?
The data unit created at the application layer is called a message, at the transport layer the data unit created is called either a segment or an user datagram, at the network layer the data unit created is called the datagram, at the data link layer the datagram is encapsulated in to a frame and finally transmitted as signals along the transmission media.
Labels:
Computer Networks
What is difference between ARP and RARP?
The address resolution protocol (ARP) is used to associate the 32 bit IP address with the 48 bit physical address, used by a host or a router to find the physical address of another host on its network by sending a ARP query packet that includes the IP address of the receiver.
The reverse address resolution protocol (RARP) allows a host to discover its Internet address when it knows only its physical address.
The reverse address resolution protocol (RARP) allows a host to discover its Internet address when it knows only its physical address.
Labels:
Computer Networks
What is the minimum and maximum length of the header in the TCP segment and IP datagram?
The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes
Labels:
Computer Networks
What is the range of addresses in the classes of internet addresses?
Class A 0.0.0.0 - 127.255.255.255
Class B 128.0.0.0 - 191.255.255.255
Class C 192.0.0.0 - 223.255.255.255
Class D 224.0.0.0 - 239.255.255.255
Class E 240.0.0.0 - 247.255.255.255
Class B 128.0.0.0 - 191.255.255.255
Class C 192.0.0.0 - 223.255.255.255
Class D 224.0.0.0 - 239.255.255.255
Class E 240.0.0.0 - 247.255.255.255
Labels:
Computer Networks
What is the difference between TFTP and FTP application layer protocols?
The Trivial File Transfer Protocol (TFTP) allows a local host to obtain files from a remote host but does not provide reliability or security. It uses the fundamental packet delivery services offered by UDP.
The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for copying a file from one host to another. It uses the services offer by TCP and so is reliable and secure. It establishes two connections (virtual circuits) between the hosts, one for data transfer and another for control information.
The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for copying a file from one host to another. It uses the services offer by TCP and so is reliable and secure. It establishes two connections (virtual circuits) between the hosts, one for data transfer and another for control information.
Labels:
Computer Networks
What are major types of networks and explain?
Server-based network
Peer-to-peer network
Peer-to-peer network, computers can act as both servers sharing resources and as clients using the resources.
Server-based networks provide centralized control of network resources and rely on server computers to provide security and network administration
Peer-to-peer network
Peer-to-peer network, computers can act as both servers sharing resources and as clients using the resources.
Server-based networks provide centralized control of network resources and rely on server computers to provide security and network administration
Labels:
Computer Networks
What are the important topologies for networks?
BUS topology:
In this each computer is directly connected to primary network cable in a single line.
Advantages:
Inexpensive, easy to install, simple to understand, easy to extend.
STAR topology:
In this all computers are connected using a central hub.
Advantages:
Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.
RING topology:
In this all computers are connected in loop.
Advantages:
All computers have equal access to network media, installation can be simple, and signal does not degrade as much as in other topologies because each computer regenerates it.
In this each computer is directly connected to primary network cable in a single line.
Advantages:
Inexpensive, easy to install, simple to understand, easy to extend.
STAR topology:
In this all computers are connected using a central hub.
Advantages:
Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.
RING topology:
In this all computers are connected in loop.
Advantages:
All computers have equal access to network media, installation can be simple, and signal does not degrade as much as in other topologies because each computer regenerates it.
Labels:
Computer Networks
Difference between bit rate and baud rate.
Bit rate is the number of bits transmitted during one second whereas baud rate refers to the number of signal units per second that are required to represent those bits.
baud rate = bit rate / N
where N is no-of-bits represented by each signal shift.
baud rate = bit rate / N
where N is no-of-bits represented by each signal shift.
Labels:
Computer Networks
What is Bandwidth?
Every line has an upper limit and a lower limit on the frequency of signals it can carry. This limited range is called the bandwidth.
Labels:
Computer Networks
What are the types of Transmission media?
Signals are usually transmitted over some transmission media that are broadly classified in to two categories.
a) Guided Media:
These are those that provide a conduit from one device to another that include twisted-pair, coaxial cable and fiber-optic cable. A signal traveling along any of these media is directed and is contained by the physical limits of the medium. Twisted-pair and coaxial cable use metallic that accept and transport signals in the form of electrical current. Optical fiber is a glass or plastic cable that accepts and transports signals in the form of light.
b) Unguided Media:
This is the wireless media that transport electromagnetic waves without using a physical conductor. Signals are broadcast either through air. This is done through radio communication, satellite communication and cellular telephony.
a) Guided Media:
These are those that provide a conduit from one device to another that include twisted-pair, coaxial cable and fiber-optic cable. A signal traveling along any of these media is directed and is contained by the physical limits of the medium. Twisted-pair and coaxial cable use metallic that accept and transport signals in the form of electrical current. Optical fiber is a glass or plastic cable that accepts and transports signals in the form of light.
b) Unguided Media:
This is the wireless media that transport electromagnetic waves without using a physical conductor. Signals are broadcast either through air. This is done through radio communication, satellite communication and cellular telephony.
Labels:
Computer Networks
What is Project 802?
It is a project started by IEEE to set standards to enable intercommunication between equipment from a variety of manufacturers. It is a way for specifying functions of the physical layer, the data link layer and to some extent the network layer to allow for interconnectivity of major LAN
protocols.
It consists of the following:
802.1 is an internetworking standard for compatibility of different LANs and MANs across protocols.
802.2 Logical link control (LLC) is the upper sublayer of the data link layer which is non-architecture-specific, that is remains the same for all IEEE-defined LANs.
Media access control (MAC) is the lower sublayer of the data link layer that contains some distinct modules each carrying proprietary information specific to the LAN product being used. The modules are Ethernet LAN (802.3), Token ring LAN (802.4), Token bus LAN (802.5).
802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.
protocols.
It consists of the following:
802.1 is an internetworking standard for compatibility of different LANs and MANs across protocols.
802.2 Logical link control (LLC) is the upper sublayer of the data link layer which is non-architecture-specific, that is remains the same for all IEEE-defined LANs.
Media access control (MAC) is the lower sublayer of the data link layer that contains some distinct modules each carrying proprietary information specific to the LAN product being used. The modules are Ethernet LAN (802.3), Token ring LAN (802.4), Token bus LAN (802.5).
802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.
Labels:
Computer Networks
What is Protocol Data Unit?
The data unit in the LLC level is called the protocol data unit (PDU). The PDU contains of four fields a destination service access point (DSAP), a source service access point (SSAP), a control field and an information field. DSAP, SSAP are addresses used by the LLC to identify the protocol stacks on the receiving and sending machines that are generating and using the data. The control field specifies whether the PDU frame is a information frame (I - frame) or a supervisory frame (S - frame) or a unnumbered frame (U - frame).
Labels:
Computer Networks
What are the different type of networking / internetworking devices?
Repeater:
Also called a regenerator, it is an electronic device that operates only at physical layer. It receives the signal in the network before it becomes weak, regenerates the original bit pattern and puts the refreshed copy back in to the link.
Bridges:
These operate both in the physical and data link layers of LANs of same type. They divide a larger network in to smaller segments. They contain logic that allow them to keep the traffic for each segment separate and thus are repeaters that relay a frame only the side of the segment containing the intended recipent and control congestion.
Routers:
They relay packets among multiple interconnected networks (i.e. LANs of different type). They operate in the physical, data link and network layers. They contain software that enable them to determine which of the several possible paths is the best for a particular transmission.
Gateways:
They relay packets among networks that have different protocols (e.g. between a LAN and a WAN). They accept a packet formatted for one protocol and convert it to a packet formatted for another protocol before forwarding it. They operate in all seven layers of the OSI model.
Also called a regenerator, it is an electronic device that operates only at physical layer. It receives the signal in the network before it becomes weak, regenerates the original bit pattern and puts the refreshed copy back in to the link.
Bridges:
These operate both in the physical and data link layers of LANs of same type. They divide a larger network in to smaller segments. They contain logic that allow them to keep the traffic for each segment separate and thus are repeaters that relay a frame only the side of the segment containing the intended recipent and control congestion.
Routers:
They relay packets among multiple interconnected networks (i.e. LANs of different type). They operate in the physical, data link and network layers. They contain software that enable them to determine which of the several possible paths is the best for a particular transmission.
Gateways:
They relay packets among networks that have different protocols (e.g. between a LAN and a WAN). They accept a packet formatted for one protocol and convert it to a packet formatted for another protocol before forwarding it. They operate in all seven layers of the OSI model.
Labels:
Computer Networks
What is ICMP?
ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite used by hosts and gateways to send notification of datagram problems back to the sender. It uses the echo test / reply to test whether a destination is reachable and responding. It also handles both control and error messages.
Labels:
Computer Networks
What is Brouter?
Hybrid devices that combine the features of both bridges and routers.
Labels:
Computer Networks
What is cladding?
A layer of a glass surrounding the center fiber of glass inside a fiber-optic cable.
Labels:
Computer Networks
What is point-to-point protocol
A communications protocol used to connect computers to remote networking services including Internet service providers.
Labels:
Computer Networks
How Gateway is different from Routers?
A gateway operates at the upper levels of the OSI model and translates information between two completely different network architectures or data formats
Labels:
Computer Networks
What is attenuation?
The degeneration of a signal over distance on a network cable is called attenuation.
Labels:
Computer Networks
What is MAC address?
The address for a device as it is identified at the Media Access Control (MAC) layer in the network architecture. MAC address is usually stored in ROM on the network adapter card and is unique.
Labels:
Computer Networks
What is passive topology?
When the computers on the network simply listen and receive the signal, they are referred to as passive because they don’t amplify the signal in any way. Example for passive topology - linear bus.
Labels:
Computer Networks
Sunday, January 30, 2011
how to know list of sites that uses my personal site?
I would like to know the list of sites, which used my personal site as reference. Please some one help me how to get it?
for ex:
I want to know what are the sites are referring my interested(personal) site(www.sqlzoo.net). But I dont want to list my own site. Please some one help me in solving this?
for ex:
I want to know what are the sites are referring my interested(personal) site(www.sqlzoo.net). But I dont want to list my own site. Please some one help me in solving this?
Labels:
Others
Online SQL tool:
Online SQL tool:
Ofentimes, we need to access database. But we may not able to access the db or we may not able have proper licence/permissions. For that matter SQLZoo provides solutions for our problem.
Have a look at this belo site and do experiments.
http://sqlzoo.net/
-KK PATURU
Ofentimes, we need to access database. But we may not able to access the db or we may not able have proper licence/permissions. For that matter SQLZoo provides solutions for our problem.
Have a look at this belo site and do experiments.
http://sqlzoo.net/
-KK PATURU
Labels:
Information Security
Online SQL tool
Online SQL tool:
Ofentimes, we need to access database. But we may not able to access the db or we may not able have proper licence/permissions. For that matter SQLZoo provides solutions for our problem.
Have a look at this belo site and do experiments.
http://sqlzoo.net/
-KK PATURU
Ofentimes, we need to access database. But we may not able to access the db or we may not able have proper licence/permissions. For that matter SQLZoo provides solutions for our problem.
Have a look at this belo site and do experiments.
http://sqlzoo.net/
-KK PATURU
Labels:
Others
Web back door / Web Shell
Web Back door: A sort of scripts stored in server and servers our purpose.
For example:
The admin console of Cold Fusion allows to upload any file to root folder. An attacker can use this scenario to upload a malicious file, intends to execute commands. Hence an attacker can get command execution using browser. Similar web back door or webShell files can be found in the below URLs.
http://grutz.jingojango.net/exploits/
http://michaeldaw.org/projects/web-backdoor-compilation
For example:
The admin console of Cold Fusion allows to upload any file to root folder. An attacker can use this scenario to upload a malicious file, intends to execute commands. Hence an attacker can get command execution using browser. Similar web back door or webShell files can be found in the below URLs.
http://grutz.jingojango.net/exploits/
http://michaeldaw.org/projects/web-backdoor-compilation
Labels:
Information Security
Saturday, January 29, 2011
What is RAID?
method for providing fault tolerance by using multiple hard disk drives.
Labels:
Computer Networks
What is NETBIOS and NETBEUI?
NETBIOS is a programming interface that allows I/O requests to be sent to and received from a remote computer and it hides the networking hardware from applications.
NETBEUI is NetBIOS extended user interface. A transport protocol designed by microsoft and IBM for the use on small subnets.
NETBEUI is NetBIOS extended user interface. A transport protocol designed by microsoft and IBM for the use on small subnets.
Labels:
Computer Networks
What is redirector?
Redirector is software that intercepts file or prints I/O requests and translates them into network requests. This comes under presentation layer.
Labels:
Computer Networks
What is Beaconing?
The process that allows a network to self-repair networks problems. The stations on the network notify the other stations on the ring when they are not receiving the transmissions. Beaconing is used in Token ring and FDDI networks.
Labels:
Computer Networks
What is terminal emulation, in which layer it comes?
Telnet is also called as terminal emulation. It belongs to application layer.
Labels:
Computer Networks
What is frame relay, in which layer it comes?
Frame relay is a packet switching technology. It will operate in the data link layer.
Labels:
Computer Networks
What do you meant by "triple X" in Networks?
The function of PAD (Packet Assembler Disassembler) is described in a document known as X.3. The standard protocol has been defined between the terminal and the PAD, called X.28; another standard protocol exists between hte PAD and the network, called X.29. Together, these three recommendations are often called "triple X"
Labels:
Computer Networks
What is SAP?
Series of interface points that allow other computers to communicate with the other layers of network protocol stack.
Labels:
Computer Networks
What are the possible ways of data exchange?
(i) Simplex (ii) Half-duplex (iii) Full-duplex.
Labels:
Computer Networks
Difference between the communication and transmission.
Transmission is a physical movement of information and concern issues like bit polarity, synchronisation, clock etc.
Communication means the meaning full exchange of information between two communication media.
Communication means the meaning full exchange of information between two communication media.
Labels:
Computer Networks
What is subnet?
A generic term for section of a large networks usually separated by a bridge or router.
Labels:
Computer Networks
What are the two types of transmission technology available?
(i) Broadcast and (ii) point-to-point
Labels:
Computer Networks
Friday, January 28, 2011
What is File Manager?
It is a program module, which manages the allocation of space on disk storage and data structure used to represent information stored on a disk.
Labels:
Others
Wednesday, January 26, 2011
[Algorithm]
There is a robery and four persons are suspected out of them one is
actual thief, these are the sentences said by each one of them!
A says D had done
B says A had done
C says i dddnt done
D B lied when he said that i am thief
Out of these only one man is true remaining are false
ans C is thef, D is true!
actual thief, these are the sentences said by each one of them!
A says D had done
B says A had done
C says i dddnt done
D B lied when he said that i am thief
Out of these only one man is true remaining are false
ans C is thef, D is true!
Labels:
Data Structures and Algorithms
[Algorithm]
Logical reasoning tactics practice puzzle poetry.
1) Henny, Axie, Amie are friends. Conditions:-
a) Herry or Axies is the oldest.
b)If Axie is the oldest, Amie is the youngest.
Who is the youngest & who is the oldest?
Ans: Amie is the youngest, Axie is oldest.
1) Henny, Axie, Amie are friends. Conditions:-
a) Herry or Axies is the oldest.
b)If Axie is the oldest, Amie is the youngest.
Who is the youngest & who is the oldest?
Ans: Amie is the youngest, Axie is oldest.
Labels:
Data Structures and Algorithms
[Algorithm]
If the twins are heard saying the following on the same day, which choice presents a correct
statement?
Twin A : "It is Sunday Today".
Twin B : "Yesterday was Sunday".
Twin A : "it is summer season now".
a) It is a summer sunday.
b) It is a summer monday.
c) It is Monday but not summer.
d) It is Sunday but not summer.
e) It is impossible to determine whether it is Sunday or Monday.
statement?
Twin A : "It is Sunday Today".
Twin B : "Yesterday was Sunday".
Twin A : "it is summer season now".
a) It is a summer sunday.
b) It is a summer monday.
c) It is Monday but not summer.
d) It is Sunday but not summer.
e) It is impossible to determine whether it is Sunday or Monday.
Labels:
Data Structures and Algorithms
[Algorithm]
Which of the following statements can be deduced from the information presented?
i) If it is Sunday, the twins will both say so.
ii) If it is not Sunday, one twin will give the correct day and the other will lie about everything.
iii) On any given day, only one twin will give his correct name.
a) i only.
b) i and ii only.
c) i and iii only.
d) ii and iii only.e) i,ii and iii.
i) If it is Sunday, the twins will both say so.
ii) If it is not Sunday, one twin will give the correct day and the other will lie about everything.
iii) On any given day, only one twin will give his correct name.
a) i only.
b) i and ii only.
c) i and iii only.
d) ii and iii only.e) i,ii and iii.
Labels:
Data Structures and Algorithms
[Algorithm]
Two turns have vertain peculiar characteristics. One of them always lies on Monday, Wednesday,
Friday. The other always lies on Tuesdays, thursdays and saturdays. On the other days they tell the truth.
You are given a conversation.
Person A -- Today is sunday and my name is anil.
Person B -- Today is tuesday and my name is Bill. What is today?
Today is tuesday.
Friday. The other always lies on Tuesdays, thursdays and saturdays. On the other days they tell the truth.
You are given a conversation.
Person A -- Today is sunday and my name is anil.
Person B -- Today is tuesday and my name is Bill. What is today?
Today is tuesday.
Labels:
Data Structures and Algorithms
[Algorithm]
Five persons muckerjee, misra, iyer, patil and sharma, all take then first or middle names in the full
names. There are 4 persons having first or middle name of kumar, 3 persons with mohan, 2 persons with
dev and 1 anil.
-- Either mukherjee and patil have a first or middle name of dev or misra and iyer have their first or middle
name of dev.
-- Of mukherkjee and misre, either both of them have a first or middle name of mohan or neither have a
first or middle name of mohan.
-- Either iyer of sharma has a first or middle name of kumar but not both.
Who has the first or middle name of anil?
Today is Mukherjee.
names. There are 4 persons having first or middle name of kumar, 3 persons with mohan, 2 persons with
dev and 1 anil.
-- Either mukherjee and patil have a first or middle name of dev or misra and iyer have their first or middle
name of dev.
-- Of mukherkjee and misre, either both of them have a first or middle name of mohan or neither have a
first or middle name of mohan.
-- Either iyer of sharma has a first or middle name of kumar but not both.
Who has the first or middle name of anil?
Today is Mukherjee.
Labels:
Data Structures and Algorithms
[Algorithm]
Every day a cyclist meets a train at a particular crossing. The road is straignt before the crossing and
both are travelling in the same direction. Cyclist travels with a speed of 10 Kmph. One day the cyclist
comes late by 25 min. and meets the train 5km before the crossing. What is the speed of the train.
60 kmph.
both are travelling in the same direction. Cyclist travels with a speed of 10 Kmph. One day the cyclist
comes late by 25 min. and meets the train 5km before the crossing. What is the speed of the train.
60 kmph.
Labels:
Data Structures and Algorithms
[Algorithm]
An escalator is descending at constant speed. A walks down and takes 50 steps to reach the bottom. B runs down and takes 90 steps in the same time as A takes 10 steps. How many steps are visible when the
escalator is not operating.
ANS. 150.
escalator is not operating.
ANS. 150.
Labels:
Data Structures and Algorithms
[Algorithm]
5 student A, B, C, D, E. One student knows 5 languages. Like that up to one langauge. Conditions:-
*) Spanish is most popular langauge.
*) 3 persons knows Porchigese.
*) B & C normally speak English, but when D gathered, they switched to Spanish because that is only
common between the three.
*) Only langauge common between A, B, E is French.
*) Only langauge common between C & E is Italian.
*) Spanish is most popular langauge.
*) 3 persons knows Porchigese.
*) B & C normally speak English, but when D gathered, they switched to Spanish because that is only
common between the three.
*) Only langauge common between A, B, E is French.
*) Only langauge common between C & E is Italian.
Labels:
Data Structures and Algorithms
4 mathematician has x apples. If he arranges them in rows of 3 one will be left. The same is the casewith 5,7,9 apples. But when he arranged them in rows of 11 non will be left.Find the no. of apples
Ans: 946. (Hint: 11*6 11*11 11*16 11*21 =2E......11*76 =3D946).
Labels:
Data Structures and Algorithms
[Algorithm]
T, U, V are 3 friends digging groups in fields. If T & U can complete i groove in 4 days &, U & V can complete 1 groove in 3 days & V & T can complete in 2 days. Find how many days each takes to complete 1 groove individually.
Ans: 24 days.
Labels:
Data Structures and Algorithms
[Algorithm]
There are some bulbs,which are numbered from 1 to 100.all the bulbs are in on conditions. The
following operations are performed:-
1. Those bulbs number which are divisible by 2 are switched OFF.
2. Those bulbs numbered which are divisible by 3 are switched ON (which are already OFF) and OFF
bulbs are switched ON.
3. Similarly bulbs numbers divisible by 4 are either switched ON or OFF depending upon there previous
condition.
4. This procedure is adopted till 100th bulb.
At the end there were how many bulbs which were in ON condition?
Ans: 10 ( only perfect squares ).
Labels:
Data Structures and Algorithms
[Algorithm]
ABCDE are sisters. Each of them gives 4 gifts and each receives 4 gifts No two sisters give the same
combination ( e.g. if A gives 4 gifts to B then no other sisters can give four to other one.)
(i) B gives four to A.
(ii) C gives 3 to E.
How much did A,B,C,E give to D?
Ans: Donor no of gifts A 1 B - C 1 D 2
combination ( e.g. if A gives 4 gifts to B then no other sisters can give four to other one.)
(i) B gives four to A.
(ii) C gives 3 to E.
How much did A,B,C,E give to D?
Ans: Donor no of gifts A 1 B - C 1 D 2
Labels:
Data Structures and Algorithms
Name the three major set of files on disk that compose a database in Oracle
There are three major sets of files on disk that compose a database. All the files are binary. These are
Database files
Control files
Redo logs
The most important of these are the database files where the actual data resides. The control files and the redo logs support the functioning of the architecture itself.
All three sets of files must be present, open, and available to Oracle for any data on the database to be useable. Without these files, you cannot access the database, and the database administrator might have to recover some or all of the database using a backup, if there is one.
Database files
Control files
Redo logs
The most important of these are the database files where the actual data resides. The control files and the redo logs support the functioning of the architecture itself.
All three sets of files must be present, open, and available to Oracle for any data on the database to be useable. Without these files, you cannot access the database, and the database administrator might have to recover some or all of the database using a backup, if there is one.
Labels:
Others
What is 3NF?
A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following is true
1.X is a Super-key of R.
2.A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
1.X is a Super-key of R.
2.A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
Labels:
Others
What is Set-at-a-time or Set-oriented?
The High level or Non-procedural DML can specify and retrieve many records in a single DML statement. This retrieve of a record is said to be Set-at-a-time or Set-oriented.
Labels:
Others
What is DML (Data Manipulation Language)?
This language that enable user to access or manipulate data as organised by appropriate data model.
1.Procedural DML or Low level: DML requires a user to specify what data are needed and how to get those data.
2.Non-Procedural DML or High level: DML requires a user to specify what data are needed without specifying how to get those data.
1.Procedural DML or Low level: DML requires a user to specify what data are needed and how to get those data.
2.Non-Procedural DML or High level: DML requires a user to specify what data are needed without specifying how to get those data.
Labels:
Others
[Algorithm]
In mathematica country 1,2,3,4....,8,9 are nine cities. Cities which form a no. that is divisible by 3 are
connected by air planes. (e.g. cities 1 & 2 form no. 12 which divisible by 3 then 1 is connected to city 2).
Find the total no. of ways you can go to 8 if you are allowed to break the journies.
Ans: 5.
Labels:
Data Structures and Algorithms
[Algorithm]
Six persons A,B,C,D,E & F went to solider cinima. There are six conseutive seats. A sits in one of the seats followed by B, followed by C and soon. If a taken one of the six seats , then B should sit adjacent to A. C should sit adjacent A or B. D should sit adjacent to A, B,or C and soon. How many possibilities are
there?
ans:32 ways
there?
ans:32 ways
Labels:
Others
[Algorithm]
If the twins are heard saying the following on the same day, which choice presents a correct statement
?
Twin A : "It is Sunday Today"
Twin B : "Yesterday was Sunday"
Twin A : "it is summer season now"
a) it is a summer sunday.
b) it is a summer monday.
c) it is Monday but not summer.d) it is Sunday but not summer.
e) it is impossible to determine whether it is Sunday or Monday.
Labels:
Data Structures and Algorithms
[Algorithm]
Assume that the twins followed a different set of rules, so that on a given day both told only the truth
while next day both only lied, alternating days of truth telling and lying. Under these rules,which of the
following conversations would be possible?
a) Twin A : "Today you are a lier"
Twin B : "That is correct"
b) Twin A : "Today you are a lier"
Twin B : "That is not so"
c) Twin A : "Tommorow we will be liers"
Twin B : "Yesterday we were truthtellers"
d) Twin A : "Tommorow we will be liers"
Twin B : "You are 1 year older than I am"
e) Twin A : "We always tell the truth"
Twin B : "We some times tell the truth".
Labels:
Data Structures and Algorithms
[Algorithm]
According to the information presented, which of the following conversations will be impossible.
a)Twin A : "Today you are a lier"
Twin B : "You are telling the truth"
b)Twin A : "Today you are a lier"
Twin B : "Today I am a truth teller"
c)Twin A : "Tommorow I shall be a lier"
Twin B : "That's correct"
d)Twin A : "Tommorow you will be a lier"
Twin B : "Today you are a truthteller"
e)Twin A : "Yesterday we were both truthtellers"
Twin B : "You are lying".
Labels:
Data Structures and Algorithms
[Algorithm]
Two identical twins have a very unusual characteristic. One tells nothing but lies on Mondays, Wednesdays and Fridays, and tells nothing but the truth all other days. The other tells nothing but lies on Tuesdays, Thursdays and Saturdays, and tells nothing but the truth all other days. On Sundays both
children speak the truth.
children speak the truth.
Labels:
Data Structures and Algorithms
[Algorithm]
The names of the inhabitants of Walkie Talkie Land sound strange to the visitors, and they find it
difficult to pronounce them, due to their length and a few vowel sounds they contain. The Walkie Talkie
guide is discussing the names of four inhabitants –
A,B,C and D. Their names each contain upto eight syllables, although none of the four names contain the
same number. Two of the names contain no vowel sounds; one contains one vowel sound; and onecontains two vowel sounds. From the Guide's statements below, determine the number of syllables and
vowel sounds in each of the four Walkie Talkie names:-
i) The one whose name contains two vowel sounds is not A.
ii) C's name does not contain more than one vowel sound or fewer than seven syllables.
iii) The name with seven syllables does not contain exactly one vowel sound.
iv) B and C do not have names with the same number of vowel sounds.
v) Neither the name with five syllables nor the name with seven syllables contains more than one vowel
sound.
vi) Neither the name with six syllables, nor the B's name, contains two vowel sounds.
difficult to pronounce them, due to their length and a few vowel sounds they contain. The Walkie Talkie
guide is discussing the names of four inhabitants –
A,B,C and D. Their names each contain upto eight syllables, although none of the four names contain the
same number. Two of the names contain no vowel sounds; one contains one vowel sound; and onecontains two vowel sounds. From the Guide's statements below, determine the number of syllables and
vowel sounds in each of the four Walkie Talkie names:-
i) The one whose name contains two vowel sounds is not A.
ii) C's name does not contain more than one vowel sound or fewer than seven syllables.
iii) The name with seven syllables does not contain exactly one vowel sound.
iv) B and C do not have names with the same number of vowel sounds.
v) Neither the name with five syllables nor the name with seven syllables contains more than one vowel
sound.
vi) Neither the name with six syllables, nor the B's name, contains two vowel sounds.
Labels:
Data Structures and Algorithms
[Algorithm]
On the Island of imperfection there is a special road, Logic Lane, on which the houses are usually
reserved for the more mathematical inhabitants. Add, Divide and Even live in three different houses on
this road (which has houses numbered from 1-50). One of them is a member of the Pukka Tribe, who
always tell the truth. Another is a member of the Wotta Tribe, who never tell the truth and the third is a
member of the Shalla Tribe, who make statements which are alternately true and false, or false and true.
They make statements as follows:-
ADD:
1. The number of my house is greater than that of Divide's.
2. My number is divisible by 4.
3. Even's number differs by 13 from that of one of the others.
DIVIDE :
1. Add's number is divisible by 12.
2. My number is 37.
3. Even's number is even.
EVEN :
1. No one's number is divisible by 10.
2. My number is 30.
3. Add's number is divisible by 3.
Find to which tribe each of them belongs, and the number of each of their houses.
Labels:
Data Structures and Algorithms
[Algorithm]
Motorboat A leaves shore P as B leaves Q; they move across the lake at a constant speed. They meet
first time 600 yards from P. Each returns from the opposite shore without halting, and they meet 200
yards from. How long is the lake?
Labels:
Data Structures and Algorithms
[Algorithm]
The Jones have named their four boys after favorite relatives; their friends, the Smiths, have done the
same thing with their three boys. One of the families has twin boys. From the following clues, can you
determine the families of all seven children and their ages?
i) Valentine is 4 years older than his twin brothers.
ii) Winston, who is 8, and Benedict are not brothers. They are each named after a grandfather.
iii) Briscoe is two years younger than his brother Hamilton, But three years older than Dewey.
iv) Decatur is 10 years old.
v) Benedict is 3 years younger than Valentine; they are not related.
vi) The twins are named for uncles.
Labels:
Data Structures and Algorithms
[Algorithm]
The seven digits in this subtraction problem are 0, 1, 2, 3, 4, 5 and 6. Each letter represents the same
digit whenever it occurs.
D A D C B
- E B E G
--------------------
B F E G
--------------------
What digit is represented by each letter?
digit whenever it occurs.
D A D C B
- E B E G
--------------------
B F E G
--------------------
What digit is represented by each letter?
Labels:
Data Structures and Algorithms
[Algorithm]
When Arthur is as old as his father Hailey is now, he shall be 5 times as old as his son Clarke is now.By then, Clarke will be 8 times older than Arthur is now. The combined ages of Hailey and Arthur are 100
years. How old is Clarke?
Labels:
Data Structures and Algorithms
What is disadvantage in File Processing System?
Data redundancy & inconsistency.
Difficult in accessing data.
Data isolation.
Data integrity.
Concurrent access is not possible.
Security Problems.
Difficult in accessing data.
Data isolation.
Data integrity.
Concurrent access is not possible.
Security Problems.
Labels:
Others
what is the output of this program
#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.
#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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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 '' termination character). The third sizeof is similar to the second one.
{
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 '' termination character). The third sizeof is similar to the second one.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
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.
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.
Labels:
C Questions
what is the output of this program
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’.
{
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’.
Labels:
C Questions
what is the output of this program
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’.
{
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’.
Labels:
C Questions
what is the output of this program
main()
{
int i, n;
char *x = “girl”;
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++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 (‘’) to the first location. Now the string becomes “irl” . 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] = ‘’ 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.
{
int i, n;
char *x = “girl”;
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++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 (‘’) to the first location. Now the string becomes “irl” . 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] = ‘’ 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.
Labels:
C Questions
what is the output of this program
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.
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.
Labels:
C Questions
what is the output of this program
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).
{
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).
Labels:
C Questions
what is the output of this program
What are the files which are automatically opened when a C file is executed?
Answer:
stdin, stdout, stderr (standard input,standard output,standard error).
Answer:
stdin, stdout, stderr (standard input,standard output,standard error).
Labels:
C Questions
what is the output of this program
main( )
{
char *q;
int j;
for (j=0; j<3; j++) scanf(“%s” ,(q+j));
for (j=0; j<3; j++) printf(“%c” ,*(q+j));
for (j=0; j<3; j++) printf(“%s” ,(q+j));
}
Explanation:
Here we have only one pointer to type char and since we take input in the same pointer thus we keep writing over in the same location, each time shifting the pointer value by 1. Suppose the inputs are MOUSE, TRACK and VIRTUAL. Then for the first input suppose the pointer starts at location 100 then the input one is stored as
M O U S E
When the second input is given the pointer is incremented as j value becomes 1, so the input is filled in memory starting from 101.
M T R A C K
The third input starts filling from the location 102
M T V I R T U A L
This is the final value stored .
The first printf prints the values at the position q, q+1 and q+2 = M T V
The second printf prints three strings starting from locations q, q+1, q+2
i.e MTVIRTUAL, TVIRTUAL and VIRTUAL.
{
char *q;
int j;
for (j=0; j<3; j++) scanf(“%s” ,(q+j));
for (j=0; j<3; j++) printf(“%c” ,*(q+j));
for (j=0; j<3; j++) printf(“%s” ,(q+j));
}
Explanation:
Here we have only one pointer to type char and since we take input in the same pointer thus we keep writing over in the same location, each time shifting the pointer value by 1. Suppose the inputs are MOUSE, TRACK and VIRTUAL. Then for the first input suppose the pointer starts at location 100 then the input one is stored as
M O U S E
When the second input is given the pointer is incremented as j value becomes 1, so the input is filled in memory starting from 101.
M T R A C K
The third input starts filling from the location 102
M T V I R T U A L
This is the final value stored .
The first printf prints the values at the position q, q+1 and q+2 = M T V
The second printf prints three strings starting from locations q, q+1, q+2
i.e MTVIRTUAL, TVIRTUAL and VIRTUAL.
Labels:
C Questions
what is the output of this program
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
Explanation:
Let us consider the array and the two pointers with some address
a
0 1 2 3 4
100 102 104 106 108
p
100 102 104 106 108
1000 1002 1004 1006 1008
ptr
1000
2000
After execution of the instruction ptr++ value in ptr becomes 1002, if scaling factor for integer is 2 bytes. Now ptr – p is value in ptr – starting location of array p, (1002 – 1000) / (scaling factor) = 1, *ptr – a = value at address pointed by ptr – starting value of array a, 1002 has a value 102 so the value is (102 – 100)/(scaling factor) = 1, **ptr is the value stored in the location pointed by the pointer of ptr = value pointed by value pointed by 1002 = value pointed by 102 = 1. Hence the output of the firs printf is 1, 1, 1.
After execution of *ptr++ increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the second printf are ptr – p = 2, *ptr – a = 2, **ptr = 2.
After execution of *++ptr increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the third printf are ptr – p = 3, *ptr – a = 3, **ptr = 3.
After execution of ++*ptr value in ptr remains the same, the value pointed by the value is incremented by the scaling factor. So the value in array p at location 1006 changes from 106 10 108,. Hence, the outputs for the fourth printf are ptr – p = 1006 – 1000 = 3, *ptr – a = 108 – 100 = 4, **ptr = 4.
{
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
Explanation:
Let us consider the array and the two pointers with some address
a
0 1 2 3 4
100 102 104 106 108
p
100 102 104 106 108
1000 1002 1004 1006 1008
ptr
1000
2000
After execution of the instruction ptr++ value in ptr becomes 1002, if scaling factor for integer is 2 bytes. Now ptr – p is value in ptr – starting location of array p, (1002 – 1000) / (scaling factor) = 1, *ptr – a = value at address pointed by ptr – starting value of array a, 1002 has a value 102 so the value is (102 – 100)/(scaling factor) = 1, **ptr is the value stored in the location pointed by the pointer of ptr = value pointed by value pointed by 1002 = value pointed by 102 = 1. Hence the output of the firs printf is 1, 1, 1.
After execution of *ptr++ increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the second printf are ptr – p = 2, *ptr – a = 2, **ptr = 2.
After execution of *++ptr increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the third printf are ptr – p = 3, *ptr – a = 3, **ptr = 3.
After execution of ++*ptr value in ptr remains the same, the value pointed by the value is incremented by the scaling factor. So the value in array p at location 1006 changes from 106 10 108,. Hence, the outputs for the fourth printf are ptr – p = 1006 – 1000 = 3, *ptr – a = 108 – 100 = 4, **ptr = 4.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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
Explanation:
The given array is a 3-D one. It can also be viewed as a 1-D array.
2 4 7 8 3 4 2 2 2 3 3 4
100 102 104 106 108 110 112 114 116 118 120 122
thus, for the first printf statement a, *a, **a give address of first element . since the indirection ***a gives the value. Hence, the first line of the output.
for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence, the output.
{
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
Explanation:
The given array is a 3-D one. It can also be viewed as a 1-D array.
2 4 7 8 3 4 2 2 2 3 3 4
100 102 104 106 108 110 112 114 116 118 120 122
thus, for the first printf statement a, *a, **a give address of first element . since the indirection ***a gives the value. Hence, the first line of the output.
for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence, the output.
Labels:
C Questions
what is the output of this program
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().
{
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().
Labels:
C Questions
what is the output of this program
main()
{
extern out;
printf("%d", out);
}
int out=100;
Answer:
100
Explanation:
This is the correct way of writing the previous program.
{
extern out;
printf("%d", out);
}
int out=100;
Answer:
100
Explanation:
This is the correct way of writing the previous program.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
#include
main()
{
char s[]={\'a\',\'b\',\'c\',\'\\n\',\'c\',\'\\'};
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\");
main()
{
char s[]={\'a\',\'b\',\'c\',\'\\n\',\'c\',\'\\'};
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\");
Labels:
Others
What is the output of this program
#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.
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.
Labels:
C Questions
What is the output of this program
#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.
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.
Labels:
C Questions
What is the output of this program
#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
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
Labels:
C Questions
What is the output of this program
#include
main()
{
char s[]={'a','b','c','\n','c',''};
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");
main()
{
char s[]={'a','b','c','\n','c',''};
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");
Labels:
C Questions
What is the output of this program
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).
{
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).
Labels:
C Questions
What is the output of this program
#define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
Answer:
100
main()
{
int var12=100;
printf("%d",f(var,12));
}
Answer:
100
Labels:
C Questions
Breaking ColdFusion without authentication
Cold fusion has published critical vulnerability. An attacker can access the application without requiring credentials.
Please follow the steps mentioned in this site.
http://www.infointox.net/?p=59
A good information about this vulnerability can be found in
http://www.gnucitizen.org/blog/coldfusion-directory-traversal-faq-cve-2010-2861/
Please follow the steps mentioned in this site.
http://www.infointox.net/?p=59
A good information about this vulnerability can be found in
http://www.gnucitizen.org/blog/coldfusion-directory-traversal-faq-cve-2010-2861/
Labels:
Information Security
Breaking ColdFusion without authentication
Cold fusion has published critical vulnerability. An attacker can access the application without requiring credentials.
Please follow the steps mentioned in this site.
http://www.infointox.net/?p=59
A good information about this vulnerability can be found in
http://www.gnucitizen.org/blog/coldfusion-directory-traversal-faq-cve-2010-2861/
Please follow the steps mentioned in this site.
http://www.infointox.net/?p=59
A good information about this vulnerability can be found in
http://www.gnucitizen.org/blog/coldfusion-directory-traversal-faq-cve-2010-2861/
Labels:
Others
Tuesday, January 25, 2011
what is the output of this program
#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.
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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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
{
int i=5;
printf("%d",i++ + ++i);
}
Answer:
Output Cannot be predicted exactly.
Explanation:
Side effects are involved in the evaluation of i
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
what is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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
{
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
Labels:
C Questions
What is the output of this program
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.
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.
Labels:
C Questions
What is the output of this program
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).
{
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).
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='') ++*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 ‘’ and p1 points to p thus p1doesnot print anything.
{
char *p="hai friends",*p1;
p1=p;
while(*p!='') ++*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 ‘’ and p1 points to p thus p1doesnot print anything.
Labels:
C Questions
What is the output of this program
#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
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
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
Answer:
hai
Explanation:
\n - newline
\b - backspace
\r - linefeed
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
Answer:
hai
Explanation:
\n - newline
\b - backspace
\r - linefeed
Labels:
C Questions
What is the output of this program
#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.
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.
Labels:
C Questions
What is the output of this program
#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
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
Labels:
Others
What is the output of this program
#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.
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.
Labels:
C Questions
What is the output of this program
#include
main()
{
char s[]={'a','b','c','\n','c',''};
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).
main()
{
char s[]={'a','b','c','\n','c',''};
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).
Labels:
C Questions
What is the output of this program
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).
{
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).
Labels:
C Questions
What is the output of this program
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).
{
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).
Labels:
C Questions
What is the output of this program
#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
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
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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.
{
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.
Labels:
C Questions
What is the output of this program
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.
Labels:
C Questions
What is the output of this program
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.
Labels:
C Questions
What is the output of this program?
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 .
Labels:
C Questions
What is the output of this program?
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.
Labels:
C Questions
What is the output of this program?
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.
Labels:
C Questions
What is the output of this program?
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.
Labels:
C Questions
What is the output of this program?
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].
{
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].
Labels:
C Questions
What is output
void main()
{
int const * p=5;
printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
{
int const * p=5;
printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
Labels:
C Questions
Whether Linked List is linear or Non-linear data structure?
According to Access strategies Linked list is a linear one.
According to Storage Linked List is a Non-linear one.
Labels:
Data Structures and Algorithms
Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?
No.
Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn’t mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.
Labels:
Data Structures and Algorithms
What is a spanning Tree?
A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.
Labels:
Data Structures and Algorithms
In RDBMS, what is the efficient data structure used in the internal storage representation?
B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.
Labels:
Data Structures and Algorithms
What are the types of Collision Resolution Techniques and the methods used in each of the type?
Open addressing (closed hashing),
The methods used include:
Overflow block,
Closed addressing (open hashing)
The methods used include:
Linked list,
Binary tree…
The methods used include:
Overflow block,
Closed addressing (open hashing)
The methods used include:
Linked list,
Binary tree…
Labels:
Data Structures and Algorithms
In an AVL tree, at what condition the balancing is to be done
If the ‘pivotal value’ (or the ‘Height factor’) is greater than 1 or less than –1.
Labels:
Others
There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree?
15.
In general:
There are 2power(n)-1 nodes in a full binary tree.
By the method of elimination:
Full binary trees contain odd number of nodes. So there cannot be full binary trees with 8 or 14 nodes, so rejected. With 13 nodes you can form a complete binary tree but not a full binary tree. So the correct answer is 15.
Note:
Full and Complete binary trees are different. All full binary trees are complete binary trees but not vice versa.
Labels:
Data Structures and Algorithms
What is the bucket size, when the overlapping and collision occur at same time?
One. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values.
Labels:
Data Structures and Algorithms
List out few of the applications that make use of Multilinked Structures?
Sparse matrix,
Index generation.
Labels:
Data Structures and Algorithms
Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.
Prefix Notation:
^ - * +ABC - DE + FG
Postfix Notation:
AB + C * DE - - FG + ^
Labels:
Others
List out few of the Application of tree data-structure?
The manipulation of Arithmetic expression,
Symbol Table construction,
Syntax analysis.
Labels:
Data Structures and Algorithms
How many different trees are possible with 10 nodes ?
1014
For example, consider a tree with 3 nodes(n=3), it will have the maximum combination of 5 different (ie, 23 - 3 = 5) trees.
If there are n nodes, there exist 2power(n)-n different trees.
Labels:
Data Structures and Algorithms
What are the methods available in storing sequential files ?
Straight merging,
Natural merging,
Polyphase sort,
Distribution of Initial runs.
Labels:
Data Structures and Algorithms
Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.
Prefix Notation:
^ - * +ABC - DE + FG
Postfix Notation:
AB + C * DE - - FG + ^
Labels:
Data Structures and Algorithms
What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?
Polish and Reverse Polish notations.
Labels:
Data Structures and Algorithms
What is the data structures used to perform recursion?
Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.
Labels:
Data Structures and Algorithms
Minimum number of queues needed to implement the priority queue?
Two. One queue is used for actual storing of data and another for storing priorities.
Labels:
Data Structures and Algorithms
4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?
The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.
Labels:
Data Structures and Algorithms
What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.
RDBMS – Array (i.e. Array of structures)
Network data model – Graph
Hierarchical data model – Trees
Labels:
Data Structures and Algorithms
List out the areas in which data structures are applied extensively?
Compiler Design,
Operating System,
Database Management System,
Statistical analysis package,
Numerical Analysis,
Graphics,
Artificial Intelligence,
Simulation
Labels:
Data Structures and Algorithms
What is data structure?
A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.
Labels:
Data Structures and Algorithms
Monday, January 24, 2011
Puzzle
Five people A ,B ,C ,D ,E are related to each other.
Four of them make one true statement each as follows.
(i) B is my father's brother.
(ii) E is my mother-in-law.
(iii)C is my son-in-law's brother
(iv)A is my brother's wife.
Ans: (i) D (ii) B (iii) E (iv) C
Four of them make one true statement each as follows.
(i) B is my father's brother.
(ii) E is my mother-in-law.
(iii)C is my son-in-law's brother
(iv)A is my brother's wife.
Ans: (i) D (ii) B (iii) E (iv) C
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
The Bulls, Pacers, Lakers and Jazz ran for a contest.
Anup, Sujit, John made the following statements regarding results.
Anup said either Bulls or Jazz will definitely win
Sujit said he is confident that Bulls will not win
John said he is confident that neither Jazz nor Lakers will win
When the result cameit was found that only one of the above three had made a correct statement.
Who has made the correct statement and who has won the contest.
Ans: Sujith; Lakers
Anup, Sujit, John made the following statements regarding results.
Anup said either Bulls or Jazz will definitely win
Sujit said he is confident that Bulls will not win
John said he is confident that neither Jazz nor Lakers will win
When the result cameit was found that only one of the above three had made a correct statement.
Who has made the correct statement and who has won the contest.
Ans: Sujith; Lakers
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are 3 societies A, B, C.
A lent cars to B and C as many as they had already.
After some time B gave as many tractors to A and C as many as they have.
After sometime c did the same thing. At the end of this transaction each one of them had 24.
Find the cars each orginally had.
Ans: A had 39 cars, B had 21 cars & C had 12 cars
A lent cars to B and C as many as they had already.
After some time B gave as many tractors to A and C as many as they have.
After sometime c did the same thing. At the end of this transaction each one of them had 24.
Find the cars each orginally had.
Ans: A had 39 cars, B had 21 cars & C had 12 cars
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
Three friends divided some bullets equally.
After all of them shot 4 bullets the total number of bullets remaining is equal to the bullets each had after
division.Find the original number divided.
Ans: 18 (2 marks)
Initially . x x x
Now x-4 x-4 x-4
Equation is 3x-12 = x
After all of them shot 4 bullets the total number of bullets remaining is equal to the bullets each had after
division.Find the original number divided.
Ans: 18 (2 marks)
Initially . x x x
Now x-4 x-4 x-4
Equation is 3x-12 = x
Labels:
algorithm,
Data Structures and Algorithms
The time taken to travel in train from Town A to Town B is 5 hours. There are trains starting from both towns at an interval of 1 hour. How many trains meet in 1 trip?
Ans : 10 trains check it as trains come from both sides every hour.
Labels:
algorithm,
Data Structures and Algorithms
Three are three boxes. In first box, two white balls. In second box, 2 black balls. In third box, 1 white & 1 black ball. The lables on the boxes are not correct. Then you have to open one box and to
Open the box labled black & white. If white balls are there then the box labled with white balls
contain black balls and labled with black balls contain one black and one white ball and vice versa, if two
black balls are there.
contain black balls and labled with black balls contain one black and one white ball and vice versa, if two
black balls are there.
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
A man covered 28 steps in 30 seconds but he decided to move fast and covered 34 steps in 18
seconds. How many steps are there on the escalator when stationary?
1. Person1: Most of us are satch J.
Person2: Most of us are jute S.
Person3: Two of us are satch J.
Person4: Three of us are jute J.
Person5: I am satch J we have to find who is satch and who is jute.
Ans: S: Satch J:Jute.
seconds. How many steps are there on the escalator when stationary?
1. Person1: Most of us are satch J.
Person2: Most of us are jute S.
Person3: Two of us are satch J.
Person4: Three of us are jute J.
Person5: I am satch J we have to find who is satch and who is jute.
Ans: S: Satch J:Jute.
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
A person went to a shop and asked for change for 1.15 paise, but he said that he could not only give
change for one rupee but also for 50p, 25p, 10p and 5p. What were the coins he had?
Ans: 1-->50p 4--->10p 1--->25p.
change for one rupee but also for 50p, 25p, 10p and 5p. What were the coins he had?
Ans: 1-->50p 4--->10p 1--->25p.
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are six cards, in which, it has two king cards. All cards are turned down and two cards are
opened.
a) What is the possibility to get at least one king?
b) What is the possibility to get two kings?
opened.
a) What is the possibility to get at least one king?
b) What is the possibility to get two kings?
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are 3 societies A, B amp; C having some tractors each. A Gives B and C as many tractors as
they already have. After some days B gives A and C as many tractors as they have. After some days C gives
A and B as many tractors as they have. Finally each has 24 tractors. What is the original No.of tractors
each had in the beginning?
Ans: A - 39. B - 21. C - 12.
they already have. After some days B gives A and C as many tractors as they have. After some days C gives
A and B as many tractors as they have. Finally each has 24 tractors. What is the original No.of tractors
each had in the beginning?
Ans: A - 39. B - 21. C - 12.
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
A, B, C, D, E related. Four of them made these statements each:-
i) C is my son-in-law's brother.
ii) B is my father's brother.
iii) E is my mother-in-law.
iv) A is my brother's wife.
Who made these statements?
i) C is my son-in-law's brother.
ii) B is my father's brother.
iii) E is my mother-in-law.
iv) A is my brother's wife.
Who made these statements?
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
In certain community, there are thousand married couples. Two thirds of the husbands who are taller
than their wives are also heavier and three quarters of the husbands who are heavier than their wives are
also taller. If there are 120 wives who are taller and heavier than their husbands, how many husbands are
taller and heavier than their wives?
than their wives are also heavier and three quarters of the husbands who are heavier than their wives are
also taller. If there are 120 wives who are taller and heavier than their husbands, how many husbands are
taller and heavier than their wives?
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are 3 piles each contains 10, 15, & 20 stones. There are A, B, C, D, F, G and H persons. One
man can catch upto four stones from any pile. The last man who takes will win. If first A starts next B and
so on, who will win?
Ans : May be F
man can catch upto four stones from any pile. The last man who takes will win. If first A starts next B and
so on, who will win?
Ans : May be F
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are 2 diamonds, 1 spade and 1 club and 1 ace and also 1 king, 1 jack and 1 ace are arranged in a
straight line.
1. The king is at third place.
2. The left of jack is a heart and its right is king.
3. No two red colours are in consecutive.
4. The queens are separated by two cards.
Write the order of which suits (hearts ,clubs)and names (jacks queens etc.) are aranged?
straight line.
1. The king is at third place.
2. The left of jack is a heart and its right is king.
3. No two red colours are in consecutive.
4. The queens are separated by two cards.
Write the order of which suits (hearts ,clubs)and names (jacks queens etc.) are aranged?
Labels:
algorithm,
Data Structures and Algorithms
Puzzle
There are 4 married couples, out of which, 3 poeple in a group is needed. But there should not be his
or her spouse in the group. How many groups are possible?
Ans: 32.
or her spouse in the group. How many groups are possible?
Ans: 32.