tag:blogger.com,1999:blog-18237496481278956102024-03-13T12:18:40.106-07:00Fresher Interview Preparation MaterialFreshers Jobs openings, Test and Interview preparation material, aptitude test papers, technical test papers,interview puzzles, hr questions, group discussion guide. Question and answers for Java, C++, C#, Net, mainframe, sap, oracle and all other technologies.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.comBlogger71125tag:blogger.com,1999:blog-1823749648127895610.post-58463892017700944532009-06-30T23:35:00.000-07:002009-06-30T23:35:02.892-07:00Computer Networks Interview Questions and Answers1. What are 10Base2, 10Base5 and 10BaseT Ethernet LANs<br />10Base2—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling, with a contiguous cable segment length of 100<br />meters and a maximum of 2 segments.<br />10Base5—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling, with 5 continuous segments not exceeding 100<br />meters per segment.<br />10BaseT—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling and twisted pair cabling.<br /><br />2. What is the difference between an unspecified passive open and a fully specified passive open<br />An unspecified passive open has the server waiting for a connection request from a client. A fully specified passive open has the server waiting for a connection from a<br />specific client.<br /><br />3. Explain the function of Transmission Control Block<br />A TCB is a complex data structure that contains a considerable amount of information about each connection.<br /><br />4. What is a Management Information Base (MIB)<br />A Management Information Base is part of every SNMP-managed device. Each SNMP agent has the MIB database that contains information about the device's status, its<br />performance, connections, and configuration. The MIB is queried by SNMP.<br /><br />5. What is anonymous FTP and why would you use it<br />Anonymous FTP enables users to connect to a host without using a valid login and password. Usually, anonymous FTP uses a login called anonymous or guest, with the<br />password usually requesting the user's ID for tracking purposes only. Anonymous FTP is used to enable a large number of users to access files on the host without having<br />to go to the trouble of setting up logins for them all. Anonymous FTP systems usually have strict controls over the areas an anonymous user can access.<br /><br />6. What is a pseudo tty A pseudo tty or false terminal enables external machines to connect through Telnet or rlogin. Without a pseudo tty, no connection can take place.<br /><br />7. What is REX<br />What advantage does REX offer other similar utilities<br /><br />8. What does the Mount protocol do<br />The Mount protocol returns a file handle and the name of the file system in which a requested file resides. The message is sent to the client from the server after reception of a client's request.<br /><br />9. What is External Data Representation<br /> External Data Representation is a method of encoding data within an RPC message, used to ensure that the data is not system-dependent.<br /><br />10. What is the Network Time Protocol ?<br /><br />11. BOOTP helps a diskless workstation boot. How does it get a message to the network looking<br />for its IP address and the location of its operating system boot files BOOTP sends a UDP message with a subnetwork broadcast address and waits for a reply from a server that gives it the IP address. The same message might contain the name of the machine that has the boot files on it. If the boot image location is not specified, the workstation sends another UDP message to query the server.<br /><br />12. What is a DNS resource record<br />A resource record is an entry in a name server's database. There are several types of resource records used, including name-to-address resolution information. Resource<br />records are maintained as ASCII files.<br /><br />13. What protocol is used by DNS name servers<br />DNS uses UDP for communication between servers. It is a better choice than TCP because of the improved speed a connectionless protocol offers. Of course,<br />transmission reliability suffers with UDP.<br />14. What is the difference between interior and exterior neighbor gateways<br />Interior gateways connect LANs of one organization, whereas exterior gateways connect the organization to the outside world.<br /><br />15. What is the HELLO protocol used for<br />The HELLO protocol uses time instead of distance to determine optimal routing. It is an alternative to the Routing<br />Information Protocol.<br /><br />16. What are the advantages and disadvantages of the three types of routing tables<br />The three types of routing tables are fixed, dynamic, and fixed central. The fixed table must be manually modified every time there is a change. A dynamic table changes its<br />information based on network traffic, reducing the amount of manual maintenance. A fixed central table lets a manager modify only one table, which is then read by other<br />devices. The fixed central table reduces the need to update each machine's table, as with the fixed table. Usually a dynamic table causes the fewest problems for a network<br />administrator, although the table's contents can change without the administrator being aware of the change.<br /><br />17. What is a TCP connection table<br />18. What is source route<br />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.<br /><br />19. What is RIP (Routing Information Protocol)<br />It is a simple protocol used to exchange information between the routers.<br /><br />20. What is SLIP (Serial Line Interface Protocol)<br />It is a very simple protocol used for transmission of IP datagrams across a serial line.<br /><br />21. What is Proxy ARP<br />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.<br />22. What is OSPF<br />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.<br /><br />23. What is Kerberos<br />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.<br />24. What is a Multi-homed Host<br />It is a host that has a multiple network interfaces and that requires m ultiple IP addresses is called as a Multi-homed Host.<br /><br />25. What is NVT (Network Virtual Terminal)<br />It is a set of rules defining a very simple virtual terminal interaction. The NVT is used in the start of a Telnet session.<br />26. What is Gateway-to-Gateway protocol<br />It is a protocol formerly used to exchange routing information between Internet core routers.<br /><br />27. What is BGP (Border Gateway Protocol)<br />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<br />system. This is newer than EGP (Exterior Gateway Protocol).<br /><br />28. What is autonomous system<br />It is a collection of routers under the control of a single administrative authority and that uses a common Interior Gateway Protocol.<br /><br />29. What is EGP (Exterior Gateway Protocol)<br />It is the protocol the routers in neighboring autonomous systems use to identify the set of networks that can be reached<br />within or via each autonomous system.<br />Computer Networks Interview Questions<br />30. What is IGP (Interior Gateway Protocol)<br />It is any routing protocol used within an autonomous system.<br />31. What is Mail Gateway<br />It is a system that performs a protocol translation between different electronic mail delivery protocols.<br />32. What is wide-mouth frog<br />Wide-mouth frog is the simplest known key distribution center (KDC) authentication protocol.<br />33. What are Digrams and Trigrams<br />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,<br />and, and ion.<br />34. What is silly window syndrome<br />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<br />receiving side reads 1 byte at a time.<br />35. What is region<br />When hierarchical routing is used, the routers are divided into what we call regions, with each router knowing all the details about how to route packets to destinations<br />within its own region, but knowing nothing about the internal structure of other regions.<br />36. What is multicast routing<br />Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.<br />37. What is traffic shaping<br />One of the main causes of congestion is that traffic is often busy. If hosts could be made to transmit at a uniform rate,<br />congestion would be less common. Another open loop<br />method to help manage congestion is forcing the packet to be transmitted at a more predictable rate. This is called<br />traffic shaping.<br />38. What is packet filter<br />Packet filter is a standard router equipped with some extra functionality. The extra functionality allows every incoming or<br />outgoing packet to be inspected. Packets meeting<br />some criterion are forwarded normally. Those that fail the test are dropped.<br />39. What is virtual path<br />Along any transmission path from a given source to a given destination, a group of virtual circuits can be grouped<br />together into what is called path.<br />Computer Networks Interview Questions<br />40. What is virtual channel<br />Virtual channel is normally a connection from one source to one destination, although multicast connections are also<br />permitted. The other name for virtual channel is virtual<br />circuit.<br />41. What is logical link control<br />One of two sublayers of the data link layer of OSI reference model, as defined by the IEEE 802 standard. This sublayer<br />is responsible for maintaining the link between<br />computers when they are sending data across the physical network connection.<br />42. Why should you care about the OSI Reference Model<br />It provides a framework for discussing network operations and design.<br />43. What is the difference between routable and non- routable protocols<br />Routable protocols can work with a router and can be used to build large networks. Non-Routable protocols are<br />designed to work on small, local networks and cannot be<br />used with a router<br />44. What is MAU<br />In token Ring , hub is called Multistation Access Unit(MAU).<br />45. Explain 5-4-3 rule<br />In a Ethernet network, between any two points on the network, there can be no more than five network segments or four<br />repeaters, and of those five segments only three of<br />segments can be populated.<br />46. What is the difference between TFTP and FTP application layer protocols<br />The Trivial File Transfer Protocol (TFTP) allows a local host to obtain files from a remote host but does not provide<br />reliability or security. It uses the fundamental packet<br />delivery services offered by UDP.<br />The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for copying a file from one host to<br />another. It uses the services offered by TCP and so is<br />reliable and secure. It establishes two connections (virtual circuits) between the hosts, one for data transfer and another<br />for control information.<br />47. What is the range of addresses in the classes of internet addresses<br />Class A 0.0.0.0 - 127.255.255.255<br />Class B 128.0.0.0 - 191.255.255.255<br />Class C 192.0.0.0 - 223.255.255.255<br />Class D 224.0.0.0 - 239.255.255.255<br />Class E 240.0.0.0 - 247.255.255.255<br />48. What is the minimum and maximum length of the header in the TCP segment and IP datagram<br />The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes.<br />Computer Networks Interview Questions<br />49. What is difference between ARP and RARP<br />The address resolution protocol (ARP) is used to associate the 32 bit IP address with the 48 bit physical address, used<br />by a host or a router to find the physical address of<br />another host on its network by sending a ARP query packet that includes the IP address of the receiver.<br />The reverse address resolution protocol (RARP) allows a host to discover its Internet address when it knows only its<br />physical address.<br />50. What is ICMP<br />ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite used by hosts and gateways to<br />send notification of datagram problems back to the<br />sender. It uses the echo test / reply to test whether a destination is reachable and responding. It also handles both<br />control and error messages.<br />51. What are the data units at different layers of the TCP / IP protocol suite<br />The data unit created at the application layer is called a message, at the transport layer the data unit created is called<br />either a segment or an user datagram, at the network<br />layer the data unit created is called the datagram, at the data link layer the datagram is encapsulated in to a frame and<br />finally transmitted as signals along the transmission<br />media.<br />52. What is Project 802<br />It is a project started by IEEE to set standards that enable intercommunication between equipment from a variety of<br />manufacturers. It is a way for specifying functions of the<br />physical layer, the data link layer and to some extent the network layer to allow for interconnectivity of major LAN<br />protocols.<br />It consists of the following:<br />802.1 is an internetworking standard for compatibility of different LANs and MANs across protocols.<br />802.2 Logical link control (LLC) is the upper sublayer of the data link layer which is non-architecture-specific, that is<br />remains the same for all IEEE-defined LANs.<br />Media access control (MAC) is the lower sublayer of the data link layer that contains some distinct modules each<br />carrying proprietary information specific to the LAN product<br />being used. The modules are Ethernet LAN (802.3), Token ring LAN (802.4), Token bus LAN (802.5).<br />802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.<br />53. What is Bandwidth<br />Every line has an upper limit and a lower limit on the frequency of signals it can carry. This limited range is called the<br />bandwidth.<br />54. Difference between bit rate and baud rate.<br />Bit rate is the number of bits transmitted during one second whereas baud rate refers to the number of signal units per<br />second that are required to represent<br />those bits.<br />baud rate = bit rate / N<br />where N is no-of-bits represented by each signal shift.<br />55. What is MAC address<br />Computer Networks Interview Questions<br />The address for a device as it is identified at the Media Access Control (MAC) layer in the network architecture. MAC<br />address is usually stored in ROM on the network<br />adapter card and is unique.<br />56. What is attenuation<br />The degeneration of a signal over distance on a network cable is called attenuation.<br />57. What is cladding<br />A layer of a glass surrounding the center fiber of glass inside a fiber-optic cable.<br />58. What is RAID<br />A method for providing fault tolerance by using multiple hard disk drives.<br />59. What is NETBIOS and NETBEUI<br />NETBIOS is a programming interface that allows I/O requests to be sent to and received from a remote computer and it<br />hides the networking hardware from applications.<br />NETBEUI is NetBIOS extended user interface. A transport protocol designed by microsoft and IBM for the use on small<br />subnets.<br />60. What is redirector<br />Redirector is software that intercepts file or prints I/O requests and translates them into network requests. This comes<br />under presentation layer.<br />61. What is Beaconing<br />The process that allows a network to self-repair networks problems. The stations on the network notify the other<br />stations on the ring when they are not receiving the<br />transmissions. Beaconing is used in Token ring and FDDI networks.<br />62. What is terminal emulation, in which layer it comes<br />Telnet is also called as terminal emulation. It belongs to application layer.<br />63. What is frame relay, in which layer it comes<br />Frame relay is a packet switching technology. It will operate in the data link layer.<br />64. What do you meant by "triple X" in Networks<br />The function of PAD (Packet Assembler Disassembler) is described in a document known as X.3. The standard protocol<br />has been defined between the terminal and the<br />PAD, called X.28; another standard protocol exists between hte PAD and the network, called X.29. Together, these<br />three recommendations are often called "triple X"<br />65. What is SAP<br />Series of interface points that allow other computers to communicate with the other layers of network protocol stack.<br />Computer Networks Interview Questions<br />66. What is subnet<br />A generic term for section of a large networks usually separated by a bridge or router.<br />67. What is Brouter<br />Hybrid devices that combine the features of both bridges and routers.<br />68. How Gateway is different from Routers<br />A gateway operates at the upper levels of the OSI model and translates information between two completely different<br />network architectures or data formats.<br />69. What are the different type of networking / internetworking devices<br />Repeater:<br />Also called a regenerator, it is an electronic device that operates only at physical layer. It receives the signal in the<br />network before it becomes weak, regenerates the original<br />bit pattern and puts the refreshed copy back in to the link.<br />Bridges:<br />These operate both in the physical and data link layers of LANs of same type. They divide a larger network in to smaller<br />segments. They contain logic that allow them to<br />keep the traffic for each segment separate and thus are repeaters that relay a frame only the side of the segment<br />containing the intended recipent and control congestion.<br />Routers:<br />They relay packets among multiple interconnected networks (i.e. LANs of different type). They operate in the physical,<br />data link and network layers. They contain software<br />that enable them to determine which of the several possible paths is the best for a particular transmission.<br />Gateways:<br />They relay packets among networks that have different protocols (e.g. between a LAN and a WAN). They accept a<br />packet formatted for one protocol and convert it to a<br />packet formatted for another protocol before forwarding it. They operate in all seven layers of the OSI model.<br />70. What is mesh network<br />A network in which there are multiple network links between computers to provide multiple paths for data to travel.<br />71. What is passive topology<br />When the computers on the network simply listen and receive the signal, they are referred to as passive because they<br />don’t amplify the signal in any way. Example for<br />passive topology - linear bus.<br />72. What are the important topologies for networks<br />BUS topology:<br />In this each computer is directly connected to primary network cable in a single line.<br />Advantages:<br />Inexpensive, easy to install, simple to understand, easy to extend.<br />STAR topology:<br />In this all computers are connected using a central hub.<br />Advantages:<br />Computer Networks Interview Questions<br />Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.<br />RING topology:<br />In this all computers are connected in loop.<br />Advantages:<br />All computers have equal access to network media, installation can be simple, and signal does not degrade as much as<br />in other topologies because each computer<br />regenerates it.<br />73. What are major types of networks and explain<br />Server-based network<br />Peer-to-peer network<br />Peer-to-peer network, computers can act as both servers sharing resources and as clients using the resources.<br />Server-based networks provide centralized control of network resources and rely on server computers to provide<br />security and network administration<br />74. What is Protocol Data Unit<br />The data unit in the LLC level is called the protocol data unit (PDU). The PDU contains of four fields a destination<br />service access point (DSAP), a source service access<br />point (SSAP), a control field and an information field. DSAP, SSAP are addresses used by the LLC to identify the<br />protocol stacks on the receiving and sending machines<br />that are generating and using the data. The control field specifies whether the PDU frame is a information frame (I -<br />frame) or a supervisory frame (S - frame) or a<br />unnumbered frame (U - frame).<br />75. What is difference between baseband and broadband transmission<br />In a baseband transmission, the entire bandwidth of the cable is consumed by a single signal. In broadband<br />transmission, signals are sent on multiple frequencies, allowing<br />multiple signals to be sent simultaneously.<br />76. What are the possible ways of data exchange<br />(i) Simplex (ii) Half-duplex (iii) Full-duplex.<br />77. What are the types of Transmission media<br />Signals are usually transmitted over some transmission media that are broadly classified in to two categories.<br />Guided Media:<br />These are those that provide a conduit from one device to another that include twisted-pair, coaxial cable and fiber-optic<br />cable. A signal traveling along any of these media<br />is directed and is contained by the physical limits of the medium. Twisted-pair and coaxial cable use metallic that accept<br />and transport signals in the form of electrical<br />current. Optical fiber is a glass or plastic cable that accepts and transports signals in the form of light.<br />Unguided Media:<br />This is the wireless media that transport electromagnetic waves without using a physical conductor. Signals are<br />broadcast either through air. This is done through radio<br />communication, satellite communication and cellular telephony.<br />78. What is point-to-point protocol<br />Computer Networks Interview Questions<br />A communications protocol used to connect computers to remote networking services including Internet service<br />providers.<br />79. What are the two types of transmission technology available<br />(i) Broadcast and (ii) point-to-point<br />80. Difference between the communication and transmission.<br />Transmission is a physical movement of information and concern issues like bit polarity, synchronization, clock etc.<br />Communication means the meaning full exchange of information between two communication media.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-90483831907807016242009-06-29T23:30:00.000-07:002009-06-29T23:30:01.041-07:00Most common Interview Questions on all topicsHR Questions (Most commonly asked Interview Questions)<br />1. Tell me about you!<br />Keep your answer to one or two minutes; don't ramble. Stick to what you've<br />written in your resume summary. To answer this question well, you'll need<br />to start with a solid and concise resume summary.<br />2. What do you know about our company?<br />Do your homework before the interview! Spend some time online or at the<br />library researching the company. Find out as much as you can, including<br />products, size, income, reputation, image, management talent, people,<br />skills, history and philosophy. Project an informed interest; let the<br />interviewer tell you about the company.<br />3. Why do you want to work for us?<br />Don't talk about what you want; first, talk about their needs: You would like<br />to be part of a specific company project; you would like to solve a company<br />problem; you can make a definite contribution to specific company goals.<br />4. What would you do for us?<br />What they really want to know is... What can you do for us that someone<br />else can't? Relate past experiences that show you've had success in<br />solving previous employer problem(s) that may be similar to those of the<br />prospective employer. Make sure you have a strongly worded Employment<br />History section in your resume, that you can refer to.<br />5. What about the job offered do you find the most attractive? Least<br />attractive?<br />List three or more attractive factors and only one minor unattractive factor.<br />6. Why should we hire you?<br />Because of your knowledge, experience, abilities and skills.<br />7. What do you look for in a job?<br />An opportunity to use your skills, to perform and be recognized.<br />8. Please give me your definition of a.... (the position for which you are<br />being interviewed).<br />Keep it brief -- give an action- and results-oriented definition.<br />9. How long would it take you to make a meaningful contribution to our<br />firm?<br />Not long at all -- you expect only a brief period of adjustment to the<br />learning curve.<br />10. How long would you stay with us?<br />As long as we both feel I'm contributing, achieving, growing, etc.<br />Warm-Up Questions<br />1. What made you apply for this position?<br />2. How did you hear about this job opening?<br />3. Briefly, would you summarize your work history & education for me?<br />Work History<br />1. What special aspects of your work experience have prepared you for<br />this job?<br />2. Can you describe for me one or two of your most important<br />accomplishments?<br />3. How much supervision have you typically received in your previous<br />job?<br />4. Describe for me one or two of the biggest disappointments in your<br />work history?<br />5. Why are you leaving your present job? (or, Why did you leave your<br />last job?)<br />6. What is important to you in a company? What things do you look for<br />in an organization?<br />Job Peformance<br />1. Everyone has strengths & weaknesses as workers. What are your<br />strong points for this job?<br />2. What would you say are areas needing improvement?<br />3. How did your supervisor on your most recent job evaluate your job<br />performance? What were some of the good points & bad points of<br />that rating?<br />4. When you have been told , or discovered for yourself , a problem in<br />your job performance, what have you typically done? Can you give<br />me an example?<br />5. Do you prefer working alone or in groups?<br />6. What kind of people do you find it most difficult to work with? Why?<br />7. Starting with your last job, tell me about any of your achievements<br />that were recognized by your superiors.<br />8. Can you give me an example of your ability to manage or supervise<br />others?<br />9. What are some things you would like to avoid in a job? Why?<br />10. In your previous job what kind of pressures did you encounter?<br />11. What would you say is the most important thing you are looking for<br />in a job?<br />12. What are some of the things on your job you feel you have done<br />particularly well or in which you have achieved the greatest<br />success? Why do you feel this way?<br />13. What were some of the things about your last job that you found<br />most difficult to do?<br />14. What are some of the problems you encounter in doing your job?<br />Which one frustrates you the most? What do you usually do about<br />it?<br />15. What are some things you particularly liked about your last job?<br />16. Do you consider your progress on the job representative of your<br />ability? Why?<br />17. How do you feel about the way you & others in the department were<br />managed by your supervisor?<br />18. If I were to ask your present (most recent) employer about your<br />ability as a____________________, what would he/she say?<br />EDUCATION<br />1. What special aspects of your education or training have prepared<br />you for this job?<br />2. What courses in school have been of most help in doing your job?<br />CAREER- GOALS<br />1. What is your long-term employment or career objective?<br />2. What kind of job do you see yourself holding five years from now?<br />3. What do you feel you need to develop in terms of skill & knowledge<br />in order to be ready for that opportunity?<br />4. Why might you be successful in such a job?<br />5. How does this job fit in with your overall career goals?<br />6. Who or what in your life would you say influenced you most with<br />your career objectives?<br />7. Can you pinpoint any specific things in your past experience that<br />affected your present career objectives?<br />8. What would you most like to accomplish if you had this job?<br />9. What might make you leave this job?<br />SELF-ASSESSMENT<br />1. What kind of things do you feel most confident in doing?<br />2. Can you describe for me a difficult obstacle you have had to<br />overcome? How did you handle it? How do you feel this experience<br />affected your personality or ability?<br />3. How would you describe yourself as a person?<br />4. What do you think are the most important characteristics & abilities a<br />person must possess to become a successful ( )? How do you rate<br />yourself in these areas?<br />5. Do you consider yourself a self-starter? If so, explain why ( and give<br />examples)<br />6. What do you consider to be your greatest achievements to date?<br />Why?<br />7. What things give you the greatest satisfaction at work?<br />8. What things frustrate you the most? How do you usually cope with<br />them?<br />CREATIVITY<br />1. In your work experience, what have you done that you consider truly<br />creative?<br />2. Can you think of a problem you have encountered when the old<br />solutions didn't work & when you came up with new solutions?<br />3. Of your creative accomplishments big or small , at work or home,<br />what gave you the most satisfaction?<br />4. What kind of problems have people recently called on you to solve?<br />Tell me what you have devised.<br />DECISIVENESS<br />1. Do you consider yourself to be thoughtful, analytical or do you<br />usually make up your mind fast? Give an example. (Watch time taken<br />to respond)<br />2. What was your most difficult decision in the last six months? What<br />made it difficult?<br />3. The last time you did not know what decision to make, what did you<br />do?<br />4. How do you go about making an important decision affecting your<br />career?<br />5. What was the last major problem that you were confronted with?<br />What action did you take on it?<br />RANGE OF INTERESTS<br />1. What organizations do you belong to?<br />2. Tell me specifically what you do in the civic activities in which you<br />participate. (Leading questions in selected areas. i.e. sports,<br />economics, current events, finance.)<br />3. How do you keep up with what's going on in your company / your<br />industry/ your profession?<br />MOTIVATION<br />1. What is your professional goal?<br />2. Can you give me examples of experience on the job that you felt<br />were satisfying?<br />3. Do you have a long & short-term plan for your department? Is it<br />realistic?<br />4. Did you achieve it last year?<br />5. Describe how you determine what constitutes top priorities in the<br />performance of your job.<br />WORK STANDARDS<br />1. What are your standards of success in your job?<br />2. In your position, how would you define doing a good job? On what<br />basis was your definition determined?<br />3. When judging the performance of your subordinate, what factors or<br />characteristics are most important to you?<br />LEADERSHIP<br />1. In your present job what approach do you take to get your people<br />together to establish a common approach to a problem?<br />2. What approach do you take in getting your people to accept your<br />ideas or department goals?<br />3. What specifically do you do to set an example for your employees?<br />4. How frequently do you meet with your immediate subordinates as a<br />group?<br />5. What sort of leader do your people feel you are? Are you satisfied?<br />6. How do you get people who do not want to work together to<br />establish a common approach to a problem?<br />7. If you do not have much time & they hold seriously differing views,<br />what would be your approach?<br />8. How would you describe your basic leadership style? Give specific<br />examples of how you practice this?<br />9. Do you feel you work more effectively on a one to one basis or in a<br />group situation?<br />10. Have you ever led a task force or committee or any group who<br />doesn't report to you, but from whom you have to get work? How did<br />you do it? What were the satisfactions & disappointments? How<br />would you handle the job differently?<br />ORAL PRESENTATION SKILLS<br />1. Have you ever done any public or group speaking? Recently? Why?<br />How did it go?<br />2. Have you made any individual presentations recently? How did you<br />prepare?<br />WRITTEN COMMUNICATION SKILLS<br />1. Would you rather write a report or give a verbal report? Why?<br />2. What kind of writing have you done? For a group? For an individual?<br />3. What is the extent of your participation in major reports that have to<br />be written?<br />FLEXIBILITY<br />1. What was the most important idea or suggestion you received<br />recently from your employees? What happened as a result?<br />2. What do you think about the continuous changes in company<br />operating policies & procedures?<br />3. How effective has your company been in adapting its policies to fit a<br />changing environment?<br />4. What was the most significant change made in your company in the<br />last six months which directly affected you, & how successfully do<br />you think you implemented this change?<br />STRESS TOLERANCE<br />1. Do you feel pressure in your job? Tell me about it.<br />2. What has been the highest pressure situation you have been under<br />in recent years? How did you cope with it?<br />STABILITY & MATURITY<br />1. Describe your most significant success & failure in the last two<br />years.<br />2. What do you like to do best?<br />3. What do you like to do least?<br />4. What in your last review did your supervisor suggest needed<br />improvement?<br />5. What have you done about it?<br />INTEREST IN SELF DEVELOPMENT<br />1. What has been the most important person or event in your own self<br />development?<br />2. How much of your education did you earn?<br />3. What kind of books & other publications do you read?<br />4. Have you taken a management development course?<br />5. How are you helping your subordinates develop themselves?<br />TESTING GENERAL<br />1. What is workadround ?<br />2. What is a show stopper?<br />3. What is Traceability Matrix? Who prepares this document?<br />4. What is testlog document in testing process?<br />5. What is the Entry And Exit Criteria of a test plan? 2.How to Automate<br />your test plan?<br />6. What is the role of QA in a company that produces software?<br />7. What is terminologe? Why testing necessary? Fundamental test process<br />psychology of testing<br />8. What are the common bugs encountered while testing an application<br />manually or using test?<br />9. What are the bug and testing metrics?<br />10. For a bug with high severity can we give the priority also to be high...If<br />so why we need both?<br />11. How would you differentiaite between Bug, Defect, Failure, Error.<br />12. What is the difference between Client Server Testing and Web Testing?<br />13. What is backward compatibility testing ?<br />14. What certifications are available in testing?<br />15. What is release candidate?<br />16. What do you think the role of test-group manager should be?<br />17. What is a test data? Give examples<br />18. What is the difference between QA, QC and testing?<br />19. What is seviarity & priority? What is test format? Test procedure?<br />20. What are the different is manual database checking types?<br />WEB TESTING<br />1. What is the difference between testing in client-server applications and<br />web based applications?<br />2. Without using GUI map editor, Can we recognise the application in<br />Winrunner?<br />3. What command is used to launch a application in Winrunner?<br />4. What is the difference in testing a CLIENT-SERVER application and a<br />WEB application ?<br />6. What bugs are mainly come in Web Testing? What severity and priority<br />we are giving?<br />WHITE BOX TESTING<br />1. What are the table contents in test plans and test cases?<br />2. What are the tables in test plans and test cases?<br />WIRELESS TESTING<br />1. What is Wireless Testing? How do we do it? What are the concepts a test<br />engineer should have knowledge of? How do you classify testing of<br />wireless products?<br />TEST CASES<br />1. How will you prepare test cases?<br />2. Write the testcases on ATM Transactions?<br />3. What is meant by Hot Keys?<br />4. How is test case written?<br />5. How can we write a good test case?<br />6. How will you check that your test cases covered all the requirements<br />7. For a triangle (sum of two sides is greater than or equal to the third side),<br />what is the minimal number of test cases required.<br />TEST DIRECTOR<br />1. Difference between WEBINSPECT-QAINSPECT and WINRUNNER/TEST<br />DIRECTOR?<br />2. How will you generate the defect ID in test director? Is it generated<br />automatically or not?<br />3. Difference between TD 8.0 (Test director) and QC 8.0 (Quality Center).<br />4. How do you ensure that there are no duplication of bugs in Test<br />Director?<br />5. Difference between WinRunner and Test Director?<br />6. How will you integrated your automated scripts from TestDirector?<br />7. What is the use of Test Director software?<br />TESTING-SCENARIOS<br />1. How to find out the length of the edit box through WinRunner?<br />2. Is it compulsary that a tester should study a Design Document for writing<br />integration and system test casses<br />3. What is Testing Scenario? What is scenario based testing? Can you<br />explain with an example?<br />4. Lets say we have an GUI map and scripts, and we got some 5 new pages<br />included in an application, How do we do that?<br />5. How do you complete the testing when you have a time constraint?<br />6. Given an yahoo application how many test cases u can write?<br />7. GUI contains 2 fields. Field 1 to accept the value of x and Field 2 displays<br />the result of the formula a+b/c-d where a=0.4*x, b=1.5*a, c=x, d=2.5*b; How<br />many system test cases would you write<br />8. How do you know that all the scenarios for testing are covered?<br />TEST AUTOMATION<br />1. Give me an example where you have customized an automated test<br />script.<br />2. What steps have you followed while automating?<br />.......a) Running the test manually and ensuring a "pass".<br />.......b) Recording<br />.......c) Checkpoints/Verification<br />3. Can you automate Context-sensitive help? If so, how do you that?<br />4. What are the major differences between Stress testing, Load testing,<br />Volume testing?<br />5. What is the difference between quality assurance and testing?<br />6. What are the main attributes of test automation?<br />7. What is data - driven automation?<br />8. What is 'configuration management'?<br />9. What is memory leaks and buffer overflows?<br />10. Why does software have bugs?<br />11. How do you do usability testing, security testing, installation testing,<br />ADHOC, safety and smoke testing?<br />12. Describe some problem that you had with automating testing tool.<br />13. How do we test for severe memory leakages?<br />14. What are the problems encountered during the testing the application<br />compatibility on different browsers and on different operating systems<br />15. How will you evaluate the fields in the application under test using<br />automation tool?<br />16. How did you use automating testing tools in your job?<br />17. What skills needed to be a good test automator?<br />18. Can the activities of test case design be automated?<br />19. What types of scripting techniques for test automation do you know?<br />.What are scripting techniques? Could you describe the 5 techniques<br />mentioned?<br />20. What tools are available for support of testing during software<br />development life cycle?<br />SOFTWARE TESTING<br />1. What is the diffrence between Regression testing and Retesting?<br />2. What are the errors encountered while testing an application manually or<br />using automated tool like Testdirector, Winrunner?<br />3. What is Inspection, Review?<br />4. What is the actual different between re-testing and regressiontesting.<br />brefily explain<br />5. Explain Test Strategy<br />6. What is Tracebility Matrix ?<br />7. What are the major diff. between the Winrunner 6.0 and 7.0 (with internal<br />procedure)?<br />8. What test you perform mostly? Regression or retesting in your testing<br />process?<br />9. What did you do as a team leader?<br />10. How do we know about the build we are going to test? where do you<br />see this?<br />11. What is system testing and what are the different types of tests you<br />perform in system testing?<br />12. What is the difference between Return and treturn?<br />13. How do you test a weblink which is changing dynamically?<br />14. What are the flaws in water fall model and how to overcome it?<br />15. What is defect leakage?<br />16. Did you ever have to deal with someone who doesn't believe in testing?<br />What did u do?<br />17. How will you write test cases for a code currently under development?<br />18. Describe the last project scenario and generate test cases for it?<br />19. If there are a lot of bugs to be fixed, which one would you resolve first<br />20. How will you test a stapler?<br />QA TESTING<br />1. If the actual result doesn't match with expected result in this situation<br />what should we do?<br />2. What is the importance of requirements traceability in a product testing?<br />3. When is the best time for system testing?<br />4. What is use case? What is the diffrence between test cases and use<br />cases?<br />5. What is the difference between the test case and a test script<br />6. Describe to the basic elements you put in a defect report?<br />7. How do you test if you have minimal or no documentation about the<br />product?<br />8. How do you decide when you have tested enough?<br />9. How do you determine what to test?<br />10. In general, how do you see automation fitting into the overall process of<br />testing?<br />11. How do you deal with environments that are hostile to quality change<br />efforts?<br />12. Describe to me the Software Development Life Cycle as you would<br />define it?<br />13. Describe to me when you would consider employing a failure mode and<br />defect analysis?<br />14. What is the role of QA in a company that produces software?<br />15. How do you scope, organize, and execute a test project?<br />16. How can you test the white page<br />17. What is the role of QA in a project developement?<br />18. How you used whitebox and block box technologies in your<br />application?<br />19. 1) What are the demerits of winrunner?2) We write the test data after<br />what are the principles to do testing an application?<br />20. What is the job of Quality Assurance Engineer? Difference between the<br />Testing & Quality Assurance job.<br />WINRUNNER INTERVIEW QUESTIONS<br />1.. How to recognise the objects during runtime in new build version (test<br />suite) comparing with old guimap?<br />2. wait(20) - What is the minimum and maximum time the above mentioned<br />synchronization statements will wait given that the global default timeout is<br />set to 15 seconds.<br />3. Where in the user-defined function library should a new error code be<br />defined?<br />4. In a modular test tree, each test will receive the values for the parameters<br />passed from the main test. These parameters are defined in the Test<br />properties dialog box of each test.Refering to the above, in which one of<br />the following files are changes made in the test properties dialog saved?<br />5. What is the scripting process in Winrunner?<br />6. How many scripts can we generate for one project?<br />7. What is the command in Winrunner to invoke IE Browser? And once I<br />open the IE browser is there a unique way to identify that browser?<br />8. How do you load default comments into your new script like IDE's?<br />9. What is the new feature add in QTP 8.0 compare in QTP 6.0<br />10. When will you go to automation?<br />11. How to test the stored procedure?<br />12. How to recognise the objects during runtime in new build version (test<br />suite) comparing with old guimap<br />13. what is use of GUI files in winrunner.<br />14. Without using the datadriven test, how can we test the application with<br />different set of inputs?<br />15. How do you load compiled module inside a comiled module?<br />16. Can you tell me the bug life cycle<br />17. How to find the length of the edit box through WinRunner?<br />18. What is file type of WinRunner test files, its extension?<br />19. What is candidate release?<br />20. What type of variables can be used with in the TSL function?<br />RATIONAL ROBOT<br />1. In which directory are the .sbl files stored?<br />2. What SQABasic commands have you used?<br />3. Difference between SQAgetpropertyArray and SQAGetPropertyAsString?<br />4. What do .sbl and .sbh represent?<br />5. Is there any Load testing tool called Rational Site Load tool?<br />6. What is the difference between rational robot and QTP or Winrunner?<br />Which is more ueful of the three?<br />7. What is the difference between Rational Robot (Rational Functional<br />Tester) and IBM functional tester? which is better?<br />QTP<br />1. How can I add an action (external action) programmatically?<br />2. How can I call an external action, which is not added external action of<br />an action.<br />3. What is meant by Source Control?<br />4. How and what kind of VB functions do u use in QTP?<br />5. How can u describe the basic flow of automation with conditional and<br />programmatic logic?<br />6. How can I implement error handling in QTP,<br />7. How to recall a function in QTP<br />8. Give one example where you have used Regular Expression?<br />9. How can I implement error handling in QTP?<br />10. How to select particular value from the combo box in the current page<br />which is entered in the previous page edit box after parameterization?<br />11. If you have the same application screen with 7 drop down boxes and<br />approximately 70 values how do you test with QTP?<br />12. When there is a task that gets repeated in multiple scripts, what do you<br />do in QTP?<br />13. What is the descriptive programming?<br />14. What is the use of descriptive programming?<br />15. How to instruct QTP to display errors and other description in the test<br />results instead of halting execution by throwing error in the mid of<br />execution due to an error (for example Object not found)?<br />16. How you write scripts in QTP? What's the main process in QTP? How<br />do you run scripts in QTP? Please anyone can answer my questions.......<br />17. What is descriptive programming?<br />18. How to add run-time parameter to a datasheet?<br />19. How to load the *.vbs or test generating script in a new machine?<br />20. How can you write a script without using a GUI in QTP?<br />LOADRUNNER<br />1. What is load testing? Can we test J2ME application with load runner ?<br />What is Performance testing?<br />2. Which protocol has to be selected for record/playback Oracle 9i<br />application?<br />3. What are the enhancements which have been included in loadrunner 8.0<br />when compared to loadrunner 6.2?<br />4. Can we use Load Runner for testing desktop applications or non web<br />based applications and how do we use it.?<br />5. How to call winrunner script in Loadrunner?<br />6. What arr the types of parameterisation in load runner? List the step to do<br />strees testing?<br />7. What are the steps for doing load and performance testing using Load<br />Runner?<br />8. What is concurrent load and corollation? What is the process of load<br />runner?<br />9. What is planning for the test?<br />10. What enables the controller and the host to communicate with each<br />other in Load Runner?<br />11. Where is Load testing usually done?<br />12. What are the only means of measuring performance?<br />13. Testing requirement and design are not part of what?<br />14. According to Market analysis 70% of performance problem lies with<br />what?<br />15. What is the level of system loading expected to occur during specific<br />business scenario?<br />16. What is run-time-setting.<br />17. When load runner is used .<br />18. What protocols does LoadRunner support?<br />19. What do you mean by creating vuser script.?<br />20. What is rendezvous point?<br />LOAD TESTING<br />1. What are the uses of load testing ? What is defered graphs? What are the<br />different components in loadrunner?<br />2. How you analyze graphics in loadrunner? How do you work bug log?<br />3. How can data caching have a negative effect on load testing results?<br />4. What criteria would you use to select Web transactions for load testing?<br />5. For what purpose are virtual users created?<br />6. What is the difference between Load testing and Performace Testing?<br />7. Why do you need to parameterize fields in your virtual user script?<br />8. What are the reasons why parameterization is necessary when load<br />testing the Web server and the database server?<br />9. Why it is recommended to add verification checks to your all your<br />scenarios?<br />10. Load Testing - What should be analyzed.<br />11. In what situation would you want to parameterize a text verification<br />check?<br />12. What usually indicates that your virtual user script has dynamic data<br />that is dependent on you parameterized fields?<br />13. What are the benefits of creating multiple actions within any virtual user<br />script?<br />DATABASE TESTING<br />1. What SQL statements have you used in Database Testing?<br />2. How to test data loading in Database testing<br />3. What is way of writing testcases for database testing?<br />4. What is Database testing?<br />5. What we normally check for in the Database Testing?<br />6. How to Test database Manually? Explain with an example<br />COMMON INTERVIEW QUESTIONS<br />1. What Technical Environments have you worked with?<br />2. Have you ever converted Test Scenarios into Test Cases?<br />3. What is the ONE key element of 'test case'?<br />4. What is the ONE key element of a Test Plan?<br />5. What is SQA testing? tell us steps of SQA testing<br />6. How do you promote the concept of phase containment and defect<br />prevention?<br />7. Which Methodology you follow in your Testcase?<br />8. Specify the tools used by MNC companies<br />9. What are the test cases prepared by the testing team<br />10. During the start of the project how will the company come to an<br />conclusion that tool is required for testing or not?<br />11. Define Bug Life Cycle? What is Metrics<br />12. What is a Test procedure?<br />13. What is the difference between SYSTEM TESTING and END-TO-END<br />TESTING?<br />14. What is Traceability Matrix? Is there any interchangeable term for<br />Traceability Matrix ?Are Traceability Matrix and Test Matrix same or<br />Different ?<br />15. What is the differance between an exception and an error?<br />16. Correct bug tracking process - Reporting, Re-testing, Debigging, .....?<br />17. What is the difference between bug and defect?<br />18. How much time is/should be alloated for Testing out of total<br />Development time based on industry standards?<br />19. What are test bugs?<br />20. Define Quality - bug free, Functionality working or both?<br />COMMON QUESTIONS<br />1. If you have an application, but you do not have any requiremnts<br />available, then how would you perform the testing?<br />2. How can you know if a test case is necessary?<br />3. What is peer review in practical terms?<br />4. How do you know when you have enough test cases to adequately test a<br />software system or module?<br />5. Who approved your test cases?<br />6. What will you when you find a bug?<br />7. What test plans have you written?<br />8. What is QA? What is Testing? Are they both same or different?<br />9. How to write Negative Testcase? Give ex.<br />10. In an application currently in production, one module of code is being<br />modified. Is it necessary to re-test the whole application or is it enough to<br />just test functionality associated with that module?<br />11. What is included in test strategy? What is overall process of testing<br />step by step and what are various documnets used testing during process?<br />12. What is the most challenging situation you had during testing<br />13. What are you going to do if there is no Functional Spec or any<br />documents related to the system and developer who wrote the code does<br />not work in the company anymore, but you have system and need to test?<br />14. What is the major problem did you resolve during testing process<br />15. What are the types of functional testing?<br />16. 1. How will you write integration test cases 2. How will you track bugs<br />from winrunner. 3.How will you customise the bugs as pass/fail. 4. You find<br />a bug How will you repair 5. In testcases you have bug or not. 6. What is<br />use case ? what does it contains.<br />17. What is the difference between smoke testing and sanity testing<br />18. What is Random Testing?<br />19. What is smoke testing?<br />20. What is stage containment in testing?<br />BUG TRACKING<br />1. What is the difference between a Bug and a Defect?<br />2. How to post a BUG<br />3. How do we track a bug?plz send format of excel sheet in which we write<br />the bug details? How do we give the severithy and priority to the bugs?<br />4. What are the different types of Bugs we normally see in any of the<br />Project? Include the severity as well.<br />5. Top Ten Tips for Bug Tracking<br />DB2 INTERVIEW QUESTIONS<br />1. Can you display the index?<br />2. At what stage db2 must be up?<br />3. When do you use subroutines?<br />4. Initial position of cursor of the exucuton of open statements?<br />5. What is the index ,types of index ?<br />6. How many clustering indexes are pasing for a table?<br />7. When u will use curser with hold option?<br />8. File opening modes in cobol and corresponding dispositions?<br />9. What will happened .if the file is open in extend mode and<br />corresponding is equal to old in jcl?<br />10. How to know other person job status?<br />11. What will happened ,if the subprogram is called second time?<br />12. Can u see s9(4)comp3 data?<br />13. Commenly facing errors?<br />14. What is low values and high values?<br />15. How to enter in xpediter?<br />16. A dataset contains 1000 records ,I want to brouse particular record in<br />file-id?<br />17. There are two programs say A&B,A is only cobol program,B iscoboldb2<br />program, how to compile both programs?<br />18. How to pass return codes from Cobol to jcl?<br />19. In my jcl ,the 1st step is delete step, if the data set is existing, I want to<br />delete, that one ,if dataset is no existing, I do not want abend the job, how<br />can I code in disp?<br />20. What is diff b/w check pending and copy pending?<br />21. How to Repair the table?<br />22. How to see the status of the table?<br />23. How to load data to a table?<br />24. What is diff b/w QMF & Spoofi?<br />25. I have update Row in table using spoofi.how Revert that update Row it<br />means original position?<br />26. Quick Respendse and REspondce time in file-aid?<br />27. File contains 5 records say D,E,F,C,A-I want to copy D and A records<br />only by using file-aid?<br />28. What is severity one error in production support?<br />29. How to increase table space in db2?<br />30. What is the indexset and sequence set in vsam ksds?<br />31. How to read last record in vsam file.,I don't know how many records<br />are there?<br />32. I have 1000 records in vsam,I want to read records 500 to 900<br />33. Explain Reuse and upgrade<br />34. How do you read vsam file?<br />35. How can we over come the same situation when using flat file.<br />36. what r the compiler options we use?where the compiler option will<br />be?What is the need of compiler options?<br />37. Suppose there is cobol-db2 program.I made changes only in the cobol<br />program.Is there need recomile the DBRM again?why?<br />38. After bind i how can we run a cobol-db2 program?<br />39. By using any condition is there any way to abend a program.?If so<br />how?<br />40. What is the diff bet plan,package,dbrm?<br />41. After retrieving the elements from production,how can do the testing<br />before moving the changes to production. Whether we have to create the<br />JCL for testing or it will automatically tested and compiled?<br />42. What is a packed decimal..?<br />DATASTAGE INTERVIEW QUESTIONS<br />1. How do you rename all of the jobs to support your new File-naming<br />conventions?<br />2. Does the selection of 'Clear the table and Insert rows' in the ODBC stage<br />send a Truncate statement to the DB or does it do some kind of Delete<br />logic.<br />3. Tell me one situation from your last project, where you had faced<br />problem and How did u solve it?<br />4. The above might rise another question: Why do we have to load the<br />dimensional tables first, then fact tables:<br />5. How will you determine the sequence of jobs to load into data<br />warehouse?<br />6. What are the command line functions that import and export the DS<br />jobs?<br />7. What is the utility you use to schedule the jobs on a UNIX server other<br />than using Ascential Director?<br />8. How would call an external Java function which are not supported by<br />DataStage?<br />9. What will you in a situation where somebody wants to send you a file<br />and use that file as an input or reference and then run job.<br />10. Read the String functions in DS<br />11. How did u connect with DB2 in your last project?<br />12. What are Sequencers?<br />13. How did you handle an 'Aborted' sequencer?<br />14. What are other Performance tunings you have done in your last project<br />to increase the performance of slowly running jobs?<br />15. How did you handle reject data?<br />16. If worked with DS6.0 and latest versions what are Link-Partitioner and<br />Link-Collector used for?<br />17. What are Routines and where/how are they written and have you<br />written any routines before?<br />18. What are OConv () and Iconv () functions and where are they used?<br />19. How did u connect to DB2 in your last project?<br />20. Do u know about METASTAGE?<br />21. Do you know about INTEGRITY/QUALITY stage?<br />22. Explain the differences between Oracle8i/9i?<br />23. How good are you with your PL/SQL?<br />24. Did you work in UNIX environment?<br />25. What other ETL's you have worked with?<br />26. What versions of DS you worked with?<br />27. What is DS Designer used for - did u use it?<br />28. What is DS Administrator used for - did u use it?<br />29. What is DS Director used for - did u use it?<br />30. What is DS Manager used for - did u use it?<br />31. What are Static Hash files and Dynamic Hash files?<br />32. What is Hash file stage and what is it used for?<br />33. Have you ever involved in updating the DS versions like DS 5.X, if so<br />tell us some the steps you have taken in doing so?<br />34. Did you Parameterize the job or hard-coded the values in the jobs?<br />35. How do you merge two files in DS?<br />.NET INTERVIEW QUESTIONS<br />1. Explain the differences between Server-side and Client-side code?<br />2. What type of code (server or client) is found in a Code-Behind class?<br />3. Should validation (did the user enter a real date) occur server-side or<br />client-side? Why?<br />4. What does the "EnableViewState" property do? Why would I want it on or<br />off?<br />5. What is the difference between Servers? Transfer and Response.<br />Redirect? Why would I choose one over the other?<br />6.Can you give an example of when it would be appropriate to use a web<br />service as opposed to a non-serviced .NET component<br />7.Let's say I have an existing application written using Visual Studio 6 (VB<br />6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction<br />services. How would you approach migrating this application to .NET<br />8.Can you explain the difference between an ADO.NET Dataset and an ADO<br />Recordset?<br />9. Can you give an example of what might be best suited to place in the<br />Application Start and Session Start subroutines?<br />10. If I'm developing an application that must accommodate multiple<br />security levels though secure login and my ASP.NET web application is<br />spanned across three web-servers (using round-robin load balancing) what<br />would be the best approach to maintain login-in state for the users?<br />JAVA INTERVIEW QUESTIONS<br />JAVA:-<br />1) What is static variable.<br />2) What is transient variable?<br />3) What is final variable.<br />4) What is final method.<br />5) What is native method.<br />6) What is abstract method<br />7) what is innerclass.<br />8) What is static class?<br />9) What is final class.<br />10) What is anonymous class?<br />JDBC:<br />1) What is a transaction. (*)<br />2) What is the purpose of setAutoCommit(). (*)<br />3) What are the three statements in JDBC & differences between them. (*)<br />4) What is stored procedure. How do you create stored procedure? (*)<br />5) What are batch updates.<br />JSP:<br />1)What is JSP. (*)<br />2)What are advantages of JSP.<br />3)What is the difference between include directive & jsp:include action. (*)<br />4)What are Custom tags. Why do you need Custom tags. How do you<br />create Custom tag. (*)<br />5)What are the implicit objects in JSP & differences between them. (*)<br />Servlets:<br />1)What are Servlets.<br />2)What are the advantages of Servlet.<br />3)What is the Life cycle of Servlet. (*)<br />4)What is the difference between Servlet and JSP. (*)<br />EJB:- (All questions are important)<br />1)What is the difference between normal Java object and EJB.<br />2)What is the difference between JavaBean and EJB.<br />3)What is EJB.<br />4)What is Session Bean. What are the various types of Session Bean.<br />XML:-<br />1)What is the difference between SAX parser and DOM parser. (*)<br />2)What is the difference between Schema and DTD. (*)<br />3)How do you parse/validate the XML document. (*)<br />4)What is XML Namespace.<br />5)What is Xpath.<br />PEOPLESOFT INTERVIEW QUESTIONS<br />1)What is the APP engine event in peoplecode.<br />2)what are the different actions in APP ENGINE.<br />3)How many temp records are there in app engine.<br />4)How do you debug your AE.<br />5)Why temp records are needed?<br />6)Why state records are needed?<br />7)Differences between State and temp records.<br />8)Different ways to run AE, SQR.(Command, process scheduler)<br />7)Different sql statements and metasql statements.<br />8)How do you retrieve a value from scroll..scroll select?<br />9)What is scroll select, etc<br />10)what is record, row peoplecode.<br />DATABASE QUESTIONS<br />1)What are copybooks(DB2)?<br />2)What is plan?<br />3)Tell me the sections in COBOL?<br />4)Connectivity to DB2 from COBOL.<br />5)What are the customizations in COBOL?<br />6)Diff between union and union all?<br />7)Give me example for group by.<br />8)What is SPUFI?<br />9)Replacement of query analyzer--- SPUFI(DB2)<br />ABAP QUESTIONS:<br />1.Elementary search helps, Collective search help.<br />2.Difference between Search Helps and Match Codes<br />3.Have you created database tables?<br />4.Difference between client dependent and client independent tables?<br />5.How to create client independent tables<br />6.Have you created Maintenance dialog or Table Maintenance?<br />7.On ABAP: Did you set up a workflow? Are you familiar with all steps for<br />setting up a workflow?<br />8.Have you used performance tuning? What major steps will you use for<br />these?<br />9.In the ‘select’ statement what is “group by”?<br />10.Have you worked with field groups? Have you used Import/Export<br />statements?<br />ABAP EDITOR:<br />1.Fixed point arithmetic – what is the use? How to set this?<br />2.Have you used client dependent ABAP programs?<br />DATABASE COMMANDS:<br />1.Select statement to read data into internal tables. Types of Select<br />statements<br />2.What happens “Update” command is used without where clause ?<br />3.Difference between “Insert”, “Update” and “Modify”<br />4.Explain “Commit” and “Roll back”<br />5.“Catch” Command<br />6.What is “Group by” in Select statement?<br />TEST AUTOMATION:<br />1.What automating testing tools are you familiar with?<br />2.How did you use automating testing tools in your job?<br />3.Describe some problem that you had with automating testing tool.<br />4.How do you plan test automation?<br />5.Can test automation improve test effectiveness?<br />6.What is data - driven automation?<br />7.What are the main attributes of test automation?<br />8.Does automation replace manual testing?<br />9.How will you choose a tool for test automation?<br />10.How you will evaluate the tool for test automation?<br />LOAD TESTING:<br />1.What criteria would you use to select Web transactions for load testing?<br />2.For what purpose are virtual users created?<br />3.Why it is recommended to add verification checks to your all your<br />scenarios?<br />4.In what situation would you want to parameterize a text verification<br />check?<br />5.Why do you need to parameterize fields in your virtual user script?<br />GENERAL QUESTIONS:<br />1.What types of documents would you need for QA, QC, and Testing?<br />2.What did you include in a test plan?<br />3.Describe any bug you remember.<br />4.What is the purpose of the testing?<br />5.What do you like (not like) in this job?<br />6.What is quality assurance?<br />7.What is the difference between QA and testing?<br />8.How do you scope, organize, and execute a test project?<br />9.What is the role of QA in a development project?<br />10.What is the role of QA in a company that produces software?<br />C C PLUS PLUS INTERVIEW QUESTIONS<br />1. What is the output of printf("%d")<br />2. Difference between "C structure" and "C++ structure".<br />3. Difference between a "assignment operator" and a "copy<br />constructor"<br />4. What is the difference between "overloading" and "overriding"?<br />5. Explain the need for "Virtual Destructor".<br />6. Can we have "Virtual Constructors"?<br />7. What are the different types of polymorphism?<br />8. What are Virtual Functions? How to implement virtual functions in<br />"C"<br />9. What are the different types of Storage classes?<br />10. What is Namespace?<br />VISUAL BASIC INTERVIEW QUESTIONS<br />1. 3 main differences between flexgrid control and dbgrid control<br />2. ActiveX and Types of ActiveX Components in VB<br />3. Advantage of ActiveX Dll over Active Exe<br />4. Advantages of disconnected recordsets<br />5. Benefit of wrapping database calls into MTS transactions<br />6. Benefits of using MTS<br />7. Can database schema be changed with DAO, RDO or ADO?<br />8. Can you create a tabletype of recordset in Jet - connected ODBC<br />database engine?<br />9. Constructors and distructors<br />10. Controls which do not have events<br />SQL Server<br />1.What are primary keys and foreign keys?<br />2.What is the difference between clustered and non-clustered indices?<br />...and why do you use a clustered index?<br />3.What is an outer join?<br />4.What are Cartesian joins?<br />5.How is referential integrity enforced in a SQL Server database?<br />6.What are the inserted and deleted tables and what are they used for?<br />7.What is the name of the SQL language used in SQL Server stored<br />procedures?<br />8.What is the purpose of having stored procedures in a database?<br />9.Why might you create a stored procedure with the 'with recompile'<br />option?<br />10.What is a cursor? Within a cursor, how would you update fields on the<br />row just fetched?<br />SQL, ORACLE, PRO*C/C++<br />1.What are the different types of joins?<br />2.Explain normalization with examples.<br />3.What cursor type do you use to retrieve multiple recordsets?<br />4.Difference between a "where" clause and a "having" clause<br />5.What is the difference between "procedure" and "function"?<br />6.How will you copy the structure of a table without copying the data?<br />7.How to find out the database name from SQL*PLUS command prompt?<br />8.Talk about "Exception Handling" in PL/SQL?<br />9.What is the difference between "NULL in C" and "NULL in Oracle?"<br />10.What is Pro*C? What is OCI?<br />ORACLE CONCEPTS AND ARCHITECTURE DATABASE STRUCTURES<br />1.What are the components of physical database structure of Oracle<br />database?<br />2.What are the components of logical database structure of Oracle<br />database?<br />3.What is a tablespace?<br />4.What is SYSTEM tablespace and when is it created?<br />5.Explain the relationship among database, tablespace and data file.<br />6.What is schema?<br />7.What are Schema Objects?<br />8.Can objects of the same schema reside in different tablespaces?<br />9.Can a tablespace hold objects from different schemes?<br />10.What is Oracle table?<br />SIEBEL INTERVIEW QUESTIONS<br />1.How do you control visibility in Siebel?<br />2.What is the difference between an organization and division in Siebel?<br />3.What does position represents in Siebel?<br />4.How do you assign responsibilities to employees in Siebel?<br />5.How do you set up employees in Siebel?<br />6.What happens if you create an employee in Siebel application and forget<br />to create the employee in the database?<br />7.Why do you need to create employees at the database in Siebel?<br />8.What is position type field in position applet?<br />9.What does an opportunity, account contact do in Siebel?<br />10.How is the opportunity related to an account?<br />DATAWARE HOUSING INTERVIEW QUESTIONS(ETL, BUSINESS<br />INTELLIGENCE,ABINITIO)<br />GENERAL :<br />1. What is a data-warehouse?<br />2. What are Data Marts?<br />4. What is ER Diagram?<br />5. What is a Star Schema?<br />6. What is Dimensional Modelling?<br />7. What is Snow Flake Schema?<br />ETL QUESTIONS:<br />1. What is a staging area? Do we need it? What is the purpose of a staging<br />area?<br />2. What is a three tier data warehouse?<br />3. What are the various methods of getting incremental records or delta<br />records from the source systems?<br />BUSINESS INTELLIGENCE:<br />1. What is Business Intelligence?<br />2. What is OLAP?<br />3. What is OLAP, MOLAP, ROLAP, DOLAP, HOLAP? Examples?<br />ABINITIO:<br />1.What is the function you would use to transfer a string into a decimal?<br />2.How many parallelisms are in Abinitio? Please give a definition of each.<br />3.What is the difference between a DB config and a CFG file?Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-33399249816872314642009-06-28T23:22:00.000-07:002009-06-28T23:22:00.605-07:00UNIX Commands Interview Questions And Answers1. Construct pipes to execute the following jobs.<br />1. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list.<br /><br />2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’ should be counted and the count should be stored in a file.<br /><br />3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file. From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.<br /><br />4. Name of cities should be accepted from the keyboard . This list should be combined with the list present in a file. This combined list should be sorted and the sorted list<br />should be stored in a file ‘newcity’.<br /><br />5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file ‘errorlog’.<br /><br />2. Explain the following commands.<br />$ ls > file1<br />$ banner hi-fi > message<br />$ cat par.3 par.4 par.5 >> report<br />$ cat file1>file1<br />$ date ; who<br />$ date ; who > logfile<br />$ (date ; who) > logfile<br /><br />3. What is the significance of the “tee” command?<br />It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.<br /><br />4. What does the command “ $who | sort –logfile > newfile” do?<br />The input from a pipe can be combined with the input from a file . The trick is to use the special symbol “-“ (a hyphen) for those commands that recognize the hyphen as std input.<br />In the above command the output from who becomes the std input to sort , meanwhile sort opens the file logfile, the contents of this file is sorted together with the output of who (rep by the hyphen) and the sorted output is redirected to the file newfile.<br /><br />5. What does the command “$ls | wc –l > file1” do?<br />ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying this count , the value is stored in file1.<br /><br />6. Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head<br />Ans: man<br />A filter is a program which can receive a flow of data from std input, process (or filter) it and send the result to the std output.<br /><br />7. How is the command “$cat file2 “ different from “$cat >file2 and >> redirection operators ?<br />is the output redirection operator when used it overwrites while >> operator appends into the file.<br /><br />9. Explain the steps that a shell follows while processing a command.<br />After the command line is terminated by the key, the shel goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order.<br />Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted. All consecutive occurrences of a space or tab are replaced here with a single space.<br />Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped.<br />Command substitution: Any command surrounded by backquotes is executed by the shell which t hen replaces the standard output of the command into the command line.<br />Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?, [, ]).<br />Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command.<br />PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to search in order to hunt for the command.<br /><br />10. What difference between cmp and diff commands?<br />cmp - Compares two files byte by byte and displays the first mismatch<br />diff - tells the changes to be made to make the files identical<br /><br />11. What is the use of ‘grep’ command?<br />‘grep’ is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file(s).<br />Syntax : grep<br />Example : grep 99mx mcafile<br /><br />12. What is the difference between cat and more command?<br />Cat displays file contents. If the file is large the contents scroll off the screen before we view it. So<br />command 'more' is like a pager which displays the contents page by page.<br /><br />13. Write a command to kill the last background job?<br />Kill $!<br /><br />14. Which command is used to delete all files in the current directory and all its sub-directories?<br />rm -r *<br /><br />15. Write a command to display a file’s contents in various formats?<br />$od -cbd file_name<br />c - character, b - binary (octal), d-decimal, od=Octal Dump.<br /><br />16. What will the following command do?<br />$ echo *<br />It is similar to 'ls' command and displays all the files in the current directory.<br /><br />17. Is it possible to create new a file system in UNIX?<br />Yes, ‘mkfs’ is used to create a new file system.<br />18. Is it possible to restrict incoming message?<br />Yes, using the ‘mesg’ command.<br /><br />19. What is the use of the command "ls -x chapter[1-5]"<br />ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1,<br />chapter2, and so on.<br /><br />20. Is ‘du’ a command? If so, what is its use?<br />Yes, it stands for ‘disk usage’. With the help of this command you can find the disk capacity and free space of the disk.<br /><br />21. Is it possible to count number char, line in a file; if so, How?<br />Yes, wc-stands for word count.<br />wc -c for counting number of characters in a file.<br />wc -l for counting lines in a file.<br /><br />22. Name the data structure used to maintain file identification?<br />‘inode’, each file has a separate inode and a unique inode number.<br /><br />23. How many prompts are available in a UNIX system?<br />Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).<br /><br />24. How does the kernel differentiate device files and ordinary files?<br /><br />Kernel checks 'type' field in the file's inode structure.<br /><br />25. How to switch to a super user status to gain privileges?<br />Use ‘su’ command. The system asks for password and when valid entry is made the user gains super user (admin) privileges.<br /><br />26. What are shell variables?<br />Shell variables are special variables, a name-value pair created and maintained by the shell.<br />Example: PATH, HOME, MAIL and TERM<br /><br />27. What is redirection?<br />Directing the flow of data to the file or from the file for input or output.<br />Example : ls > wc<br /><br />28. How to terminate a process which is running and the specialty on command kill 0?<br />With the help of kill command we can terminate the process.<br />Syntax: kill pid<br />Kill 0 - kills all processes in your system except the login shell.<br /><br />29. What is a pipe and give an example?<br />A pipe is two or more commands separated by pipe char '|'. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command.<br />Example : ls -l | pr<br />The output for a command ls is the standard input of pr. When a sequence of commands are combined using pipe, then it is called pipeline.<br /><br />30. Explain kill() and its possible return values.<br />There are four possible results from this call:<br />‘kill()’ returns 0. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie.<br />‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or security enhancements are causing the system to deny its existence. (On some systems, the process could be a zombie.) ‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process. This means that either the process exists (again, it could be a zombie) or draconian security enhancements are present (e.g. your process is not allowed to send signals to *anybody*). ‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique is to assume that success or failure with ‘EPERM’ implies that the process exists, and any other error implies that it doesn't.<br />An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ‘/proc’ filesystem: checking for the existence of ‘/proc/PID’ may work.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-91597905774091085382009-06-27T22:16:00.000-07:002009-06-27T22:16:01.180-07:00HR Interview Questions and AnswersWhat Are Your Strenght and Weaknesses?<br />"My strength is my flexibility to handle change. As far as weaknesses, I feel that my management skills could be stronger, and I am constantly working to improve them."<br /><br />Why Should We Hire You?<br />"I have a unique combination of strong technical skills, and the ability to build strong customer relationships. This allows me to use my knowledge and break down information to be more user-friendly." "With five years' experience working in the financial industry and my proven record of saving the company money, I could make a big difference in your company. I'm confident I would be a great addition to your team."<br />Why Do You Want to Work Here?<br />This is the company I've been looking for, a place where my background, experience and skills can be put to use and make things happen."<br />or<br />"I've selected key companies whose mission statements are in line with my values, and this company is very high on my list of desirable choices."<br />WHAT is ur goal<br />"My immediate goal is to get a job in a growth-oriented company. My long-term goal will depend on where the company goes. I hope to eventually grow into a position of responsibility."<br /><br />If you are employed, focus on what you want in your next job: "After two years, I made the decision to look for a company that is team-focused, where I can add my experience."<br />When Were You Most Satisfied in Your Job?<br />"I was very satisfied in my last job, because I worked directly with the customers and their problems; that is an important part of the job for me."<br />What Are Three Positive Things Your Last Boss Would Say About You?<br />It's time to pull out your old performance appraisals and boss's quotes. This is a great way to brag about yourself through someone else's words: "My boss has told me that I am the best designer he has ever had. He knows he can rely on me, and he likes my sense of humor<br /><br /><br />I have been in the customer service industry for the past five years. My most recent experience has been handling incoming calls in the high tech industry. One reason I particularly enjoy this business, and the challenges that go along with it, is the opportunity to connect with people. In my last job,."<br />Next, mention your strengths and abilities:<br />"My real strength is my attention to detail. I pride myself on my reputation for following through and meeting deadlines. When I commit to doing something, I make sure it gets done, and on time."<br />Continued...<br />Conclude with a statement about your current situation:<br />"What I am looking for now is a company that values customer relations, where I can join a strong team and have a positive impact on customer retention and sales."Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-66774716390240991832009-06-26T22:14:00.000-07:002009-06-26T22:14:01.542-07:00Database Interview Questions and answers for Oracle database administratorDifferentiate between TRUNCATE and DELETE<br />What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?<br />Can you use a commit statement within a database trigger?<br />What is an UTL_FILE.What are different procedures and functions associated with it?<br />Difference between database triggers and form triggers?<br />What is OCI. What are its uses?<br />What are ORACLE PRECOMPILERS?<br />What is syntax for dropping a procedure and a function? Are these operations possible?<br />Can a function take OUT parameters. If not why?<br />Can the default values be assigned to actual parameters?<br />What is difference between a formal and an actual parameter?<br />What are different modes of parameters used in functions and procedures?<br />Difference between procedure and function.<br />Can cursor variables be stored in PL/SQL tables.If yes how. If not why?<br />How do you pass cursor variables in PL/SQL?<br />How do you open and close a cursor variable.Why it is required?<br />What should be the return type for a cursor variable.Can we use a scalar data type as return type?<br />What is use of a cursor variable? How it is defined?<br />What WHERE CURRENT OF clause does in a cursor?<br />Difference between NO DATA FOUND and %NOTFOUND<br />What is a cursor for loop?<br />What are cursor attributes?<br />Difference between an implicit & an explicit cursor.<br />What is a cursor?<br />What is the purpose of a cluster?<br />How do you find the numbert of rows in a Table ?<br />Display the number value in Words?<br />What is a pseudo column. Give some examples?<br />How you will avoid your query from using indexes?<br />What is a OUTER JOIN?<br />Which is more faster - IN or EXISTS?<br />When do you use WHERE clause and when do you use HAVING clause?<br />There is a % sign in one field of a column. What will be the query to find it?<br />What is difference between SUBSTR and INSTR?<br />Which datatype is used for storing graphics and images?<br />What is difference between SQL and SQL*PLUS?<br />What is difference between UNIQUE and PRIMARY KEY constraints?<br />What is difference between Rename and Alias?<br />What are various joins used while writing SUBQUERIES?<br /><br />^Back to Top<br /><br />MS SQL Server interview questions<br />This one always gets asked. For a while the database interview questions were limited to Oracle and generic database design questions. This is a set of more than a hundred Microsoft SQL Server interview questions. Some questions are open-ended, and some do not have answers.<br /><br />What is normalization? - Well a relational database is basically composed of tables that contain related data. So the Process of organizing this data into tables is actually referred to as normalization.<br />What is a Stored Procedure? - Its nothing but a set of T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements.<br />Can you give an example of Stored Procedure? - sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user defined stored procedures which can be called in similar way.<br />What is a trigger? - Triggers are basically used to implement business rules. Triggers is also similar to stored procedures. The difference is that it can be activated when data is added or edited or deleted from a table in a database.<br />What is a view? - If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time.<br />What is an Index? - When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index.<br />What are the types of indexes available with SQL Server? - There are basically two types of indexes that we use with the SQL Server. Clustered and the Non-Clustered.<br />What is the basic difference between clustered and a non-clustered index? - The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.<br />What are cursors? - Well cursors help us to do an operation on a set of data that we retreive by commands such as Select columns from table. For example : If we have duplicate records in a table we can remove it by declaring a cursor which would check the records during retreival one by one and remove rows which have duplicate values.<br />When do we use the UPDATE_STATISTICS command? - This command is basically used when we do a large processing of data. If we do a large amount of deletions any modification or Bulk Copy into the tables, we need to basically update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.<br />Which TCP/IP port does SQL Server run on? - SQL Server runs on port 1433 but we can also change it for better security.<br />From where can you change the default port? - From the Network Utility TCP/IP properties –> Port number.both on client and the server.<br />Can you tell me the difference between DELETE & TRUNCATE commands? - Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.<br />Can we use Truncate command on a table which is referenced by FOREIGN KEY? - No. We cannot use Truncate command on a table with Foreign Key because of referential integrity.<br />What is the use of DBCC commands? - DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks.<br />Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.<br />What command do we use to rename a db? - sp_renamedb ‘oldname’ , ‘newname’<br />Well sometimes sp_reanmedb may not work you know because if some one is using the db it will not accept this command so what do you think you can do in such cases? - In such cases we can first bring to db to single user using sp_dboptions and then we can rename that db and then we can rerun the sp_dboptions command to remove the single user mode.<br />What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? - Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.<br />What do you mean by COLLATION? - Collation is basically the sort order. There are three types of sort order Dictionary case sensitive, Dictonary - case insensitive and Binary.<br />What is a Join in SQL Server? - Join actually puts data from two or more tables into a single result set.<br />Can you explain the types of Joins that we can have with Sql Server? - There are three types of joins: Inner Join, Outer Join, Cross Join<br />When do you use SQL Profiler? - SQL Profiler utility allows us to basically track connections to the SQL Server and also determine activities such as which SQL Scripts are running, failed jobs etc..<br />What is a Linked Server? - Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server dbs using T-SQL Statements.<br />Can you link only other SQL Servers or any database servers such as Oracle? - We can link any server provided we have the OLE-DB provider from Microsoft to allow a link. For Oracle we have a OLE-DB provider for oracle that microsoft provides to add it as a linked server to the sql server group.<br />Which stored procedure will you be running to add a linked server? - sp_addlinkedserver, sp_addlinkedsrvlogin<br />What are the OS services that the SQL Server installation adds? - MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)<br />Can you explain the role of each service? - SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers<br />How do you troubleshoot SQL Server if its running very slow? - First check the processor and memory usage to see that processor is not above 80% utilization and memory not above 40-45% utilization then check the disk utilization using Performance Monitor, Secondly, use SQL Profiler to check for the users and current SQL activities and jobs running which might be a problem. Third would be to run UPDATE_STATISTICS command to update the indexes<br />Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot? - First I will look to ensure that port settings are proper on server and client Network utility for connections. ODBC is properly configured at client end for connection ——Makepipe & readpipe are utilities to check for connection. Makepipe is run on Server and readpipe on client to check for any connection issues.<br />What are the authentication modes in SQL Server? - Windows mode and mixed mode (SQL & Windows).<br />Where do you think the users names and passwords will be stored in sql server? - They get stored in master db in the sysxlogins table.<br />What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.<br />Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow? - For restoring the master db we have to stop the SQL Server first and then from command line we can type SQLSERVER .m which will basically bring it into the maintenance mode after which we can restore the master db.<br />Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action do you take? - (I am not sure- but I think we have a command to do it).<br />What is BCP? When do we use it? - BulkCopy is a tool used to copy huge amount of data from tables and views. But it won’t copy the structures of the same.<br />What should we do to copy the tables, schema and views from one SQL Server to another? - We have to write some DTS packages for it.<br />What are the different types of joins and what dies each do?<br />What are the four main query statements?<br />What is a sub-query? When would you use one?<br />What is a NOLOCK?<br />What are three SQL keywords used to change or set someone’s permissions?<br />What is the difference between HAVING clause and the WHERE clause?<br />What is referential integrity? What are the advantages of it?<br />What is database normalization?<br />Which command using Query Analyzer will give you the version of SQL server and operating system?<br />Using query analyzer, name 3 ways you can get an accurate count of the number of records in a table?<br />What is the purpose of using COLLATE in a query?<br />What is a trigger?<br />What is one of the first things you would do to increase performance of a query? For example, a boss tells you that “a query that ran yesterday took 30 seconds, but today it takes 6 minutes”<br />What is an execution plan? When would you use it? How would you view the execution plan?<br />What is the STUFF function and how does it differ from the REPLACE function?<br />What does it mean to have quoted_identifier on? What are the implications of having it off?<br />What are the different types of replication? How are they used?<br />What is the difference between a local and a global variable?<br />What is the difference between a Local temporary table and a Global temporary table? How is each one used?<br />What are cursors? Name four types of cursors and when each one would be applied?<br />What is the purpose of UPDATE STATISTICS?<br />How do you use DBCC statements to monitor various aspects of a SQL server installation?<br />How do you load large data to the SQL server database?<br />How do you check the performance of a query and how do you optimize it?<br />How do SQL server 2000 and XML linked? Can XML be used to access data?<br />What is SQL server agent?<br />What is referential integrity and how is it achieved?<br />What is indexing?<br />What is normalization and what are the different forms of normalizations?<br />Difference between server.transfer and server.execute method?<br />What id de-normalization and when do you do it?<br />What is better - 2nd Normal form or 3rd normal form? Why?<br />Can we rewrite subqueries into simple select statements or with joins? Example?<br />What is a function? Give some example?<br />What is a stored procedure?<br />Difference between Function and Procedure-in general?<br />Difference between Function and Stored Procedure?<br />Can a stored procedure call another stored procedure. If yes what level and can it be controlled?<br />Can a stored procedure call itself(recursive). If yes what level and can it be controlled.?<br />How do you find the number of rows in a table?<br />Difference between Cluster and Non-cluster index?<br />What is a table called, if it does not have neither Cluster nor Non-cluster Index?<br />Explain DBMS, RDBMS?<br />Explain basic SQL queries with SELECT from where Order By, Group By-Having?<br />Explain the basic concepts of SQL server architecture?<br />Explain couple pf features of SQL server<br />Scalability, Availability, Integration with internet, etc.)?<br />Explain fundamentals of Data ware housing & OLAP?<br />Explain the new features of SQL server 2000?<br />How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?<br />What is data integrity? Explain constraints?<br />Explain some DBCC commands?<br />Explain sp_configure commands, set commands?<br />Explain what are db_options used for?<br />What is the basic functions for master, msdb, tempdb databases?<br />What is a job?<br />What are tasks?<br />What are primary keys and foreign keys?<br />How would you Update the rows which are divisible by 10, given a set of numbers in column?<br />If a stored procedure is taking a table data type, how it looks?<br />How m-m relationships are implemented?<br />How do you know which index a table is using?<br />How will oyu test the stored procedure taking two parameters namely first name and last name returning full name?<br />How do you find the error, how can you know the number of rows effected by last SQL statement?<br />How can you get @@error and @@rowcount at the same time?<br />What are sub-queries? Give example? In which case sub-queries are not feasible?<br />What are the type of joins? When do we use Outer and Self joins?<br />Which virtual table does a trigger use?<br />How do you measure the performance of a stored procedure?<br />Questions regarding Raiseerror?<br />Questions on identity?<br />If there is failure during updation of certain rows, what will be the state?<br /><br />^Back to Top<br /><br />JDBC and JSP interview questions<br />What is the query used to display all tables names in SQL Server (Query analyzer)?<br /><br /> select * from information_schema.tables<br /><br />How many types of JDBC Drivers are present and what are they?- There are 4 types of JDBC Drivers<br />JDBC-ODBC Bridge Driver<br /><br />Native API Partly Java Driver<br />Network protocol Driver<br />JDBC Net pure Java Driver<br />Can we implement an interface in a JSP?- No<br />What is the difference between ServletContext and PageContext?- ServletContext: Gives the information about the container. PageContext: Gives the information about the Request<br />What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?- request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource, context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.<br />How to pass information from JSP to included JSP?- Using <%jsp:param> tag.<br />What is the difference between directive include and jsp include?- <%@ include>: Used to include static resources during translation time. JSP include: Used to include dynamic content or static content during runtime.<br />What is the difference between RequestDispatcher and sendRedirect?- RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.<br />How does JSP handle runtime exceptions?- Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP.<br />How do you delete a Cookie within a JSP?<br /> Cookie mycook = new Cookie(\"name\",\"value\");<br /> response.addCookie(mycook);<br /> Cookie killmycook = new Cookie(\"mycook\",\"value\");<br /> killmycook.setMaxAge(0);<br /> killmycook.setPath(\"/\");<br /> killmycook.addCookie(killmycook);<br /><br />How do I mix JSP and SSI #include?- If you’re just including raw HTML, use the #include directive as usual inside your .jsp file.<br /> <!--#include file="data.inc"--><br /><br />But it’s a little trickier if you want the server to evaluate any JSP code that’s inside the included file. If your data.inc file contains jsp code you will have to use<br /><br /> <%@ vinclude="data.inc" %><br /><br />The <!–#include file="data.inc"–> is used for including non-JSP files.<br /><br />I made my class Cloneable but I still get Can’t access protected method clone. Why?- Some of the Java books imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that’s not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn’t do anything special and just calls super.clone().<br />Why is XML such an important development?- It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for; the complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.<br />What is the fastest type of JDBC driver?- JDBC driver performance will depend on a number of issues:<br />the quality of the driver code,<br /><br />the size of the driver code,<br />the database server and its load,<br />network topology,<br />the number of times your request is translated to a different API.<br />In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).<br /><br />How do I find whether a parameter exists in the request object?<br />boolean hasFoo = !(request.getParameter(\"foo\") == null<br /> || request.getParameter(\"foo\").equals(\"\"));<br /><br />or<br /><br />boolean hasParameter =<br /> request.getParameterMap().contains(theParameter); //(which works in Servlet 2.3+)<br /><br />How can I send user authentication information while makingURLConnection?- You’ll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.<br /><br />^Back to Top<br /><br />SQL Server interview questions<br />How do you read transaction logs?<br />How do you reset or reseed the IDENTITY column?<br />How do you persist objects, permissions in tempdb?<br />How do you simulate a deadlock for testing purposes?<br />How do you rename an SQL Server computer?<br />How do you run jobs from T-SQL?<br />How do you restore single tables from backup in SQL Server 7.0/2000? In SQL Server 6.5?<br />Where to get the latest MDAC from?<br />I forgot/lost the sa password. What do I do?<br />I have only the .mdf file backup and no SQL Server database backups. Can I get my database back into SQL Server?<br />How do you add a new column at a specific position (say at the beginning of the table or after the second column) using ALTER TABLE command?<br />How do you change or alter a user defined data type?<br />How do you rename an SQL Server 2000 instance?<br />How do you capture/redirect detailed deadlock information into the error logs?<br />How do you remotely administer SQL Server?<br />What are the effects of switching SQL Server from ‘Mixed mode’ to ‘Windows only’ authentication mode? What are the steps required, to not break existing applications?<br />Is there a command to list all the tables and their associated filegroups?<br />How do you ship the stored procedures, user defined functions (UDFs), triggers, views of my application, in an encrypted form to my clients/customers? How do you protect intellectual property?<br />How do you archive data from my tables? Is there a built-in command or tool for this?<br />How do you troubleshoot ODBC timeout expired errors experienced by applications accessing SQL Server databases?<br />How do you restart SQL Server service automatically at regular intervals?<br />What is the T-SQL equivalent of IIF (immediate if/ternary operator) function of other programming languages?<br />How do you programmatically find out when the SQL Server service started?<br />How do you get rid of the time part from the date returned by GETDATE function?<br />How do you upload images or binary files into SQL Server tables?<br />How do you run an SQL script file that is located on the disk, using T-SQL?<br />How do you get the complete error message from T-SQL while error handling?<br />How do you get the first day of the week, last day of the week and last day of the month using T-SQL date functions?<br />How do you pass a table name, column name etc. to the stored procedure so that I can dynamically select from a table?<br />Error inside a stored procedure is not being raised to my front-end applications using ADO. But I get the error when I run the procedure from Query Analyzer.<br />How do you suppress error messages in stored procedures/triggers etc. using T-SQL?<br />How do you save the output of a query/stored procedure to a text file?<br />How do you join tables from different databases?<br />How do you join tables from different servers?<br />How do you convert timestamp data to date data (datetime datatype)?<br />Can I invoke/instantiate COM objects from within stored procedures or triggers using T-SQL?<br />Oracle has a rownum to access rows of a table using row number or row id. Is there any equivalent for that in SQL Server? Or How do you generate output with row number in SQL Server?<br />How do you specify a network library like TCP/IP using ADO connect string?<br />How do you generate scripts for repetitive tasks like truncating all the tables in a database, changing owner of all the database objects, disabling constraints on all tables etc?<br />Is there a way to find out when a stored procedure was last updated?<br />How do you find out all the IDENTITY columns of all the tables in a given database?<br />How do you search the code of stored procedures?<br />How do you retrieve the generated GUID value of a newly inserted row? Is there an @@GUID, just like @@IDENTITY?Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-40000101077038354792009-06-25T22:09:00.000-07:002009-06-25T22:09:01.655-07:00NETWORKING INTERVIEW QUESTIONS1. What are 10Base2, 10Base5 and 10BaseT Ethernet LANs<br />10Base2—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling, with a contiguous cable segment length of 100 meters and a maximum of 2 segments.<br />10Base5—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling, with 5 continuous segments not exceeding 100 meters per segment.<br />10BaseT—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband signaling and twisted pair cabling.<br /><br />2. Explain the difference between an unspecified passive open and a fully specified passive open<br />An unspecified passive open has the server waiting for a connection request from a client. A fully specified passive open has the server waiting for a connection from a specific client.<br /><br />3. Explain the function of Transmission Control Block<br />A TCB is a complex data structure that contains a considerable amount of information about each connection.<br /><br />4. Explain a Management Information Base (MIB)<br />A Management Information Base is part of every SNMP-managed device. Each SNMP agent has the MIB database that contains information about the device's status, its performance, connections, and configuration. The MIB is queried by SNMP.<br /><br />5. Explain anonymous FTP and why would you use it<br />Anonymous FTP enables users to connect to a host without using a valid login and password. Usually, anonymous FTP uses a login called anonymous or guest, with the password usually requesting the user's ID for tracking purposes only. Anonymous FTP is used to enable a large number of users to access files on the host without having to go to the trouble of setting up logins for them all. Anonymous FTP systems usually have strict controls over the areas an anonymous user can access.<br /><br />6. Explain a pseudo tty<br />A pseudo tty or false terminal enables external machines to connect through Telnet or rlogin. Without a pseudo tty, no connection can take place.<br /><br />7. Explain REX<br />What advantage does REX offer other similar utilities?<br /><br />8. What does the Mount protocol do?<br />The Mount protocol returns a file handle and the name of the file system in which a requested file resides. The message is sent to the client from the server after reception of a client's request.<br /><br />9. Explain External Data Representation<br />External Data Representation is a method of encoding data within an RPC message, used to ensure that the data is not system-dependent.<br /><br />10. Explain the Network Time Protocol?<br /><br />11. BOOTP helps a diskless workstation boot. How does it get a message to the network looking for its IP address and the location of its operating system boot files?<br />BOOTP sends a UDP message with a subnetwork broadcast address and waits for a reply from a server that gives it the IP address. The same message might contain the name of the machine that has the boot files on it. If the boot image location is not specified, the workstation sends another UDP message to query the server.<br /><br />12. Explain a DNS resource record<br />A resource record is an entry in a name server's database. There are several types of resource records used, including name-to-address resolution information. Resource records are maintained as ASCII files.<br /><br />13. What protocol is used by DNS name servers?<br />DNS uses UDP for communication between servers. It is a better choice than TCP because of the improved speed a connectionless protocol offers. Of course, transmission reliability suffers with UDP.<br /><br />14. Explain the difference between interior and exterior neighbor gateways<br />Interior gateways connect LANs of one organization, whereas exterior gateways connect the organization to the outside world.<br /><br />15. Explain the HELLO protocol used for<br />The HELLO protocol uses time instead of distance to determine optimal routing. It is an alternative to the Routing Information Protocol.<br /><br />16. What are the advantages and disadvantages of the three types of routing tables?<br />The three types of routing tables are fixed, dynamic, and fixed central. The fixed table must be manually modified every time there is a change. A dynamic table changes its information based on network traffic, reducing the amount of manual maintenance. A fixed central table lets a manager modify only one table, which is then read by other devices. The fixed central table reduces the need to update each<br />machine's table, as with the fixed table. Usually a dynamic table causes the fewest problems for a network administrator, although the table's contents can change without the administrator being aware of the change.<br /><br />17. Explain a TCP connection table<br /><br />18. Explain source route<br />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.<br /><br />19. Explain RIP (Routing Information Protocol)<br />It is a simple protocol used to exchange information between the routers.<br />20. Explain SLIP (Serial Line Interface Protocol)<br />It is a very simple protocol used for transmission of IP datagrams across a serial line.<br />21. Explain Proxy ARP<br />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.<br />22. Explain OSPF<br />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.<br />23. Explain Kerberos<br />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.<br />24. Explain a Multi-homed Host<br />It is a host that has a multiple network interfaces and that requires multiple IP addresses is called as a Multi-homed Host.<br />25. Explain NVT (Network Virtual Terminal)<br />It is a set of rules defining a very simple virtual terminal interaction. The NVT is used in the start of a Telnet session.<br />26. Explain Gateway-to-Gateway protocol<br />It is a protocol formerly used to exchange routing information between Internet core routers.<br />27. Explain BGP (Border Gateway Protocol)<br />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).<br />28. Explain autonomous system<br />It is a collection of routers under the control of a single administrative authority and that uses a common Interior Gateway Protocol.<br />29. Explain EGP (Exterior Gateway Protocol)<br />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.<br />30. Explain IGP (Interior Gateway Protocol)<br />It is any routing protocol used within an autonomous system.<br />31. Explain Mail Gateway<br />It is a system that performs a protocol translation between different electronic mail delivery protocols.<br />32. Explain wide-mouth frog<br />Wide-mouth frog is the simplest known key distribution center (KDC) authentication protocol.<br />33. What are Digrams and Trigrams<br />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.<br />34. Explain silly window syndrome<br />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.<br />35. Explain region<br />When hierarchical routing is used, the routers are divided into what we 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.<br />36. Explain multicast routing<br />Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.<br />37. Explain traffic shaping<br />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.<br />38. Explain packet filter<br />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.<br />39. Explain virtual path<br />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.<br />40. Explain virtual channel<br />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.<br />41. Explain logical link control<br />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.<br />42. Why should you care about the OSI Reference Model<br />It provides a framework for discussing network operations and design.<br />43. Explain the difference between routable and non- routable protocols<br />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<br />44. Explain MAU<br />In token Ring , hub is called Multistation Access Unit(MAU).<br />45. Explain 5-4-3 rule<br />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.<br />46. Explain the difference between TFTP and FTP application layer protocols<br />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.<br />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 offered 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.<br />47. Explain the range of addresses in the classes of internet addresses<br />Class A 0.0.0.0 - 127.255.255.255<br />Class B 128.0.0.0 - 191.255.255.255<br />Class C 192.0.0.0 - 223.255.255.255<br />Class D 224.0.0.0 - 239.255.255.255<br />Class E 240.0.0.0 - 247.255.255.255<br />48. Explain the minimum and maximum length of the header in the TCP segment and IP datagram<br />The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes.<br />49. Explain difference between ARP and RARP<br />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.<br />50. Explain ICMP<br />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.<br />51. What are the data units at different layers of the TCP / IP protocol suite<br />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<br />finally transmitted as signals along the transmission media.<br />52. Explain Project 802<br />It is a project started by IEEE to set standards that 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.<br />It consists of the following:<br />802.1 is an internetworking standard for compatibility of different LANs and MANs across protocols.<br />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.<br />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).<br />802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.<br />53. Explain Bandwidth<br />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.<br />54. Difference between bit rate and baud rate.<br />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.<br />55. Explain MAC address<br />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.<br />56. Explain attenuation<br />The degeneration of a signal over distance on a network cable is called attenuation.<br />57. Explain cladding<br />A layer of a glass surrounding the center fiber of glass inside a fiber-optic cable.<br />58. Explain RAID<br />A method for providing fault tolerance by using multiple hard disk drives.<br />59. Explain NETBIOS and NETBEUI<br />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.<br />60. Explain redirector<br />Redirector is software that intercepts file or prints I/O requests and translates them into network requests. This comes under presentation layer.<br />61. Explain Beaconing<br />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.<br />62. Explain terminal emulation, in which layer it comes<br />Telnet is also called as terminal emulation. It belongs to application layer.<br />63. Explain frame relay, in which layer it comes<br />Frame relay is a packet switching technology. It will operate in the data link layer.<br />64. What do you meant by "triple X" in Networks<br />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"<br />65. Explain SAP<br />Series of interface points that allow other computers to communicate with the other layers of network protocol stack.<br />66. Explain subnet<br />A generic term for section of a large networks usually separated by a bridge or router.<br />67. Explain Brouter<br />Hybrid devices that combine the features of both bridges and routers.<br />68. How Gateway is different from Routers<br />A gateway operates at the upper levels of the OSI model and translates information between two completely different network architectures or data formats.<br />69. What are the different type of networking / internetworking devices<br />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.<br />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.<br />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.<br />Gateways:<br />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.<br />70. Explain mesh network<br />A network in which there are multiple network links between computers to provide multiple paths for data to travel.<br />71. Explain passive topology<br />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.<br />72. What are the important topologies for networks<br />BUS topology:<br />In this each computer is directly connected to primary network cable in a single line.<br />Advantages:<br />Inexpensive, easy to install, simple to understand, easy to extend.<br />STAR topology:<br />In this all computers are connected using a central hub.<br />Advantages:<br />Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.<br />RING topology:<br />In this all computers are connected in loop.<br />Advantages:<br />All computers have equal access to network media, installation can be simple, and signal does not degrade as much as<br />in other topologies because each computer<br />regenerates it.<br />73. What are major types of networks and explain<br />Server-based network<br />Peer-to-peer network<br />Peer-to-peer network, computers can act as both servers sharing resources and as clients using the resources.<br />Server-based networks provide centralized control of network resources and rely on server computers to provide security and network administration<br />74. Explain Protocol Data Unit<br />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<br />unnumbered frame (U - frame).<br />75. Explain difference between baseband and broadband transmission<br />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.<br />76. What are the possible ways of data exchange<br />(i) Simplex (ii) Half-duplex (iii) Full-duplex.<br />77. What are the types of Transmission media<br />Signals are usually transmitted over some transmission media that are broadly classified in to two categories.<br />Guided Media:<br />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<br />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.<br />Unguided Media:<br />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.<br />78. Explain point-to-point protocol<br />A communications protocol used to connect computers to remote networking services including Internet service providers.<br />79. What are the two types of transmission technology available<br />(i) Broadcast and (ii) point-to-point<br />80. Difference between the communication and transmission.<br />Transmission is a physical movement of information and concern issues like bit polarity, synchronization, clock etc. Communication means the meaning full exchange of information between two communication media.<br />Source: http://www.tutorialdownloads.com/FAQ/networking-interview-questions.htmlSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-90852439025942184962009-06-24T22:08:00.000-07:002009-06-24T22:08:00.944-07:00General & HR Interview Question and AnswerMental fear of the unknown is often what produces the physical symptoms of nervousness. In addition to preparing yourself physically, you also need to prepare yourself mentally. The best way to prepare mentally is to know what may be coming. Fear of the unknown can only exist when there is an unknown. Take the time to understand some of the "standards" when it comes to interviewing questions.<br />The following are some of the most difficult questions you will face in the course of your job interviews. Some questions may seem rather simple on the surface--such as "Tell me about yourself"--but these questions can have a variety of answers. The more open-ended the question, the wider the variation in the answers. Once you have become practiced in your interviewing skills, you will find that you can use almost any question as a launching pad for a particular topic or compelling story.<br />Others are "classic" interview questions, such as, "What is your greatest weakness?" Questions which most people answer inappropriately. In this case, the standard textbook answer for the "greatest weakness" question is to give a veiled positive--"I work too much. I just work and work and work"--which ends up sending the wrong message. Either you are lying or, worse yet, you are telling the truth, in which case you define working too much as a weakness and really don't want to work much at all. Think about it.<br />The following answers are provided to give you a new perspective on how to answer tough interview questions. They are not there for you to lift from the page and insert into your next interview. They are there for you to use as the basic structure for formulating your own answers. While the specifics of each reply may not apply to you, try to follow the basic structure of the answer from the perspective of the interviewer. Answer the questions behaviorally, with specific examples that show clear evidence backs up what you are saying about yourself. Always provide information that shows you want to become the very best _____ for the company and that you have specifically prepared yourself to become exactly that. They want to be sold. They are waiting to be sold. Don't disappoint them!<br />1. Tell me about yourself.<br />My background to date has been centered around preparing myself to become the very best _____ I can become. Let me tell you specifically how I've prepared myself . . .<br />2. Why should I hire you?<br />Because I sincerely believe that I'm the best person for the job. I realize that there are many other college students who have the ability to do this job. I also have that ability. But I also bring an additional quality that makes me the very best person for the job--my attitude for excellence. Not just giving lip service to excellence, but putting every part of myself into achieving it. In _____ and _____ I have consistently reached for becoming the very best I can become by doing the following . . .<br />3. What is your long-range objective? Where do you want to be 10 or 15 years from now?<br />Although it's certainly difficult to predict things far into the future, I know what direction I want to develop toward. Within five years, I would like to become the very best _____ your company has. In fact, my personal career mission statement is to become a world-class _____ in the _____ industry. I will work toward becoming the expert that others rely upon. And in doing so, I feel I will be fully prepared to take on any greater responsibilities that might be presented in the long term.<br />4. How has your education prepared you for your career?<br />As you will note on my resume, I've taken not only the required core classes in the _____ field, I've also gone above and beyond. I've taken every class the college has to offer in the field and also completed an independent study project specifically in this area. But it's not just taking the classes to gain academic knowledge--I've taken each class, both inside and outside of my major, with this profession in mind. So when we're studying _____ in _____, I've viewed it from the perspective of _____. In addition, I've always tried to keep a practical view of how the information would apply to my job. Not just theory, but how it would actually apply. My capstone course project in my final semester involved developing a real-world model of _____, which is very similar to what might be used within your company. Let me tell you more about it . . .<br />5. Are you a team player?<br />Very much so. In fact, I've had opportunities in both athletics and academics to develop my skills as a team player. I was involved in _____ at the intramural level, including leading my team in assists during the past year--I always try to help others achieve their best. In academics, I've worked on several team projects, serving as both a member and team leader. I've seen the value of working together as a team to achieve a greater goal than any one of us could have achieved individually. As an example . . .<br />6. Have you ever had a conflict with a boss or professor? How was it resolved?<br />Yes, I have had conflicts in the past. Never major ones, but certainly there have been situations where there was a disagreement that needed to be resolved. I've found that when conflict occurs, it's because of a failure to see both sides of the situation. Therefore, I ask the other person to give me their perspective and at the same time ask that they allow me to fully explain my perspective. At that point, I would work with the person to find out if a compromise could be reached. If not, I would submit to their decision because they are my superior. In the end, you have to be willing to submit yourself to the directives of your superior, whether you're in full agreement or not. An example of this was when . . .<br />7. What is your greatest weakness?<br />I would say my greatest weakness has been my lack of proper planning in the past. I would overcommit myself with too many variant tasks, then not be able to fully accomplish each as I would like. However, since I've come to recognize that weakness, I've taken steps to correct it. For example, I now carry a planning calendar in my pocket so that I can plan all of my appointments and "to do" items. Here, let me show you how I have this week planned out . . .<br />8. If I were to ask your professors to describe you, what would they say?<br />I believe they would say I'm a very energetic person, that I put my mind to the task at hand and see to it that it's accomplished. They would say that if they ever had something that needed to be done, I was the person who they could always depend on to see that it was accomplished. They would say that I always took a keen interest in the subjects I was studying and always sought ways to apply the knowledge in real world settings. Am I just guessing that they would say these things? No, in fact, I'm quite certain they would say those things because I have with me several letters of recommendation from my professors, and those are their very words. Let me show you . . .<br />9. What qualities do you feel a successful manager should have?<br />The key quality should be leadership--the ability to be the visionary for the people who are working under them. The person who can set the course and direction for subordinates. A manager should also be a positive role model for others to follow. The highest calling of a true leader is inspiring others to reach the highest of their abilities. I'd like to tell you about a person who I consider to be a true leader . . .<br />10. If you had to live your life over again, what would you change?<br />That's a good question. I realize that it can be very easy to continually look back and wish that things had been different in the past. But I also realize that things in the past cannot be changed, that only things in the future can be changed. That's why I continually strive to improve myself each and every day and that's why I'm working hard to continually increase my knowledge in the _____ field. That's also the reason why I want to become the very best _____ your company has ever had. To make positive change. And all of that is still in the future. So in answer to your question, there isn't anything in my past that I would change. I look only to the future to make changes in my life.<br />In reviewing the above responses, please remember that these are sample answers. Please do not rehearse them verbatim or adopt them as your own. They are meant to stir your creative juices and get you thinking about how to properly answer the broader range of questions that you will face.<br />Fifty Standard Interview Questions<br /><br />It is not enough to have solid answers only for the above questions. You need to be prepared for the full spectrum of questions that may be presented. For further practice, make sure you go through the required mock interview (see the "Competitive Interview Prep" Section) and for further review, look at some of the following questions:<br />1. Tell me about yourself.<br />2. What do you want to do with your life?<br />3. Do you have any actual work experience?<br />4. How would you describe your ideal job?<br />5. Why did you choose this career?<br />6. When did you decide on this career?<br />7. What goals do you have in your career?<br />8. How do you plan to achieve these goals?<br />9. How do you evaluate success?<br />10. Describe a situation in which you were successful.<br />11. What do you think it takes to be successful in this career?<br />12. What accomplishments have given you the most satisfaction in your life?<br />13. If you had to live your life over again, what would you change?<br />14. Would your rather work with information or with people?<br />15. Are you a team player?<br />16. What motivates you?<br />17. Why should I hire you?<br />18. Are you a goal-oriented person?<br />19. Tell me about some of your recent goals and what you did to achieve them.<br />20. What are your short-term goals?<br />21. What is your long-range objective?<br />22. What do you see yourself doing five years from now?<br />23. Where do you want to be ten years from now?<br />24. Do you handle conflict well?<br />25. Have you ever had a conflict with a boss or professor? How did you resolve it?<br />26. What major problem have you had to deal with recently?<br />27. Do you handle pressure well?<br />28. What is your greatest strength?<br />29. What is your greatest weakness?<br />30. If I were to ask one of your professors to describe you, what would he or she say?<br />31. Why did you choose to attend your college?<br />32. What changes would you make at your college?<br />33. How has your education prepared you for your career?<br />34. What were your favorite classes? Why?<br />35. Do you enjoy doing independent research?<br />36. Who were your favorite professors? Why?<br />37. Why is your GPA not higher?<br />38. Do you have any plans for further education?<br />39. How much training do you think you'll need to become a productive employee?<br />40. What qualities do you feel a successful manager should have?<br />41. Why do you want to work in the _____ industry?<br />42. What do you know about our company?<br />43. Why are you interested in our company?<br />44. Do you have any location preferences?<br />45. How familiar are you with the community that we're located in?<br />46. Will you relocate? In the future?<br />47. Are you willing to travel? How much?<br />48. Is money important to you?<br />49. How much money do you need to make to be happy?<br />50. What kind of salary are you looking for?<br />Don't just read these questions--practice and rehearse the answers. Don't let the company interview be the first time you have actually formulated an answer in spoken words. It is not enough to think about them in your head--practice! Sit down with a friend, a significant other, or your roommate (an especially effective critic, given the amount of preparation to date) and go through all of the questions. Make the most of every single interview opportunity by being fully prepared!<br />Top Ten Critical Success Factors<br /><br />With all the different questions being referenced, you may wonder what exactly the employer is looking for. And I will tell you. Following is the list of the top ten critical success factors that nearly every employer is seeking:<br />1. Positive attitude toward work<br />2. Proficiency in field of study<br />3. Communication skills (oral and written)<br />4. Interpersonal skills<br />5. Confidence<br />6. Critical thinking and problem solving skills<br />7. Flexibility<br />8. Self-motivation<br />9. Leadership<br />10. Teamwork<br />Show your competence in as many of the above critical success factors as possible and you will rise above the competition.<br /><br />One Interview Question That Nearly Every College Student Fails<br /><br />Here it is. The one question that nearly every college student fails to answer properly (and will continue to send students to their interview ruin) is:<br />"Why did you choose to attend this college?"<br />You have spent the last several years knocking the college--the professors, the administration, the dorms, the food in the dining halls, whatever--and now you suddenly need to come to its defense. And if you have not thought of an answer before the interview, you definitely will not come up with a valid one on the spot.<br />So think about it in advance. What is the real reason you are attending your college? Is it because of the academic program? Is it because of extracurricular programs? Athletics? Close to home? Party school? Great dating opportunities? Everyone else turned you down?<br />Once you acknowledge your true reason for attending, you will need to temper your response with some directed reasoning--tie in what it is about your college that makes it worthwhile from the perspective of the employer. Your response should emphasize what it is about the school that makes it an attractive training ground for this employer. You need to talk about your college as the ideal training facility for becoming a _____ with that company.<br />You might find it best to give a "process answer" such as:<br />"I originally decided to attend State U. because of its strong general academic reputation and its close proximity to my home, which gave me the opportunity to continue working at my part-time job. During the years I have spent here, I have come to truly appreciate the depth and breadth of the _____ curriculum. It has given me an excellent foundation for becoming an immediate contributor in the _____ field."<br />Lay on the superlatives, but don't get mushy. You will come to appreciate your time at college later in life, but for now, a few well-chosen words about why it is #1 for you in your career will suffice.<br />Job Search Information<br /><br />What To Do If You Are Asked An Illegal Question<br />The interview is going along smoothly. You are psyched that "this may be the one." And then it happens. Out of nowhere. "Are you considering having children?" Or, "How long has your family been in this country?" Or, "Your people place a high value on that, don't they?" Or, "You've done amazingly well for someone in a wheelchair. How long have you had to use one?"<br />On the surface the question may seem innocent enough. And most of the time, they are truly asked in innocence. Yet the structure and format of the question is entirely illegal. So what do you do? How do you respond?<br />First of all, it is important to understand the difference between an illegal question and a criminally liable question. Even though a question or comment may have been stated in an illegal form, it does not necessarily mean that a crime has been committed. There is a difference between criminal liability and civil liability. For there to be criminal liability, it requires establishing a motive or intent. Most illegal questions are asked in ignorance, not with malicious intent. Yet there can still be civil recourse, even when there was no criminal motive or intent.<br />In our politically correct society, we often cry "foul" at the slightest deviation from the accepted standard. But the reality is that most illegal interview questions are asked in true innocence. Or, better stated, in true ignorance. Ignorance of the law, ignorance of what questions are proper, ignorance of how the information could be used by others in a discriminatory way.<br />Ironically, most illegal questions are asked when the untrained interviewer is trying to be more friendly and asks a seemingly innocent question about your personal life or family background. Therefore, any attempt by the candidate to assert their constitutional rights will merely throw up the defense shields and will put an end to mutual consideration. Warning lights go on, sirens sound, and the interviewer begins backing down from what may have been an otherwise very encouraging position.<br />So what is the proper response? The answer is up to you, but my recommendation is to follow one of two courses of action: answer in brief and move on to a new topic area, or ignore the question altogether and redirect the discussion to a new topic area. The interviewer may even recognize the personal misstep and appreciate your willingness to put it aside and go on.<br />Unless the question is blatantly discriminatory--and yes, blatant discrimination does still take place--your best option is to move on to other things. But if it is blatant and offensive, you have every right to terminate the interview and walk out.<br />While laws vary from state to state, there are some definite taboo areas with regard to interview questions which employers should avoid. Following is a brief list of some of the questions that employers should not be asking:<br /> Questions related to birthplace, nationality, ancestry, or descent of applicant, applicant's spouse, or parents<br />(Example: "Pasquale--is that a Spanish name?")<br /> Questions related to applicant's sex or marital status<br />(Example: "Is that your maiden name?")<br /> Questions related to race or color<br />(Example: "Are you considered to be part of a minority group?")<br /> Questions related to religion or religious days observed<br />(Example: "Does your religion prevent you from working weekends or holidays?")<br /> Questions related to physical disabilities or handicaps<br />(Example: "Do you have any use of your legs at all?")<br /> Questions related to health or medical history<br />(Example: "Do you have any pre-existing health conditions?")<br /> Questions related to pregnancy, birth control, and child care<br />(Example: "Are you planning on having children?")<br />It should be noted that just because an illegal question has been asked does not necessarily mean a crime has been committed. It is up to a court of law to determine whether the information was used in a discriminatory manner.<br /><br /> <br />Interview question what are your strong points<br /> <br />It is important to prepare in advance for the interview question what are your strong points. If you've already listed your strengths when preparing your CV / resume, coming up with three answers shouldn't be too difficult.<br />But be careful. The interviewer is asking you to sell yourself, but at the same time, they do not want to hear you being arrogant. And while they may want to know about your personality (if you are over confident they will certainly learn something about you), do remember that this is still an interview situation, so your answers must be relevant to the job in question. In other words, don't get too personal.<br />So how do you go about answering the interview question what are your strong points? The general recommendation is to prepare at least three answers and to relate them to the organisation and the vacancy. This means you need to tailor your answers. Ensure there is truth in what you say, but do not be too honest, especially it makes you sound like a less than ideal candidate.<br />Here are some suggested responses and the reasons why they might work in interviews for certain kinds of jobs.<br />"I am confident and outgoing"<br />This is a response that says something about your personality, but if you are applying for a role where you need to relate to a lot of people - particularly the public - it will serve your purposes. However, if the vacancy involves consultation, it might be better to say "I have good interpersonal skills", as this implies that you are able to listen to people as well.<br />"I enjoy a challenge"<br />Be careful with this. It is an excellent response if the vacancy requires problem solving, or servicing of some kind, working to tight deadlines or project completion. It will obviously not be helpful if the job is less dynamic and involves a larger amount of regular, less exciting duties - the employer might be concerned that you will become bored. You could always qualify it to offer a more balanced response: "I enjoy a challenge, but I'm also happy completing regular tasks." Then it illustrates that you're flexible and responsive to different work situations.<br />"I'm a strong team leader"<br />Clearly, this is appropriate if the job involves managing people. It's a good idea to show that you know what leading a team involves (although this will no doubt come up in other questions too). So, "I'm a strong team leader with the ability to motivate others" and "I'm a strong team leader who leads by example" represent stronger answers. Draw on your own understanding of your management skills plus the job description to decide what you'll say here.<br />"I am ambitious"<br />This is a very strong answer and you should use it with care. In the wrong situation, it can sound hard-headed and the employer may wonder whether you'll compete too fiercely with your colleagues, or even your superiors. However, in a sales role it might be perfect, especially if you focus your response a little more: "I am ambitious and aim to exceed targets".<br />"I am dedicated and hard working"<br />You're on safe ground here, as this can be true whatever your individual working style. It's not the most exciting answer, but when presented alongside two others that are more individual, it should offer reassurance to the interviewer.<br />"I am a good communicator"<br />Again, this is a win-win answer. Be prepared to expand, though: specify whether you have strong writing skills, are good at explaining difficult ideas in a simple way, or perform well at important meetings.<br />"I work well without supervision"<br />A majority of employers would be pleased to hear this, providing the vacancy is at a level where they'd normally expect you to need a degree of supervision. But be careful not to sound as if you prefer to work without supervision, as this may sound as if you risk coming into conflict with your supervisor or manager. A safer option might be to state "I work well with or without supervision".<br />"I enjoy learning through my work"<br />Again, this is a safe answer. The interviewer might then ask how you have done this in the past, so be ready to give details of some hands-on learning or special training you've experienced, and to say why you enjoyed it.<br />And finally<br />These examples show that when preparing an answer to the interview question what are your strong points, it is important to consider whether your responses could be taken the wrong way. Put yourself in the interviewer's shoes - you can then ensure that the potential for a negative interpretation is removed.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-19224276416396680752009-06-23T22:04:00.000-07:002009-06-23T22:04:01.725-07:00Networking Interview QuestionsNetwork engineer interview questions<br />OSPF<br />Describe OSPF in your own words.<br />OSPF areas, the purpose of having each of them<br />Types of OSPF LSA, the purpose of each LSA type<br />What exact LSA type you can see in different areas<br />How OSPF establishes neighboor relation, what the stages are<br />If OSPF router is stucked in each stage what the problem is and how to troubleshoot it<br />OSPF hierarchy in the single or multi areas. Cool OSPF behavior in broadcast and nonbroadcast<br />Draw the diagram of typical OSPF network and explain generally how it works, DR, BDR, election, ASBR, ABR, route redistribution and summarization<br />STP<br />How it works and the purpose<br />Diff types (SSTP, MSTP, RSTP) Cisco - PVST/PVST+<br />root election<br />Diff. port stages and timing for convergence<br />Draw the typical diagram and explain how diff types of STP work<br />What ports are blocking or forwarding<br />How it works if there are topology changes<br />ACLs<br />What are they<br />Diff types<br />Write an example if you want to allow and to deny…<br />Well-known port numbers (DNS - 53 and etc…)<br />QOS<br />What is that<br />What is the diff b/w L2 and L3 QoS<br />How it works<br />Network:<br />Draw the typical network diagram you have to deal with<br />explain how it works<br />What part of it you are responsible<br />firewall, what is that, how it works, how it is diff from ACLs<br />What problems with the network you had had and how you solved it.<br />What are the ways to troubleshoot the network, techniques, commands<br />network security, ways to achieve it<br />Switching:<br />VLANs<br />STP<br />How a L2 switch works with broadcast, unicast, multicast, known/unknown traffic<br />VRRP, GLBP<br />port monitoring and mirroring<br />L3 switch, how it works<br />PIM sparse and dense modes<br /><br />^Back to Top<br /><br />Windows admin interview questions<br />Describe how the DHCP lease is obtained. It’s a four-step process consisting of (a) IP request, (b) IP offer, © IP selection and (d) acknowledgement.<br />I can’t seem to access the Internet, don’t have any access to the corporate network and on ipconfig my address is 169.254.*.*. What happened? The 169.254.*.* netmask is assigned to Windows machines running 98/2000/XP if the DHCP server is not available. The name for the technology is APIPA (Automatic Private Internet Protocol Addressing).<br />We’ve installed a new Windows-based DHCP server, however, the users do not seem to be getting DHCP leases off of it. The server must be authorized first with the Active Directory.<br />How can you force the client to give up the dhcp lease if you have access to the client PC? ipconfig /release<br />What authentication options do Windows 2000 Servers have for remote clients? PAP, SPAP, CHAP, MS-CHAP and EAP.<br />What are the networking protocol options for the Windows clients if for some reason you do not want to use TCP/IP? NWLink (Novell), NetBEUI, AppleTalk (Apple).<br />What is data link layer in the OSI reference model responsible for? Data link layer is located above the physical layer, but below the network layer. Taking raw data bits and packaging them into frames. The network layer will be responsible for addressing the frames, while the physical layer is reponsible for retrieving and sending raw data bits.<br />What is binding order? The order by which the network protocols are used for client-server communications. The most frequently used protocols should be at the top.<br />How do cryptography-based keys ensure the validity of data transferred across the network? Each IP packet is assigned a checksum, so if the checksums do not match on both receiving and transmitting ends, the data was modified or corrupted.<br />Should we deploy IPSEC-based security or certificate-based security? They are really two different technologies. IPSec secures the TCP/IP communication and protects the integrity of the packets. Certificate-based security ensures the validity of authenticated clients and servers.<br />What is LMHOSTS file? It’s a file stored on a host machine that is used to resolve NetBIOS to specific IP addresses.<br />What’s the difference between forward lookup and reverse lookup in DNS? Forward lookup is name-to-address, the reverse lookup is address-to-name.<br />How can you recover a file encrypted using EFS? Use the domain recovery agent.<br /><br />^Back to Top<br /><br />Network engineer/architect interview questions<br />Explain how traceroute, ping, and tcpdump work and what they are used for?<br />Describe a case where you have used these tools to troubleshoot.<br />What is the last major networking problem you troubleshot and solved on your own in the last year?<br />What LAN analyzer tools are you familiar with and describe how you use them to troubleshoot and on what media and network types.<br />Explain the contents of a routing table (default route, next hop, etc.)<br />What routing protocols have you configured?<br />Describe the commands to set up a route.<br />What routing problems have you troubleshot?<br />How do you display a routing table on a Cisco? On a host?<br />How do you use a routing table and for what?<br />What is a route flap?<br />What is a metric?<br />When do you use BGP, IGRP, OSPF, Static Routes?<br />What do you see as current networking security issues (e.g. NFS mounting, spoofing, one time passwords, etc.)?<br />Describe a routing filter and what it does.<br />Describe an access list and what it does.<br />What is a network management system?<br />Describe how SNMP works.<br />Describe the working environment you are currently in, e.g. frequent interruptions, frequent priority shifting, team or individual.<br />What do you use to write documentation? Editor? Mail reader?<br />What platform (s) do you currently work on at your desk?<br />How do you manage multiple concurrent high level projects?<br />Describe a recent short term stressful situation and how you managed it.<br />How do you manage a long term demanding stressful work environment?<br />Have you worked in an assignment based environment, e.g. work request/trouble ticket system, and if so, describe that environment.<br />Describe what network statistics or measurement tools you are familiar with and how you have used them.<br />Describe what a VPN is and how it works.<br />Describe how VoIP works.<br />Describe methods of QoS.<br />How does ToS bit work?<br /><br />^Back to Top<br /><br />CCNA/Cisco admin interview questions<br />You need to retrieve a file from the file server for your word processing application, which layer of the OSI model is responsible for this function?<br />Presentation layer<br />Application layer<br />Session layer<br />Transport layer<br />Datalink layer<br />You are working in a word processing program, which is run from the file server. Your data comes back to you in an unintelligible manner. Which layer of the OSI model would you investigate?<br />Application layer<br />Presentation layer<br />Session layer<br />Network layer<br />Datalink layer<br />The IEEE subdivided the datalink layer to provide for environments that need connectionless or connection-oriented services. What are the two layers called?<br />Physical<br />MAC<br />LLC<br />Session<br />IP<br />You are working with graphic translations. Which layer of the OSI model is responsible for code formatting and conversion and graphic standards.<br />Network layer<br />Session layer<br />Transport layer<br />Presentation layer<br />Which is the best definition of encapsulation?<br />Each layer of the OSI model uses encryption to put the PDU from the upper layer into its data field. It adds header and trailer information that is available to its counterpart on the system that will receive it.<br />Data always needs to be tunneled to its destination so encapsulation must be used.<br />Each layer of the OSI model uses compression to put the PDU from the upper layer into its data field. It adds header and trailer information that is available to its counterpart on the system that will receive it.<br />Each layer of the OSI model uses encapsulation to put the PDU from the upper layer into its data field. It adds header and trailer information that is available to its counterpart on the system that will receive it.<br />Routers can be configured using several sources. Select which of the following sources can be used.<br />Console Port<br />Virtual Terminals<br />TFTP Server<br />Floppy disk<br />Removable media<br />Which memory component on a Cisco router contains the dynamic system configuration?<br />ROM<br />NVRAM<br />Flash<br />RAM/DRAM<br />Which combination of keys will allow you to view the previous commands that you typed at the router?<br />ESC-P<br />Ctrl-P<br />Shift-P<br />Alt-P<br />Which commands will display the active configuration parameters?<br />show running-config<br />write term<br />show version<br />display term<br />You are configuring a router, which prompt tells you that you are in the privileged EXEC mode?<br />@<br />><br />!<br />:<br />#<br />What does the command “IP name-server 255.255.255.255? accomplish?<br />It disables domain name lookup.<br />It sets the domain name lookup to be a local broadcast.<br />This is an illegal command.<br />The command is now defunct and has been replaced by “IP server-name ip any”<br />The following selections show the command prompt and the configuration of the IP network mask. Which two are correct?<br />Router(config-if)#netmask-format { bitcount | decimal | hexadecimal }<br />Router#term IP netmask-format { bitcount | decimal | hexadecimal }<br />Router(config-if)#IP netmask-format { bitcount | decimal | hexadecimal }<br />Router#ip netmask-format { bitcount | decimal | hexadecimal }<br />Which layer is responsible for flow control with sliding windows and reliability with sequence numbers and acknowledgments?<br />Transport<br />Application<br />Internet<br />Network Interface<br />Which processes does TCP, but not UDP, use?<br />Windowing<br />Acknowledgements<br />Source Port<br />Destination Port<br />Select which protocols use distance vector routing?<br />OSPF<br />RIP<br />IGRP<br />PPP<br /><br />^Back to Top<br /><br />Networking and Unix interview questions<br />What is UTP?<br /><br />UTP — Unshielded twisted pair 10BASE-T is the preferred Ethernet medium of the 90s. It is based on a star topology and provides a number of advantages over coaxial media:<br /><br />It uses inexpensive, readily available copper phone wire. UTP wire is much easier to install and debug than coax. UTP uses RG-45 connectors, which are cheap and reliable.<br /><br /><br />What is a router? What is a gateway?<br /><br />Routers are machines that direct a packet through the maze of networks that stand between its source and destination. Normally a router is used for internal networks while a gateway acts a door for the packet to reach the ‘outside’ of the internal network<br /><br /><br />What is Semaphore? What is deadlock?<br /><br />Semaphore is a synchronization tool to solve critical-section problem, can be used to control access to the critical section for a process or thread. The main disadvantage (same of mutual-exclusion) is require busy waiting. It will create problems in a multiprogramming system, where a single CPU is shared among many processes.<br /><br />Busy waiting wastes CPU cycles.<br /><br /><br />Deadlock is a situation when two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes. The implementation of a semaphore with a waiting queue may result in this situation.<br /><br /><br />What is Virtual Memory?<br /><br />Virtual memory is a technique that allows the execution of processes that may not be completely in memory. A separation of user logical memory from physical memory allows an extremely large virtual memory to be provided for programmers when only a smaller physical memory is available. It is commonly implemented by demand paging. A demand paging system is similar to a paging system with swapping. Processes reside on secondary memory (which is usually a disk). When we want to execute a process, we swap it into memory.<br /><br /><br />Explain the layered aspect of a UNIX system. What are the layers? What does it mean to say they are layers?<br /><br /><br />A UNIX system has essentially three main layers:<br /><br />. The hardware<br /><br />. The operating system kernel<br /><br />. The user-level programs<br /><br /><br />The kernel hides the system’s hardware underneath an abstract, high-level programming interface. It is responsible for implementing many of the facilities that users and user-level programs take for granted.<br /><br /><br />The kernel assembles all of the following UNIX concepts from lower-level hardware features:<br /><br />. Processes (time-sharing, protected address space)<br /><br />. Signals and semaphores<br /><br />. Virtual Memory (swapping, paging, and mapping)<br /><br />. The filesystem (files, directories, namespace)<br /><br />. Pipes and network connections (inter-process communication)Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-59003431928357885512009-06-22T21:59:00.000-07:002009-06-22T21:59:01.675-07:00Microprocessor Interview Questions And Answers8085 Microprocessor Questions:<br /><br />1. What are the various registers in 8085? - Accumulator register, Temporary register, Instruction register, Stack Pointer, Program Counter are the various registers in 8085 .<br />2. In 8085 name the 16 bit registers? - Stack pointer and Program counter all have 16 bits.<br />3. What are the various flags used in 8085? - Sign flag, Zero flag, Auxillary flag, Parity flag, Carry flag.<br />4. What is Stack Pointer? - Stack pointer is a special purpose 16-bit register in the Microprocessor, which holds the address of the top of the stack.<br />5. What is Program counter? - Program counter holds the address of either the first byte of the next instruction to be fetched for execution or the address of the next byte of a multi byte instruction, which has not been completely fetched. In both the cases it gets incremented automatically one by one as the instruction bytes get fetched. Also Program register keeps the address of the next instruction.<br />6. Which Stack is used in 8085? - LIFO (Last In First Out) stack is used in 8085.In this type of Stack the last stored information can be retrieved first.<br />7. What happens when HLT instruction is executed in processor? - The Micro Processor enters into Halt-State and the buses are tri-stated.<br />8. What is meant by a bus? - A bus is a group of conducting lines that carriers data, address, & control signals.<br />9. What is Tri-state logic? - Three Logic Levels are used and they are High, Low, High impedance state. The high and low are normal logic levels & high impedance state is electrical open circuit conditions. Tri-state logic has a third line called enable line.<br />10. Give an example of one address microprocessor? - 8085 is a one address microprocessor.<br />11. In what way interrupts are classified in 8085? - In 8085 the interrupts are classified as Hardware and Software interrupts.<br />12. What are Hardware interrupts? - TRAP, RST7.5, RST6.5, RST5.5, INTR.<br />13. What are Software interrupts? - RST0, RST1, RST2, RST3, RST4, RST5, RST6, RST7.<br />14. Which interrupt has the highest priority? - TRAP has the highest priority.<br />15. Name 5 different addressing modes? - Immediate, Direct, Register, Register indirect, Implied addressing modes.<br />16. How many interrupts are there in 8085? - There are 12 interrupts in 8085.<br />17. What is clock frequency for 8085? - 3 MHz is the maximum clock frequency for 8085.<br />18. What is the RST for the TRAP? - RST 4.5 is called as TRAP.<br />19. In 8085 which is called as High order / Low order Register? - Flag is called as Low order register & Accumulator is called as High order Register.<br />20. What are input & output devices? - Keyboards, Floppy disk are the examples of input devices. Printer, LED / LCD display, CRT Monitor are the examples of output devices.<br />21. Can an RC circuit be used as clock source for 8085? - Yes, it can be used, if an accurate clock frequency is not required. Also, the component cost is low compared to LC or Crystal.<br />22. Why crystal is a preferred clock source? - Because of high stability, large Q (Quality Factor) & the frequency that doesn’t drift with aging. Crystal is used as a clock source most of the times.<br />23. Which interrupt is not level-sensitive in 8085? - RST 7.5 is a raising edge-triggering interrupt.<br />24. What does Quality factor mean? - The Quality factor is also defined, as Q. So it is a number, which reflects the lossness of a circuit. Higher the Q, the lower are the losses.<br />25. What are level-triggering interrupt? - RST 6.5 & RST 5.5 are level-triggering interrupts<br /><br />8086 Interview Questions:<br />1. What are the flags in 8086? - In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag.<br />2. What are the various interrupts in 8086? - Maskable interrupts, Non-Maskable interrupts.<br />3. What is meant by Maskable interrupts? - An interrupt that can be turned off by the programmer is known as Maskable interrupt.<br />4. What is Non-Maskable interrupts? - An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable interrupt.<br />5. Which interrupts are generally used for critical events? - Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency, Shut off etc.,<br />6. Give examples for Maskable interrupts? - RST 7.5, RST6.5, RST5.5 are Maskable interrupts<br />7. Give example for Non-Maskable interrupts? - Trap is known as Non-Maskable interrupts, which is used in emergency condition.<br />8. What is the Maximum clock frequency in 8086? - 5 Mhz is the Maximum clock frequency in 8086.<br />9. What are the various segment registers in 8086? - Code, Data, Stack, Extra Segment registers in 8086.<br />10. Which Stack is used in 8086? - FIFO (First In First Out) stack is used in 8086.In this type of Stack the first stored information is retrieved first.<br />11. What are the address lines for the software interrupts? -<br />RST 0 0000 H<br /><br />RST1 0008 H<br /><br />RST2 0010 H<br /><br />RST3 0018 H<br /><br />RST4 0020 H<br /><br />RST5 0028 H<br /><br />RST6 0030 H<br /><br />RST7 0038 H<br /><br />12. What is SIM and RIM instructions? - SIM is Set Interrupt Mask. Used to mask the hardware interrupts. RIM is Read Interrupt Mask. Used to check whether the interrupt is Masked or not.<br />13. Which is the tool used to connect the user and the computer? - Interpreter is the tool used to connect the user and the tool.<br />14. What is the position of the Stack Pointer after the PUSH instruction? - The address line is 02 less than the earlier value.<br />15. What is the position of the Stack Pointer after the POP instruction? - The address line is 02 greater than the earlier value.<br />16. Logic calculations are done in which type of registers? - Accumulator is the register in which Arithmetic and Logic calculations are done.<br />17. What are the different functional units in 8086? - Bus Interface Unit and Execution unit, are the two different functional units in 8086.<br />18. Give examples for Micro controller? - Z80, Intel MSC51 &96, Motorola are the best examples of Microcontroller.<br />19. What is meant by cross-compiler? - A program runs on one machine and executes on another is called as cross-compiler.<br />20. What are the address lines for the hardware interrupts? -<br /><br />RST 7.5 003C H<br /><br />RST 6.5 0034 H<br /><br />RST 5.5 002C H<br />TRAP 0024 H<br /><br />21. Which Segment is used to store interrupt and subroutine return address registers? - Stack Segment in segment register is used to store interrupt and subroutine return address registers.<br />22. Which Flags can be set or reset by the programmer and also used to control the operation of the processor? - Trace Flag, Interrupt Flag, Direction Flag.<br />23. What does EU do? - Execution Unit receives program instruction codes and data from BIU, executes these instructions and store the result in general registers.<br />24. Which microprocessor accepts the program written for 8086 without any changes? - 8088 is that processor.<br />25. What is the difference between 8086 and 8088? - The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue is 4 byte long in 8088and 6 byte in 8086.<br /><br /><br /><br />________________________________________________________________________<br /><br />*** People who feel good about themselves - Produce good results ***<br /><br /><br />Regards,<br /><br />Sachchidanand SinghSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-26706877516972253342009-06-20T23:45:00.000-07:002009-06-20T06:24:31.832-07:00Behavioral Interview QuestionsBehavioral questions can be difficult if you are not prepared. Always try to<br />be conscious about what the recruiter is trying to find out about you by asking you a particular question. Setting up a mock interview with the MIT Careers Office is an excellent way to practice. Here are some examples:<br /><br />Adaptability:<br />Tell me about a time when you had to adjust to a classmate’s or colleague’s working style in order to complete a project or achieve your objectives.<br /><br />Analytical Skills/Problem Solving<br />Tell me about a situation where you had to solve a difficult problem. What did you do? What was your thought process? What was the outcome? What do you wish you had done differently?<br /><br />Communication:<br />What is your typical way of dealing with conflict? Give me an example.<br />Give me an example of a time when you were able to successfully communicate with another person even when that individual may not have personally liked you (or vice versa). How did you handle the situation? What obstacles or difficulties did you face? How did you deal with them?<br /><br />Creativity:<br />Tell me about a time when you had to use your presentation skills to influence someone's opinion. Tell me about a problem that you’ve solved in a unique or unusual way. What was the outcome? Were you happy or satisfied with it?<br /><br />Decision Making:<br />Tell me about a difficult decision you've made in the last year.<br />Describe a situation where you have had to overcome a problem or obstacle in order to move forward with something. What did you do?<br />Tell me about a time when you had to make a decision without all the information you needed. How did you handle it? Why? Were you happy with the outcome?<br /><br />Flexibility:<br />Give me a specific example of a time when you had to conform to a policy with which you did not agree. Describe a time when you put your needs aside to help a co-worker understand a task. How did you assist them? What was the result?<br /><br />Goal Setting:<br />Give me an example of a time when you set a goal and were able to meet or achieve it.<br />What do you consider to be your greatest achievement so far and why?<br />Tell me about a goal that you set that you did not reach. What steps did you take? What obstacles did you encounter? How did it make you feel?<br /><br />Iniative:<br />Describe a time when you anticipated potential problems and developed preventive measures.<br />What tricks or techniques have you learned to make school or a job easier, or to make yourself more effective? How did you learn that?<br />Describe a situation where you have had to use your initiative to solve a problem. What did you do?<br />What was the best idea you came up with during your professional or college career? How did you apply it?<br />Give me an example of a time when something you tried to accomplish and failed.<br />Give me an example of when you showed initiative and took the lead.<br /><br />Integrity/Honesty:<br />Tell me about a time when you missed an obvious solution to a problem.<br />Tell me about a time when you were forced to make an unpopular decision.<br />Tell me about a time you had to fire a friend.<br />Describe a time when you set your sights too high (or too low).<br />Tell of the most difficult customer service experience that you have ever had to handleperhaps an angry or irate customer. Be specific and tell what you did and what was the<br />outcome.<br />Tell me about a time when you had to go above and beyond the call of duty in order to get a job done. Give a specific example of a policy you conformed to with which you did not agree. Why?<br /><br />Leadership:<br />Give me an example of a time when you motivated others.<br />Tell me about a time when you delegated a project effectively.<br />What has been your experience in giving presentations to small or large groups? What has been your most successful experience in speech making?<br />Tell me about a team project when you had to take the lead or take charge of the project?<br />What did you do? How did you do it? What was the result?<br /><br />Interpersonal Skills:<br />Give me an example of a time when you used your fact-finding skills to solve a problem.<br />Give me a specific example of a time when you used good judgment and logic in solving a problem.<br />Describe a situation in which you were able to use persuasion to successfully convince someone to see things your way.<br />Give an example of when you had to work with someone who was difficult to get along with. How/why was this person difficult? How did you handle it? How did the relationship progress?<br /><br /><br />Planning and Organization/Time Management:<br />How do you determine priorities in scheduling your time? Give examples.<br />Describe a time in school when you had many projects or assignments due at the same time. What steps did you take to get them all done?<br />Tell me about a time when you had too many things to do and you were required to prioritize your tasks.<br />How do you prioritize projects and tasks when scheduling your time? Give me some examples.<br /><br />Teamwork:<br />Tell me about a time you were able to successfully deal with another person even when that individual may not have personally liked you (or vice versa).<br />Tell me about a recent situation in which you had to deal with a very upset customer or co-worker.<br />Describe a situation where you have had to work as part of a team to achieve a result. What was your role in this?<br />Describe a situation where others you were working with on a project disagreed with your ideas. What did you do?Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-90498088334520943342008-12-11T04:25:00.000-08:002009-02-13T02:55:51.942-08:00Introduction to ProgrammingComputer Systems<br />A computer system consists of all the components (hardware and software) used to execute the desires of the computer user. Hardware is the electronic phys- ical components that can retrieve, process and store data. It is generally broken down into five basic components:<br />Central Processing This is the unit where programs are executed. It<br />Unit (C.P.U.) consists of the control unit, which oversees the<br />overall operation of program execution and the<br />A.L.U. (Arithmetic/Logic Unit), which performs the<br />mathematical and comparison operations.<br />Main Memory The area where programs and data are stored for<br />use by the CPU<br />Secondary Storage The area where programs and data are filed (stored)<br />for use at a later time<br />Input Devices The devices used to get programs and data into the<br />computer (e.g., a keyboard)<br />Output Devices The devices used to get programs and data from the<br />computer (e.g., a printer)<br />Software consists of a sequence of instructions given to perform some pre-defined task. These labs concentrate on the software portion of a computer system.<br />Introduction to Programming<br />A computer program is a series of instructions written in some computer lan- guage that performs a particular task. Many times beginning students concentrate solely on the language code; however, quality software is accomplished only after careful design that identifies the needs, data, process and anticipated out- comes. For this reason it is critical that students learn good design techniques before attempting to produce a quality program. Design is guided by an algo- rithm, which is a plan of attacking some problem. An algorithm is used for many aspects of tasks, whether a recipe for a cake, a guide to study for an exam or the specifications of a rocket engine.<br /><br />Problem example: Develop an algorithm to find the average of five test grades. <br /><br /> <br /> <br />An algorithm usually begins with a general broad statement of the problem.<br />Find the average of Five Test Grades<br />From here we can further refine the statement by listing commands that will accomplish our goal.<br />Read in the Grades Find the Average Write out the Average<br /> <br />Each box (called a node) may or may not be refined further depending on its clarity to the user. For example: Find the Average may be as refined as an experienced programmer needs to accomplish the task of finding an average; however, students learning how to compute averages for the first time may need more refinement about how to accomplish the goal. This refinement process continues until we have a listing of steps understandable to the user to accomplish the task. For example, Find the Average may be refined into the fol- lowing two nodes.<br />Total=sum of 5 grades Average=Total/5<br /> <br />Starting from left to right, a node that has no refinement becomes part of the algo- rithm. The actual algorithm (steps in solving the above program) is listed in bold.<br />Find the Average of Five Test Grades<br />Read in the Grades<br />Find the Average<br />Total = sum of 5 grades Average = Total / 5<br />Write Out the Average<br />From this algorithm, a program can be written in C++.<br />Translation Process<br />Computers are strange in that they only understand a sequence of 1s and 0s. The following looks like nonsense to us but, in fact, is how the computer reads and executes everything that it does:<br />10010001111010101110010001110001000<br />Because computers only use two numbers (1 and 0), this is called binary code. can imagine how complicated programming would be if we had to learn this very complex language. That, in fact, was how programming was done many years ago; however, today we are fortunate to have what are called high level languages such as C++. These languages are geared more for human understanding and thus make the task of programming much easier. However, since the computer only understands low level binary code (often called machine code), there must be a translation process to convert these high level languages to machine code. This is often done by a compiler, which is a software package that translates high level<br /> <br /> <br /> languages into machine code. Without it we could not run our programs. The fig- <br /> ure below illustrates the role of the compiler. <br /> High Level Low Level Code <br /> <br /> Compiler <br /> <br /> Language Code <br /> (Object Code) <br /> <br /> (Source Code) <br /> <br />The compiler translates source code into object code. The type of code is often reflected in the extension name of the file where it is located.<br />Example: We will write source (high level language) code in C++ and all our file names will end with .cpp, such as:<br />firstprogram.cpp secondprogram.cpp<br />When those programs are compiled, a new file (object file) will be created that ends with .obj, such as:<br />firstprogram.obj secondprogram.obj<br />The compiler also catches grammatical errors called syntax errors in the source code. Just like English, all computer languages have their own set of grammar rules that have to be obeyed. If we turned in a paper with a proper name (like John) not capitalized, we would be called to task by our teacher, and probably made to correct the mistake. The compiler does the same thing. If we have something that violates the grammatical rules of the language, the compiler will give us error messages. These have to be corrected and a grammar error free program must be submitted to the compiler before it translates the source code into machine language. In C++, for example, instructions end with a semicolon. The following would indicate a syntax error:<br />cout << "Hi there" << endl<br />Since there is no semicolon at the end, the compiler would indicate an error, which must be corrected as follows:<br />cout << "Hi there" << endl;<br />After the compile process is completed, the computer must do one more thing before we have a copy of the machine code that is ready to be executed. Most programs are not entirely complete in and of themselves. They need other mod- ules previously written that perform certain operations such as data input and out- put. Our programs need these attachments in order to run. This is the function of the linking process. Suppose you are writing a term paper on whales and would like a few library articles attached to your report. You would go to the library, get a copy of the articles (assuming it would be legal to do so), and attach them to your paper before turning it in. The linker does this to your pro- gram. It goes to a “software library” of programs and attaches the appropriate code to your program. This produces what is called the executable code, generated in a file that often ends with .exe.<br />Example: firstprogram.exe secondprogram.exe<br /><br />The following figure summarizes the translation process:<br /> <br /><br /><br />firstprogram.cpp<br />Compiler<br />firstprogram.obj<br />Library Linker <br /> <br />firstprogram.exe<br /><br />Source Code<br />(High Level Language<br />such as C++)<br />Compiler translates source code into object code.<br />The .obj file contains a translation of the source code.<br />Linker links library code with the object code to produce the .exe file.<br />The .exe file is executable.<br /><br />Once we have the executable code, the program is ready to be run. Hopefully it will run correctly and everything will be fine; however that is not always the case. During “run time”, we may encounter a second kind of error called a run time error. This error occurs when we ask the computer to do something it cannot do. Look at the following sentence:<br />You are required to swim from Naples, Italy to New York in five minutes.<br />Although this statement is grammatically correct, it is asking someone to do the impossible. Just as we cannot break the laws of nature, the computer cannot violate the laws of mathematics and other binding restrictions. Asking the com- puter to divide by 0 is an example of a run time error. We get executable code; however, when the program tries to execute the command to divide by 0, the pro- gram will stop with a run time error. Run time errors, particularly in C++, are usu- ally more challenging to find than syntax errors.<br />Once we run our program and get neither syntax nor run time errors, are we free to rejoice? Not exactly. Unfortunately, it is now that we may encounter the worst type of error: the dreaded Logic error. Whenever we ask the computer to do something, but mean for it to do something else, we have a logic error. Just as there needs to be a “meeting of the minds” between two people for meaningful communication to take place, there must be precise and clear instructions that gen- erate our intentions to the computer. The computer only does what we ask it to do. It does not read our minds or our intentions! If we ask a group of people to cut down the tree when we really meant for them to trim the bush, we have a communication problem. They will do what we ask, but what we asked and what we wanted are two different things. The same is true for the computer. Asking it to multiply by 3 when we want something doubled is an example of a<br /> <br /> <br />logic error. Logic errors are the most difficult to find and correct because there are no error messages to help us locate the problem. A great deal of program- ming time is spent on solving logic errors.<br />Integrated Environments<br />An integrated development environment (IDE) is a software package that bun- dles an editor (used to write programs), a compiler (that translates programs) and a run time component into one system. For example, the figure below shows a screen from the Microsoft Visual C++ integrated environment.<br />Other systems may have these components separate which makes the process of running a program a little more difficult. You should also be aware of which Operating System you are using. An Operating System is the most important software on your computer. It is the “grand master” of programs that interfaces the computer with your requests. Your instructor will explain your particular sys- tem and C++ environment so that you will be able to develop, compile and run C++ programs on it.<br />A S S I G N M E N T<br />Fill-in-the-Blank Questions<br />1. Compilers detect errors. <br /> <br />2. Usually the most difficult errors to correct are the errors, <br /> <br /> since they are not detected in the compilation process. <br />3. Attaching other pre-written routines to your program is done by the <br /> process. <br />4. <br /> code is the machine code consisting of ones and zeroes <br /> <br /> that is read by the computer. <br />5. Dividing by zero is an example of a error. <br /> <br /><br />Lesson 1A 7<br />Learn the Environment That You Are Working In<br />The following information may be obtained from your instructor.<br />1. What operating system are you using?<br />2. What C++ environment are you working in?<br />3. If you are not working in an integrated environment, what are the com- pile, run and edit commands that you will need?<br />L E S S O N 1 A<br />Your instructor may assign either Appendix A or Appendix B depending on your environment. Appendix A is for labs using Visual C++ and Appendix B is for labs using UNIX. If you are using an environment other than these two, your instructor will give you instructions for this first lesson and ask you to complete Lab 1.1 below.<br />LAB 1.1 Opening, Compiling and Running Your First Program<br />Exercise 1: Logon to your system based on your professor’s instructions.<br />Exercise 2: Bring in the firstprog.cpp program from the Lab 1 folder.<br />Exercise 3: Compile the program.<br />Exercise 4: Run the program and write what is printed on the screen.<br />The code of firstprog.cpp is as follows:<br />// This is the first program that just writes out a simple message<br />// Place your name here<br /> #include // needed to perform C++ I/O<br /> using namespace std; <br /> int main () <br /> { <br /> cout << "Now is the time for all good men" << endl;<br /> cout << "To come to the aid of their party" << endl;<br /> return 0; <br /> } <br /> <br />LAB 1.2 Compiling a Program with a Syntax Error <br />Exercise 1: Bring in program semiprob.cpp from the Lab 1 folder.<br />Exercise 2: Compile the program. Here we have our first example of the many syntax errors that you no doubt will encounter in this course. The error message you receive may be different depending on the system you are using, but the compiler insists that a semicolon is missing somewhere. Unfortunately, where the message indicates that the problem exists, and where the problem actually occurs may be two different places. To correct<br /> <br /> <br />the problem place a semicolon after the line cout << "Today is a great day for Lab".<br />Most syntax errors are not as easy to spot and correct as this one.<br />Exercise 3: Re-compile the program and when you have no syntax errors, run the program and input 9 when asked. Record the output.<br />Exercise 4: Try running it with different numbers. Record your output.<br />Do you feel you are getting valid output?<br />The code of semiprob.cpp is as follows:<br />// This program demonstrates a compile error.<br />// Place your name here<br />#include using namespace std;<br />int main()<br />{<br />int number; float total;<br />cout << "Today is a great day for Lab"<br />cout <<>> number;<br />total = number * 2;<br />cout << total << " is twice the number you typed" << endl;<br />return 0;<br />}<br />LAB 1.3 Running a Program with a Run Time Error<br />Exercise 1: Bring in program runprob.cpp from the Lab 1 folder.<br />Exercise 2: Compile the program. You should get no syntax errors.<br />Exercise 3: Run the program. You should now see the first of several run time errors. There was no syntax or grammatical error in the program; however, just like commanding someone to break a law of nature, the program is asking the computer to break a law of math by dividing by zero. It cannot be done. On some installations, you may see this as output that looks very strange. Correct this program by having the code divide by 2 instead of 0.<br />Exercise 4: Re-compile and run the program. Type 9 when asked for input. Record what is printed.<br /> <br /><br /> <br />Lesson 1B 9<br />Exercise 5: Run the program using different values. Record the output. Do you feel that you are getting valid output?<br />The code of runprob.cpp is as follows:<br />// This program will take a number and divide it by 2.<br />// Place your name here<br />#include using namespace std;<br />int main()<br />{<br />float number; int divider;<br />divider = 0;<br />cout << "Hi there" << endl;<br />cout << "Please input a number and then hit return" <<>> number;<br />number = number / divider;<br />cout << "Half of your number is " << number << endl;<br />return 0;<br />}<br />L E S S O N 1 B<br />LAB 1.4 Working with Logic Errors<br />Exercise 1: Bring in program logicprob.cpp from the Lab 1 folder. The code follows.<br />// This program takes two values from the user and then swaps them<br />// before printing the values. The user will be prompted to enter<br />// both numbers.<br />// Place your name here<br />#include<br />using namespace std;<br /><br /><br /><br /> <br />int main()<br />{<br />float firstNumber; float secondNumber;<br />// Prompt user to enter the first number.<br />cout << "Enter the first number" <<>> firstNumber;<br />// Prompt user to enter the second number.<br />cout << "Enter the second number" <<><br />cin >> secondNumber;<br />// Echo print the input.<br />cout << endl << "You input the numbers as " << firstNumber<br /><< " and " << secondNumber << endl;<br />// Now we will swap the values.<br />firstNumber = secondNumber; secondNumber = firstNumber;<br />// Output the values.<br />cout << "After swapping, the values of the two numbers are " <<><br />return 0;<br />}<br />Exercise 2: Compile this program. You should get no syntax errors.<br />Exercise 3: Run the program. What is printed?<br />Exercise 4: This program has no syntax or run time errors, but it certainly has a logic error. This logic error may not be easy to find. Most logic errors create a challenge for the programmer. Your instructor may ask you not to worry about finding and correcting the problem at this time.<br /> <br /><br />Lesson 1B 11<br />LAB 1.5 Writing Your First Program (Optional)<br />Exercise 1: Develop a design that leads to an algorithm and a program that will read in a number that represents the number of kilometers traveled. The output will convert this number to miles. 1 kilometer = 0.621 miles. Call this program kilotomiles.cpp.<br />Exercise 2: Compile the program. If you get compile errors, try to fix them and re-compile until your program is free of syntax errors.<br />Exercise 3: Run the program. Is your output what you expect from the input you gave? If not, try to find and correct the logic error and run the pro- gram again. Continue this process until you have a program that produces the correct result.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-36642934464497571142008-10-22T22:34:00.000-07:002008-12-23T04:01:37.822-08:00Kanbay Placement Test, Papers and Procedure<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>ZH-MO</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Cite"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="HTML Typewriter"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 1 Char"; mso-style-next:Normal; margin-top:0in; margin-right:.5in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:10.0pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman","serif"; color:black; mso-font-kerning:0pt; mso-fareast-language:EN-US; font-weight:bold;} p {mso-style-noshow:yes; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} tt {mso-style-noshow:yes; mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 1"; mso-bidi-font-size:12.0pt; color:black; mso-fareast-language:EN-US; font-weight:bold;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1799956180; mso-list-type:hybrid; mso-list-template-ids:-1759592220 -431582614 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-number-format:alpha-lower; mso-level-text:"\(%1\)"; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <p style="margin: 5pt 0.5in;"><strong><span style="font-size: 10pt;">Kanbay Exam conducted on 2nd Aug 2003.</span></strong><span style="font-size: 10pt;">The Selection Process will have Written Test, GD & Interview. : <strong>GD : Y</strong>ou are each given a role to play..u have to justify why yours is best suited to the question and final reach a general consensus.<span style="color: black;"> Tps: Be cool...... Listen carefully..... n talk..talk what u want but do say something.. don't be too aggressive nor too submissive n yes..don't address any one member only.</span><strong>Interview:</strong><span style="color: black;"> They also ask puzzles like: <o:p></o:p></span></span></p> <p style="margin: 5pt 0.5in;"><span style="font-size: 10pt; color: black;">3 switches in the bottom floor, 3 bulbs on top floor..u can go upstairs only once.find out which switch is for which bulb. then , out of a group of<span style=""> </span>10 matchboxes..each with 10 matchsticks of 10 gms. if one weighs 9 gms..how will u find it in minimum no. of weighings.. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">Be confidant and preapre ques like why should we take u?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">what are ur assets, hobbies, the last book that read , the last film that u saw ..name of characters in that film etc..<o:p></o:p></span></p> <h1> Few questions of KANBAY 2003,aug 1st,in KITS college Bhubaneswar</h1> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">I am sending all those which I could remember,all were multiple choices..they said cut-off was 12 but it was actually 15 per section. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">It had two sections ,LOGIC AND MATHS,cut of in each secn 12,each had <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">30 questions,1 mark each<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">LOGIC<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1.problems on permutation combinations like BANANA,…..<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2.if april 18 was Wednesday in 1998,when is april 18 in 1999?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3.if B has its shadow falling on right side early morning ,then in <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">which direction is he facing?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4.age problems like…….Mothers age was twice the the age of son two years ago.after how many years will she be three times her sons age??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 5.analyzing data interpretations and around 4-5 questions based on tat<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 6.a Guy has some chocolates with him he distributes them equally among 5 people and remaning with him is 3.if he distributes them equlay among 7 people remaining is 5 with him. Which of them isn't is possible no.of chocolates he had??53,208……….<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 7.4-5 problems on profit And loss<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">8.in a test moti,ganesh,manali,rupali,raj, appear,according to the scores moti is not the leats scorer but is lower to raj………….who<span style=""> </span>occupies the 2 nd postion is the order?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 9.mr a meets mrs b.mr b is has a son and daughter .son is moti and is married and has a son .mrs moti is mr a mother .how is mr a related to mr b??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 10.ram buys some dozens of apples and peaches .their price ratio is 5:7.if the price of 1 dozen of peach is is rs 9,how many dozens of<span style=""> </span>apple did he bring?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 11.problems based on relationships like those in rs aggarwal<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 12.in a queue A is is in 7 th positon from the left and B is 9<span style=""> </span>position from the left .if they switch positions A is in 11 th<span style=""> </span>position ,find the total people in the row??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> <b>MATHS<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1. S 1=={1,2,3,4}, S 2 =={A,B.C……….Z},S 3=={……………},(S1*S2)U S3==?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 2. IF 5*4= ,8*7=B,how much is 6*9== <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3. 4 to 5 questions on simplifying complex nos. equations<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 4. sphere of radius 4.5 cm is divide in three spheres ,two have radius 1.5 and 2 cm,find the other ones?? <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">5. if COMPLEX == 81,and……………….how much is ANALYSE==?? 2-3 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">6. two taps a and b fill up a cistern in 2 and3 hrs ,at wat time<span style=""> </span>should b be clsed if the tank cistern is filled up in 17 minutes?? <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">7. a doctor checks 5 patients every 3 hrs with abreak of 10<span style=""> </span>minutes between each two check ups.how many he patients he checks in<span style=""> </span>10 hrs and 15 minutes??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 8. no. of diagonals friends if vertices of a octagon are joined??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 9. an equilateral triangle is formed by joining the centers of<span style=""> </span>sides of a equilateral triangle.wat is the ratio of area ,s of both<span style=""> </span>the triangles??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> 10. A can finish the work in 3 days , B can finish the work in double efficiency,can finish with equal efficiency of both A and B.if<span style=""> </span>all work together within how many days will they complete the work? <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">11. A.B,C,D stand at the edges of a square.they start moving<span style=""> </span>along the square sides.after clockwise rotation where will each be?? <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">12. if 1 is stop,2 is run,3 is go,4 is wait,5 is walk,then would<span style=""> </span>be the next stage if the following pattern 5 5 4 3 2 1 ……………………..<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4 1 2 2 3 1 ? <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">13. C remembers meeting B after 14 but before 18 ,but D<span style=""> </span>remembers meeting B after 16 but before 18.when did both meet B??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">14. avg age of boys in a class is 12.when the age of teacher is<span style=""> </span>included it is 13.wat could be the age of teacher? 35 , 45,53,50<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> <b>written test consists of 2 sections(apptitude and logical reasoning) <o:p></o:p></b></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">of 30 quest. each and cut off is 12 each.and the total time is 1 hour. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1. which is greater (1000)pow1001 and 1001pow999<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2.one container contains milk and water in the ratio 3:7 and the<span style=""> </span>other contains 8:11,in what ratio these two containers is to be mixed<span style=""> </span>so that the ratio of milk and water is 4:5.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3. there are two simple problems on time and work. 4.four points will be given and you have to frame two st. line eq.s<span style=""> </span>in such a way that their point of interesection lies in one of the<span style=""> </span>four options.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">5.there are two to three problems on profit and loss which are little<span style=""> </span>bit time taking ,so i didn't attempt. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">6.a series of nos will be given where the ans can be found by<span style=""> </span>observing the diff bet two consecutive nos <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><b><span style="font-size: 10pt; color: black;">logical reasoning<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1. air is cloud<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>cloud is rain<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>rain is water<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>wateris sand<span style=""> </span>so what is cloud?<span style=""> </span>ans<span style=""> </span>:sand<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2. one quesion on relations<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3. trafic: signal<span style=""> </span>ans : river :dam<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4. two more quesions are there 5. dsoighkl now if lk-(?)-sd<span style=""> </span>, find letter in 4th place<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">6. some mammals are donkeys<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>allbuffalos will have horns<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>based on this 3 quesions r ther<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">7. two more r simmilar to above<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">8. to decode the noise :-<span style=""> </span>H.................M<span style=""> </span>ANS:C<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">9.cube is of size 5*5*5 .every side has been coloured. it is divided into 125 equal parts.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1) what is the no. of parts having only one side coloured - 54. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2) no. of parts having two sided coloured<span style=""> </span>36. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3) having no side coloured - 27.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">10.find the no. of occurrence of T which is immediately preceded y P and no<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">timmediately followed by S in some series for eg. (TPTSTRUST.......)<span style=""> </span>ans - 3<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">11.Four persons are there wearing different coloured shirts eg.<span style=""> </span>A,B,C,D <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">wearing blue ,green, red, yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span><span style=""> </span>Now, 1. A cannot wear yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>2. B can wear blue or green.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>3. C /D is wearing yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>You have to find who is wearing which coloured shirt.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">12.Find the root of 4a2+b2+c2+4ab-2bc-4ac<span style=""> </span>Ans: 2a+b-c.Two <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">pipes<span style=""> </span>can<span style=""> </span>fill a tank in 5 hrs and 8 hrs.<span style=""> </span>while a hole can empty it in 40 hrs. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">What<span style=""> </span>will be the time taken to fill if each operate at a time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>Soln:<span style=""> </span>1\x == 1\5 + 1\8 - 1\40<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">13.A can beat B by 20 mts. While C can beat B by 40 mts. In a race of<span style=""> </span>100 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">mts. By how much can C beat A?<span style=""> </span>Soln: 75 mts.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">14.If u start your journey 30 minutes late , u have to increase your<span style=""> </span>speed<span style=""> </span>by 250kms\hr. to cover up 1500 kms. In same time.<span style=""> </span>What is your usual<span style=""> </span>speed?<span style=""> </span>Ans: 750kms\hr.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">15.For a circle, radius is inc. by some % , find net change in area?<span style=""> </span><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">gd topics are<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>lov marriages r arranged marages<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>r tv serials helpful<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">R.S. AGRAWAL .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">Go thru<span style=""> </span>1>blood relation.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2>analogy.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3>coding ?decoding.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4> puzzles.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">Qus related<span style=""> </span>to these topics were asked .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1)complete the series<span style=""> </span>600 ,180 ,54,<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">ans===.2( options were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2) some doctors are fool john<span style=""> </span>is a doctor<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">a> john is a fool.b>all<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">b><span style=""> </span>fools are doctors<span style=""> </span>from this you have to draw the conclusion given in the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">options such as only a is true only b is tru both are tru or none is tru.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">3> similar question like2 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">some teacher are female.a is female.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">a>she is a teacher.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">b>all females are teacher.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4>river : dam<span style=""> </span>::<span style=""> </span>traffic:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">ans.==== signal<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">other qus related to analogy were there .go thru R.S.AGRAWAL.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">other<span style=""> </span>qus were from the lbood relations .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">some qus were from puzzles .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">a,b,c,d,e,f,g are 7 epople seating on a wall facing<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">towards north.b is not at the end.c and<span style=""> </span>d can not<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">seat together .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">qus like this were there .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"> mathematical qus / aptitudes.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">1)a sum of money doubles in 5 years by simple interest . how much time it will take for 300 to become 2400.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">a>40 years b>25 years<span style=""> </span>c>35 years<span style=""> </span>d> 20 years.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">2)if length of a rectangle is made 4 less and breadth is increased by 3 then the resultant square ?s area is equal to the rectangle. What is the perimeter of the rectangle .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>3)what will be the no. at ? position below<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>51<span style=""> </span>11<span style=""> </span>61<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>64<span style=""> </span>30<span style=""> </span>32 <span style=""> </span>35<span style=""> </span>?<span style=""> </span>43<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">4>the L.C.M. and<span style=""> </span>H.C.F. of two nos. are 84 and 21<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">and the nos. are in the ratio of 1:4 ,. Find the nos.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">ans====<span style=""> </span>21, 84<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">5)find the volume of the hemisphere having radius 2m . <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">6>problem based on compound interest were asked . so<span style=""> </span>see the formula of compound interest.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">7)a train goes from a to b. if it travels with 50 km/s then it is late by 10 mins. When it travels with30km/s then it bis late by 50 mins. Fi nd the distance between a and b.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">8)a river is 8 m deep and 150 m wide.river?s speed is 5 km/s.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">find the volume of water passed in one min.(1 m cube =1000 c.c.) <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">9) fin dthe equation of the st. line passing thru the intersection of<span style=""> </span>the two lines<span style=""> </span>and two other lines.(equ.<span style=""> </span>Were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">10) a man sells 20 mangoes + 15 oranges<span style=""> </span>ath the same price as 15 mangoes+20 oranges. Ho would judge<span style=""> </span>which is costlier .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">11) a graph was given representing joint venture in the years. An dquestion related to the graph were asked such as<span style=""> </span>A)in which year there was max. change.(ans. Was in the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">last year)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">12)A is counting the no from 1 to 32 and b from 32 .A is counting the odd no. only .both?s speed is same. What will be the number which will be pronounced by A<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">&<span style=""> </span>B<span style=""> </span>together. ( ans .<span style=""> </span>aws<span style=""> </span>none of these )but confirm yourself .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">13) in the word ?DISTURBANCE?<span style=""> </span>1st<span style=""> </span>is replaced by last 2nd<span style=""> </span>is replced by 10th , 3rd is<span style=""> </span>by 9th<span style=""> </span>and so on. Which will be the next to<span style=""> </span>?T?.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">14)GIVEN<span style=""> </span>if x/y==3/5. if 1 is added to num . and 1 is subtracted from denominator then ratio ==5/7. find the number.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">15)there are 5 black and 9 white balls .if one ball is drawn then find the probability of being white. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">16)Avg. age of 5 children =.a child of 5 year age dies.after 4 years what will be the avg. age. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">17)three nos. are given<span style=""> </span>the product of<span style=""> </span>first and last is equal to the square<span style=""> </span>of the middle. Find the nos.(options were given) ans.== 10, 20, 40)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;"><span style=""> </span>18) a rectangle was having<span style=""> </span>length 100 m<span style=""> </span>breadth<span style=""> </span>60 m. there is a road of 5m wide on each side of the rectangle . find the area of the road.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">19) fir no. is<span style=""> </span>the<span style=""> </span>double of 2nd and ½ of the 3rd .(ans=H,24,96)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">20) a girl cuts a cake in two<span style=""> </span>halevs. One half is again<span style=""> </span>cut into six<span style=""> </span>equal parts . wt. Of the smaller one was 20 gms. Fin the wt. Of the whole cake.(ans=240gms.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">21)other question was based on the relative speed in the river . i.e. a person first goes upstream then down stream . river?s speed was<span style=""> </span>given .also the diff. Of time was<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">given . find the speed<span style=""> </span>of the man.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">22) ravana speed is 5000 km/s when going towards the heaven. The distance == 75000. ravana has traveled<span style=""> </span>2<span style=""> </span>mins. When god?s messenger reaches the earth . Rama told him<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">to go back. The speed of the god?s messenger =`00 km/s. By how much he will increase or decrease his speed so that he and Ravana reaches exactly at the same time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="font-size: 10pt; color: black;">23) a man sells a product by giving 10% reduction<span style=""> </span>on it .in spite of this he gets 10% profit . on<span style=""> </span>a product of 330 rs. Original price What will be the buying price.<o:p></o:p></span></p> <p class="MsoNormal"><tt><b><span style="font-size: 10pt;"><o:p> </o:p></span></b></tt></p> <p class="MsoNormal"><tt><b><span style="font-size: 10pt;">SECTION A) APTITUTE</span></b></tt><b><span style="font-size: 10pt;">
<br /></span></b><tt><span style="font-size: 10pt;">1) day:night:: then</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">a) man:woman</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">b) spring:summer</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">c) light : dark</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">2)if BOMBAY = MYMYMY</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">then code of .......</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">ans) choose every third alphabet</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">3) 5 * 4 = 12</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">and 8* 7 =42</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">then 9* 6 = ?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">solution (9-2)*6 =</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">4).if a certain money becomes twice in 5 years(simple<span style=""> </span>interest).then the 300 rs. will become 2400 at the same rate in how many years........ ans 35 year</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">5)after giving 35.66% discount. a saler makes a loss of 11.11 rs..............</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">6).there is a number when diveded by 5 gives a remainder 3 and when divede by 7 gives a</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">remainder of 5 Ans is 33.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">7).a boat is going along the stream and returning in the opposite direction of stream it travels</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">10 km along stream.the sppeed of stream is 3 km/hr,then find the speed of boat.<o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;"><span style=""> </span>9).A and B runing around a circle of perimeter of 1200meter(may be differ).A is runing at 210</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">meter/minute and B is running 190 metre/minute in oppsite direction to each other.at</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">wich time they will meet. ans) 3 mins</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">10) A person goes to the house of Sita who is the neighbour of Gita. Amar married with Anita who is the</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">sister of Sita. Ashu is the father of Amar.<o:p></o:p></span></tt></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><tt><span style="font-size: 10pt;"><span style="">(a)</span></span></tt><!--[endif]--><tt><span style="font-size: 10pt;">What is the relation between Sita and Amar?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">(b) What is the relation between Amar and Gita?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">11) what is the day on 12 january 1979 ? </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">12).If GEN = 9 , ABOUT = 15 then GENERAL = ? solu. 3* 3 =9 , 5*3=15,so 7 *3= 21<o:p></o:p></span></tt></p> <p class="MsoNormal" style="margin-left: 0.25in;"><tt><span style="font-size: 10pt;">13).A is richer than B. B is richer than C. C is richer than D. D is richer than E. Then who is</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">the middle of this relation. <o:p></o:p></span></tt></p> <p class="MsoNormal" style="margin-left: 0.25in;"><tt><span style="font-size: 10pt;">14)A,Band C. B is as younger than A as b is as older than C if A and C age sum is 80 .then age of B is</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">15)A mother 1 year back is 4 times her son age .after 6 years she is 3 times her son age.if the present age of son is<span style=""> </span>20.find his mother age.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><b><span style="font-size: 10pt;">SECTION B) MATHS</span></b></tt><b><span style="font-size: 10pt;">
<br /></span></b><tt><span style="font-size: 10pt;">1) s1 = { 1,2,3.......,20}</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">s2 = { a,b,c,d}</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">s3 = { b,d,e,f } then the number of element in (s1*s2 )U ( s1* s3) ans) 120</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">2)a graph was given and three question was asked on it.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">3) | z-2|square + |z-1| = constant . this represent what a) circle b) ellipse c) parabola d) none</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">4)(4+6w+4w*w)cube - (2+4w+2w*w)square = ? where w is the complex root of unity</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">5) A contractor have to finish a road in 200.He employed 140 worker for 60 days and gets one-fourth of work done .find the<span style=""> </span>addition number of worker is to be employed to complete the work in given </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">time. ans ) 120 worker (check)</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">6)there are two pipe ,one fill the tank in 12 hours and other<span style=""> </span>fill in 32 hours .After how long the first pipe is to be closed so as<span style=""> </span>to fill the tank in 16 hours. <o:p></o:p></span></tt></p> <p class="MsoNormal" style="margin-left: 0.25in;"><tt><span style="font-size: 10pt;">7)A sphere is 3cm in radius .It was melted in three sphere out of<span style=""> </span>which one is 1.5 cm radius and other is 2 cm radius .Find the radius<span style=""> </span>of third sphere </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">8)A refrigator has dimension 6 x 8 x 2 cmcube.how many cube of 2cm square can be put into it.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">9)In a equilateral triangle the mid point of its side is<span style=""> </span>connected and the process was repeated one more time .find the ratio of<span style=""> </span>inner triangle to the outermost triangle ans) 1: 16</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">10) A,B,C,D,E are in arithmatic progression.what is the value of 4A -6B +4C-.......+E. ans) zero</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">11) A train's to traverse between A &B. If it travels by 50Kmph it got<span style=""> </span>late by 10min If it travels by 36Kmph it got late by 50 min. Find out the speed of the train. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">12) I boy's to buy a bike whose cost is 75000. His fatherv gave him<span style=""> </span>1.5 times what he</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">can spend and his financial provider gave him 4 time of his father<span style=""> </span>contribution. Find out the Rs. given by his father.</span></tt><b><span style="font-size: 10pt;">
<br /></span></b><tt><b><span style="font-size: 10pt;">the topic given in GD was 1) iraq war 2) Role model ( ideal )<o:p></o:p></span></b></tt></p> <p class="MsoNormal"><span style="font-size: 10pt;"><span style=""> </span></span><tt><b><span style="font-size: 8pt;">GD TOPICS ASKED: LOVE MARRIGE VS ARRANGE MARRIGE, IRAQ WAR, kUINKI<span style=""> </span>SAAS BHI KABHI BAHU THI AND KHANI GHAR GHAR KI( TV SERIALS).</span></b></tt><tt><span style="font-size: 8pt;"> SEC-1</span></tt><span style="font-size: 8pt;">
<br /></span><tt><span style="font-size: 10pt;">1.IF rose code as 6786<span style=""> </span>hot coded as 879</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">then search will code as in this q there is one no. is assigned t each letter.so take search <span style=""> </span>and </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">letter by letter see the given condition.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">2.600,180,54........... complete the series.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">3.sedane:pain :: solace:........<span style=""> </span>ans: grief.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">4.play:director :: news<span style=""> </span>ans: editor.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">5.river:dam :: traffic<span style=""> </span>(a)signal (b)motin (c)vehicle (d)</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">6.find the greatest no. <span style=""> </span>(a)half 50%of 50 (b)3times 40%of 40<span style=""> </span>see the obtion & place 3times 40% of 40 blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">7.find the compound interest of 1000 rs. at the rate of 5% p.a. for<span style=""> </span>15 years.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">8.find the greatest of 1000power of 1000,1001power of 999</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">9.product of two no is constt. if one no. is increased by 50% then<span style=""> </span>other no is decreased how much.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">ans: 33.3</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">10.l.c.m & h.cf of two no is 84 & 21 respectively and the ratio of<span style=""> </span>these two no is 1:4 find the gretest no </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">ans: 84 place blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">11.if x is 90% of y then y is how much % of x. 12.the cost of 15 apples & 20 mangoes is much as equal to the 15<span style=""> </span>mangoes & 20 apple then what is the<span style=""> </span>relation between their cost.. (a)apple is as much equal as mangoes. place blindly (a) obtion.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">13.there r 20 men and 5 women then how much maximum couple can be<span style=""> </span>made.....</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">ans: 20c1*5c1=100. place 100 blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">14.a bag contains 8 white and 6 black balls find the prob. of drawing<span style=""> </span>a white ball....</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">ans: 4/7 place blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">15.if numerator is less than 2 by denominator and then if 1 is<span style=""> </span>subtract from the numerator<span style=""> </span>and 1 is added to the denominator then the ratio becomes half what is<span style=""> </span>the no.....<span style=""> </span>ans: 5/7 place blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">16.if a certain money becomes twice in 5 years.then the 300 rs. will<span style=""> </span>become 2400 at the same rate in how</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">many years........ <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">17.if the average of three numbers is 135.and the difference between<span style=""> </span>others is 25 then find the</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">lowest no. </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">18.if the thrice of three consecutive odd no is equal to the more<span style=""> </span>three of twice the last no.then </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">find the 3rd (largest odd no). ans: 11.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">19.there are 5 questions in each of the two section.three questions<span style=""> </span>must be attempt for passing the exam how many ways a student will choose the question ans: 100 place blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">20.if the lenght of the rectangle is decreased by 4 and breath is<span style=""> </span>increased by 3.then it becomes sqaure</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">whose areas is equal to that of rectangle.what is the perimeter of<span style=""> </span>the original rectangle.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">21.there is a hemisphere of radius of 2 cm how much litre will be occupied in the hemisphere.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">given 1 litre= 1000 cubic cm. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">22.there is a water tank which has enough water to be consumed in 60<span style=""> </span>days.if there is a leakage </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">water stays there for 40 days.if there are more similar leakage then<span style=""> </span>how lomg water will consumed. </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">23.a man saves money 1000 in each year.and he gives this amount at<span style=""> </span>the end of year for the compound interest at the rate of 5% how much he will save after 25 years. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">24.after giving 35.66% discount. a saler makes a loss of 11.11 rs. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">25 there is an intersection question cannot remember it but the<span style=""> </span>answer is b </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">26.the sides of a rectangle is 100 cm and 60 cm if there is a path of<span style=""> </span>5 cm around the rectanle.it is </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">included in that given rectangle.find the area of that path.......</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">27.there is a number when diveded by 5 gives a remainder 3 and when <span style=""> </span>divede by 7 gives a </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">remainder of 5 Ans is 33.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">Q28.a train when travelling from 2 station A and B when travelling a<span style=""> </span>speed of 50km/hr is late by 10min,</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">and when travelling at 30km/hr arrives a late by 50min. Find the<span style=""> </span>diatance.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">29.rational no. is a......... ans: real no. place blindly.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">30.a boat is going along the stream and returning in the opposite<span style=""> </span>direction of stream it travels </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">10 km along stream.the sppeed of stream is 3 km/hr,then find the<span style=""> </span>speed of boat.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">31.a boy leaves his home 15 minute before his shedule time. he takes 10 minutes to reach the bus stop.he arrive at the stop at<span style=""> </span>8:40 am when he leaves the home.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">32.A and B runing around a circle of perimeter of 1200meter(may be<span style=""> </span>differ).A is runing at 210 meter/minute and bB is running 190 metre/minute in oppsite direction to each other.at wich time they </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">will meet. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">33.a boy start to count from 32 in the descending order.and another<span style=""> </span>boy start counting from 1 at the </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">same time and he count only the odd no.then find which no they will count at the same time.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">there were 5 questions on syllogism. </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">if inference is true then A is right</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">if inference is false then B is right</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">if inference is probably true then c<span style=""> </span>otherwise D</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">34.all the wives are women<span style=""> </span>she is women.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">inference: she is wife </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">35.some of the teachers are fool.<span style=""> </span>A is a teacher.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">inference:<span style=""> </span>A is a fool.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">36.there is a ladder and 4 persons (A,B,C,D) on the ladder. A is<span style=""> </span>further up than B and C.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">D is further up than A.Which is third from the bottom of the ladder? <span style=""> </span>Ans: person A.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">37.A person goes to the house of Sita who is the neighbour of Gita.<span style=""> </span>Amar married with Anita who is the sister of Sita. Ashu is the father of Amar.(a) What is the relation between Sita<span style=""> </span>and Amar?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">(b) What is the relation between Amar <span style=""> </span>and Gita?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">38.In an elevator either 12 adults or 20 children can go. If 15<span style=""> </span>children already occupied the </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">space , how many adults can go with children? ans: 3</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">39.Amit's D.O.B. is 3rd March 1980. Amit is four day's older than<span style=""> </span>Sumit. The Republic Day of 1980</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">is Thrusday. What is the day of Sumit's D.O.B.?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">40.A complete a race of 120m taking 4sec less than B. B takes one sec<span style=""> </span>less than C. How much time</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">taken by A to complete the race?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">41.A person pointing towards a lady says She is the only sister of my<span style=""> </span>father. Find the no. of </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">childs of grandfather? ans: can't say</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">42.If GEN = 9 , ABOUT = 15 then GENERAL = ?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">43.If DUST is called AIR . AIR is called RAIN.RAIN is called WATER.<span style=""> </span>WATER is called COLOUR.</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">COLOUR is called ROAD. ROAD is called DUST. Where the Fish lives?</span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">44.A is richer than B. B is richer than C. C is richer than D. D is<span style=""> </span>richer than E. Then who is </span></tt><span style="font-size: 10pt;">
<br /></span><tt><span style="font-size: 10pt;">the middle of this relation. <o:p></o:p></span></tt></p> <p class="MsoNormal"><tt><span style="font-size: 10pt;">45.there is question to find the code of SEARCH the ans is c. There are 5 or 6 questions based on coding and decoding. </span></tt><span style="">
<br /></span><tt><span style="font-size: 10pt;">46.A to Z. First letter A is swapped with Z, second letter B with Y,<span style=""> </span>and so on. Which letter the</span></tt><span style="">
<br /></span><tt><span style="font-size: 10pt;">tenth from right.</span></tt><span style="">
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;">1)Compound Interest (3 or 4)<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;">2)Two taps are filling a tank and the third one is emptying it .. sort.<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;">3)Problems on trains<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;">Maybe RS AGarwal will help a lot.In aptitude there were problems on RELATIONS and on triangle area..Like<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;">One equilateral triangle is divide into say into 3 equilateral traingle.What is the area proportion of the outermost to the innermost?<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p style="margin: 5pt 0.5in;"><strong>Kanbay Exam conducted on 2nd Aug 2003.</strong><span style="color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">The Selection Process will have Written Test, GD & Interview. :<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><strong>GD : Y</strong><span style="color: black;">ou are each given a role to play..u have to justify why yours is best suited to the question and final reach a general consensus.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> Tps: Be cool...... Listen carefully..... n talk..talk what u want but do say something.. don't be too aggressive nor too submissive n yes..don't address any one member only.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-right: 0.5in; margin-left: 0.5in;"><strong>Interview:</strong><span style="color: black;"> They also ask puzzles like: <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3 switches in the bottom floor, 3 bulbs on top floor..u can go upstairs only once.find out which switch is for which bulb. then , out of a group of<span style=""> </span>10 matchboxes..each with 10 matchsticks of 10 gms. if one weighs 9 gms..how will u find it in minimum no. of weighings.. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Be confidant and preapre ques like why should we take u?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">what are ur assets, hobbies, the last book that read , the last film that u saw ..name of characters in that film etc..<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">********** </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">qstns<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">******<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> Few questions of KANBAY 2003,aug 1st,in KITS college Bhubaneswar<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">I am sending all those which I could remember,all were multiple choices..they said cut-off was 12 but it was actually 15 per section. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">It had two sections ,LOGIC AND MATHS,cut of in each secn 12,each had <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">30 questions,1 mark each<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">LOGIC<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1.problems on permutation combinations like BANANA,…..<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2.if april 18 was Wednesday in 1998,when is april 18 in 1999?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3.if B has its shadow falling on right side early morning ,then in <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">which direction is he facing?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4.age problems like…….<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Mothers age was twice the the age of son two years ago.after how many <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">years will she be three times her sons age??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5.analyzing data interpretations and around 4-5 questions based on <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">tat<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">6.a Guy has some chocolates with him he distributes them equally among 5 people and remaning with him is 3.if he distributes them equlay among 7 people remaining is 5 with him. Which of them isn't is possible no.of chocolates he had??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">53,208……….<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">7.4-5 problems on profit And loss </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">8.in a test moti,ganesh,manali,rupali,raj, appear,according to the scores moti is not the leats scorer but is lower to raj………….who <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">occupies the 2 nd postion is the order?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">9.mr a meets mrs b.mr b is has a son and daughter .son is moti and is married and has a son .mrs moti is mr a mother .how is mr a related to mr b??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">10.ram buys some dozens of apples and peaches .their price ratio is <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5:7.if the price of 1 dozen of peach is is rs 9,how many dozens of <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">apple did he bring?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">11.problems based on relationships like those in rs aggarwal<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">12.in a queue A is is in 7 th positon from the left and B is 9 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">position from the left .if they switch positions A is in 11 th <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">position ,find the total people in the row??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">MATHS<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1. S 1=={1,2,3,4}, S 2 =={A,B.C……….Z},S 3=={……………},(S1*S2)U S3==?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2. IF 5*4= ,8*7=B,how much is 6*9== ? </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3. 4 to 5 questions on simplifying complex nos. equations<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4. sphere of radius 4.5 cm is divide in three spheres ,two have <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">radius 1.5 and 2 cm,find the other ones??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5. if COMPLEX == 81,and……………….how much is ANALYSE==?? 2-3 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">questions based on similar pattern<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">6. two taps a and b fill up a cistern in 2 and3 hrs ,at wat time <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">should b be clsed if the tank cistern is filled up in 17 minutes??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">7. a doctor checks 5 patients every 3 hrs with abreak of 10 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">minutes between each two check ups.how many he patients he checks in <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">10 hrs and 15 minutes??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">8. no. of diagonals friends if vertices of a octagon are joined??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">9. an equilateral triangle is formed by joining the centers of <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">sides of a equilateral triangle.wat is the ratio of area ,s of both <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">the triangles??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">10. A can finish the work in 3 days , B can finish the work in <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">double efficiency,can finish with equal efficiency of both A and B.if <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">all work together within how many days will they complete the work?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">11. A.B,C,D stand at the edges of a square.they start moving <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">along the square sides.after clockwise rotation where will each be??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">12. if 1 is stop,2 is run,3 is go,4 is wait,5 is walk,then would <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">be the next stage if the following pattern<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5 5 4 3 2 1 ……………………..<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4 1 2 2 3 1 ? </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">13. C remembers meeting B after 14 but before 18 ,but D <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">remembers meeting B after 16 but before 18.when did both meet B??<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">14. avg age of boys in a class is 12.when the age of teacher is <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">included it is 13.wat could be the age of teacher?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">35 , 45,53,50<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">the 2nd set was repeated frm NIT jamshedpur.most of the ques are <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">repeated ..but there are some sets that are real tough...<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">written test is very simple filteration will be done in GD.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">written test consists of 2 sections(apptitude and logical reasoning) <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">of 30 quest. each and cut off is 12 each.and the total time is 1 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">hour. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1. which is greater (1000)pow1001 and 1001pow999<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2.one container contains milk and water in the ratio 3:7 and the <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">other contains 8:11,in what ratio these two containers is to be mixed <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">so that the ratio of milk and water is 4:5.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3. there are two simple problems on time and work.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4.four points will be given and you have to frame two st. line eq.s <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">in such a way that their point of interesection lies in one of the <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">four options.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5.there are two to three problems on profit and loss which are little <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">bit time taking ,so i didn't attempt.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">6.a series of nos will be given where the ans can be found by <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">observing the diff bet two consecutive nos<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">logical reasoning<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1. air is cloud<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>cloud is rain<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>rain is water<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>wateris sand<span style=""> </span>so what is cloud?<span style=""> </span>ans<span style=""> </span>:sand<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2. one quesion on relations<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3. trafic: signal<span style=""> </span>ans : river :dam<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4. two more quesions are there </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5. dsoighkl now if lk-(?)-sd<span style=""> </span>, find letter in 4th place<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">6. some mammals are donkeys<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>allbuffalos will have horns<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>based on this 3 quesions r ther<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">7. two more r simmilar to above<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">8. to decode the noise :-<span style=""> </span>H.................M<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>ANS:C<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">9.cube is of size 5*5*5 .every side has been coloured. it is divided<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">into 125 equal parts.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1) what is the no. of parts having only one side coloured - 54.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2) no. of parts having two sided coloured<span style=""> </span>36.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3) having no side coloured - 27.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">10.find the no. of occurrence of T which is immediately preceded y P<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">and no<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">timmediately followed by S in some series for eg. (TPTSTRUST.......)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>ans - 3<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">11.Four persons are there wearing different coloured shirts eg. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">A,B,C,D <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">wearing blue ,green, red, yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>Now, 1. A cannot wear yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span><span style=""> </span>2. B can wear blue or green.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>3. C /D is wearing yellow.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>You have to find who is wearing which coloured shirt.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">12.Find the root of 4a2+b2+c2+4ab-2bc-4ac<span style=""> </span>Ans: 2a+b-c.Two <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">pipes <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">can <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">fill a tank in 5 hrs and 8 hrs.<span style=""> </span>while a hole can empty it in 40 hrs. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">What <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">will be the time taken to fill if each operate at a time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>Soln:<span style=""> </span>1\x == 1\5 + 1\8 - 1\40<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">13.A can beat B by 20 mts. While C can beat B by 40 mts. In a race of <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">100 <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">mts. By how much can C beat A?<span style=""> </span>Soln: 75 mts.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">14.If u start your journey 30 minutes late , u have to increase your <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">speed <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">by<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">250kms\hr. to cover up 1500 kms. In same time.<span style=""> </span>What is your usual <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">speed?<span style=""> </span><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Ans: 750kms\hr.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">15.For a circle, radius is inc. by some % , find net change<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">in area? </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">these r some of the quesion me and my frends remember<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">note :<span style=""> </span>these r from 5 different sets<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">gd topics are<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>lov marriages r arranged marages<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>r tv serials helpful<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Total no. of sets<span style=""> </span>0716 , 0717<span style=""> </span>, 0718<span style=""> </span>out of which<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">0717 was<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Hard . I am sending the qus of 0717 . other section?s<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">qus . were not managed. Also other sections were easy<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">in comparison to 0717 .in my college most of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">students having 0717 set were not in the written test<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">. it was time taking .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">I don?t remember the logic qus.<span style=""> </span>For it go thru<span style=""> </span>the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">R.S. AGRAWAL .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Go thru<span style=""> </span>1>blood relation.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2>analogy.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3>coding ?decoding.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4> puzzles.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Qus related<span style=""> </span>to these topics were asked .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">I am sending you<span style=""> </span>few questions.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1)complete the series<span style=""> </span>600 ,180 ,54,<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">ans===.2( options were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2) some doctors are fool john<span style=""> </span>is a doctor<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">a> john is a fool.b>all<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">b><span style=""> </span>fools are doctors<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">from this you have to draw the conclusion given in the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">options such as only a is true only b is tru both are<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">tru or none is tru.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3> similar question like2 </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">some teacher are female.a is female.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">a>she is a teacher.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">b>all females are teacher.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4>river : dam<span style=""> </span>::<span style=""> </span>traffic:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">ans.==== signal<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">other qus related to analogy were there .go thru R.S.AGRAWAL.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">other<span style=""> </span>qus were from the lbood relations .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">some qus were from puzzles .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">a,b,c,d,e,f,g are 7 epople seating on a wall facing<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">towards north.b is not at the end.c and<span style=""> </span>d can not<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">seat together .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">qus like this were there .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">mathematical qus / aptitudes.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">1)a sum of money doubles in 5 years by simple interest<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">. how much time it will take for 300 to become 2400.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">a>40 years b>25 years<span style=""> </span>c>35 years<span style=""> </span>d> 20 years.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">2)if length of a rectangle is made 4 less and breadth<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">is increased by 3 then the resultant square ?s area is<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">equal to the rectangle. What is the perimeter of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">rectangle .( options were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">3)what will be the no. at ? position below<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>51<span style=""> </span>11<span style=""> </span>61<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>64<span style=""> </span>30<span style=""> </span>32 </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;"><span style=""> </span>35<span style=""> </span>?<span style=""> </span>43<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">4>the L.C.M. and<span style=""> </span>H.C.F. of two nos. are 84 and 21<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">and the nos. are in the ratio of 1:4 ,. Find the nos.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">ans====<span style=""> </span>21, 84<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5)find the volume of the hemisphere having radius 2m .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">6>problem based on compound interest were asked . so<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">see the formula of compound interest.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">7)a train goes from a to b. if it travels with 50 km/s<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">then it is late by 10 mins. When it travels with30km/s<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">then it bis late by<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">50 mins. Fi nd the distance between a and b.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">8)a river is 8 m deep and 150 m wide.river?s speed is<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">5 km/s.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">find the volume of water passed in one min.(1 m cube =1000 c.c.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">9) fin dthe equation of the st. line passing thru the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">intersection of<span style=""> </span>the two lines<span style=""> </span>and two other<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">lines.(equ.<span style=""> </span>Were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">10) a man sells 20 mangoes + 15 oranges<span style=""> </span>ath the same<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">price as 15 mangoes+20 oranges. Ho would judge<span style=""> </span>which<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">is costlier .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">( four options were given . I didn?t remember those)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">11) a graph was given representing joint venture in<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">the years.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">An dquestion related to the graph were asked such as<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">A)in which year there was max. change.(ans. Was in the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">last year) </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-right: 0.5in; margin-left: 0.5in;"><span style="color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">Two other qus were asked.they were long so I don?t<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">remember them .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">12)A is counting the no from 1 to 32 and b from 32 .A<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">is counting the odd no. only .both?s speed is same.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">What will be the number which will be pronounced by A<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">&<span style=""> </span>B<span style=""> </span>together.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">( ans .<span style=""> </span>aws<span style=""> </span>none of these )but confirm yourself .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">13) in the word ?DISTURBANCE?<span style=""> </span>1st<span style=""> </span>is replaced by<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">last 2nd<span style=""> </span>is replced by 10th , 3rd is<span style=""> </span>by 9th<span style=""> </span>and so<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">on. Which will be the next to<span style=""> </span>?T?.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">14)GIVEN<span style=""> </span>if x/y==3/5. if 1 is added to num . and 1 is<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">subtracted from denominator then ratio ==5/7. find the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">number.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">15)there are 5 black and 9 white balls .if one ball is<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">drawn then find the probability of being white.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">16)Avg. age of 5 children =.a child of 5 year age<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">dies.after 4 years what will be the avg. age.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">17)three nos. are given<span style=""> </span>the product of<span style=""> </span>first and<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">last is equal to the square<span style=""> </span>of the middle. Find the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">nos.(options were given)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">(ans.== 10, 20, 40) </span><span style="font-size: 7.5pt; color: black;">freshersworld.com</span><span style="color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-right: 0.5in; margin-left: 0.5in;"><span style="color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">18) a rectangle was having<span style=""> </span>length 100 m<span style=""> </span>breadth<span style=""> </span>60<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">m. there is a road of 5m wide on each side of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">rectangle . find the area of the road.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">19) fir no. is<span style=""> </span>the<span style=""> </span>double of 2nd and ½ of the 3rd .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">other statement was also given which I don?t<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">rememeber.(ans=H,24,96)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">20) a girl cuts a cake in two<span style=""> </span>halevs. One half is<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">again<span style=""> </span>cut into six<span style=""> </span>equal parts . wt. Of the smaller<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">one was 20 gms. Fin the wt. Of the whole cake.(ans=240gms.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">21)other question was based on the relative speed in<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">the river .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">i.e. a person first goes upstream then down stream .<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">river?s speed was<span style=""> </span>given .also the diff. Of time was<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">given . find the speed<span style=""> </span>of the man.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">22) ravana speed is 5000 km/s when going towards the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">heaven.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">The distance == 75000. ravana has traveled<span style=""> </span>2<span style=""> </span>mins.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">When god?s messenger reaches the earth . Rama told him<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">to go back. The speed of the god?s messenger =`00<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">km/s.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">By how much he will increase or decrease his speed so<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">that he and Ravana reaches exactly at the same time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">23) a man sells a product by giving 10% reduction<span style=""> </span>on<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">it .in spite of this he gets 10% profit . on<span style=""> </span>a<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">product of 330 rs. Original price What will be the<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0.5in 0.0001pt;"><span style="color: black;">buying price.<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt;"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-52210306855832982852008-10-22T22:30:00.000-07:002008-12-23T04:01:37.822-08:00Essay<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>ZH-MO</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Cite"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} pre {mso-style-noshow:yes; mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-fareast-language:EN-US;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-noshow:yes; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><pre><span style="font-family: "Arial","sans-serif"; color: black;">Essay - 15 mins<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"> How to improve IT business in India<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">OR<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Deforestation is not an issue we can live in concrete jungles<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q1) 3 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">A tank has two inlets and one out let. one inlet can fill the tank in 8 hours,<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">another inlet can fill the tank in 6 hours. The outlet can empty the tank in 10 hours.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">If all the taps are working together in 1.68 what fraction of the tank will be filled<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q2) 5 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Tom, Dick and harry are walking to-gether. Tom always tell truth, dick tells truth only sometimes,<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">harry tell lie always. Dick says "He is harry". Harry the person in the middle is "Tom".<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Identify the postion of each person.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q3) 8 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">A jeweller has two glass cases for displaying the jewels left case and right case.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">He has always display 6 of 8 jewels Alchemist, Diamond, garnet, sapphire, ruby, pearl, gold and emerald,<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">3 in each<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">1. Alchemist must always be displayed in the Left case<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">2. Diamond must always be displayed in the right case<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">3. emerald and sapphire should be displayed together<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">4. If ruby, then diamondis not displayed together.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">5. If garnet then pearl is not displayed together.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">1. Which of the following combination is correct in the left case<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">a) Alchemist, diamond, ruby<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">b)alchemist, garnet, emerald<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">2. Which of the following combination is correct in the left case<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">a)diamond, ruby, pearl<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">b)alchemist, garnet, pearl<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q4) 5 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">A person wants to travel from A to B a distance of 189 kms.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">He can take either the train or coach. He decides to take the coach.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Both the train and coach leave the together. They meet at a point.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">The time taken for the person to travel is equal to more distance covered by<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">him combined for the entire distance. Find the time taken by the Person.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q5)8 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sally and sue want to date joe.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sally asks joes "Your house number is a square"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Joe answers "Yes"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sally asks joes "Your house number is greater than 50"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Joe answers "No"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sally thinks that she has got the number<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sue asks joes "Your house number is a cube"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Joe answers "Yes"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sue asks joes "Your house number is greater than 25"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Joe answers "No"<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Sue thinks that she has got the number<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Both sally and sue reach the wrong house. <o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">If joe had anwered the sally's first question wrong<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">and sue second question wrong and if the joe's house number <o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">is square of the sallys and sue number.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">1. What is sallys guess<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">2. What is sues guess<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q6)8 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Bill, smith, conners, william are the First names.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Conners, joe, jack, ted are the last names not in the correct order.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">They play a game of cards with following rules<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">First winner will get 10$ from each.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Second winner will get 20$ from each.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Third winner will get 30$ from each.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Fourth winner will get 40$ from each.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">After four turns each one is a winner.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Bill is the first winner, williams is the last winner.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">If smith had more money in the first round and jack had more money in the last round.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Match their first and Last Names.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Q7) 8 - Marks<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">There are 6 towns A, B, C, D, E, F, G.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Town A and B are in the same longitude.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Towns D, E are in the same latitude.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">E,F are industrail towns. Industrial towns cannot be harbours.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">C,G are the harbours<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">The temperature in the harbour is always 10 degrees less than other towns.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">The temperature in the longitude is alway higher than that in the latitude by<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">16 degress. The temperature in the harbour is less than the industrail towns<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">The temperature in harbour is 20 degrees.<o:p></o:p></span></pre><pre><span style="font-family: "Arial","sans-serif"; color: black;">Find the temperatures of all towns.<o:p></o:p></span></pre>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-86460500559105144002008-08-06T09:08:00.000-07:002008-12-23T04:01:37.822-08:00INTERVIEWSWhat is the purpose of Interview?<br />An interview will enable an employer:<br />to check that you have the required skills and knowledge for the job<br />to ensure that you are clear about what the job involves and that you know what will be required of you<br />to make sure you know about and are committed to the company, and that you genuinely want to work for them. <br /><br />Know Yourself <br /><br />Imaging <br /> Imaging is the most important philosophical aspect for any success. Let me explain imaging with an example.<br /> Do you think whenever Sachin scores a century it is only due to his game on the field? No! There is something which is responsible for it which is off the field.<br /> One day prior to the match Sachin imagines, sitting alone. He imagines: “Tomorrow I get up at 6 ‘O Clock. I will warm myself up for an hour, have break fast, take out my kit and go to the ground at 9 ‘O Clock. At 9:30 Dravid will go for toss, he wins it and selects fielding. I will stand at covers and field every ball that comes to me. Agarkar and Irfan ball tidy spells. I will take a flying catch, etc. In spite of that, Smith scores 140 runs, and the team score 359 runs.<br />Imaging <br />“I will open our batting. Initially I will take singles Then I will charge Nel. I score 50 in 15 overs. I will never go for paddle sweep, as there will be bounce for spinners. I will play aggressively. We will win and I will get man of the match award”<br />Then next day Sachin will just repeat his images. This is called imaging techniques. Every successful person uses this. If you use this technique your confidence grows exponentially.<br /><br />So before you go to bed, lie down and start imaging in your mind. You go to the place, write test well, get short listed, give interview well, results announced, you are selected. <br /><br /> More the depth you imagine more the success rate grows.<br /><br />I recommend you to pray and ask the God to make you successful. Please sleep for at least 6 hours<br />Items to take to Interview<br />A summary of the research you have done on the company.<br />A list of questions you have prepared to ask the interviewer.<br />A notepad and writing tool to take notes with and write down questions.<br />Any additional materials you may need to present to the interviewer such as reference lists, personal identification pieces, certificates, transcripts or letters of recommendation.<br />A quick snack that will keep you from getting hungry in the event of a long interview.<br />Finally be sure that you turned off your mobile phones.<br /><br />Success Formula for interview<br />The two things that make you succeed in the interview are preparation and confidence.<br />Preparation + Confidence = Success -------------- (1)<br />After good preparation confidence comes automatically which makes you perform well. <br />So confidence ~ Preparation<br /> So from--- (1)<br />Preparation + Preparation = Success <br />? Preparation = Success <br /> 2<br />This implies that if you prepare well, you are already half succeeded.<br /><br />What employer expects from you?<br />Leadership - demonstrates effective leadership and motivates and inspires others to perform well<br />Teamwork - works effectively as part of a team<br />Motivation - demonstrates a personal drive to achieve, even in uncomfortable situations<br />Brainpower - ability to analyse and manage information, to identify key issues<br />Lateral thinking - thinks “outside the box” to come up with imaginative solutions<br /><br /><br /> Perform in the interview <br />UNDERSTAND HOW THE INTERVIEW WORKS<br />The interview can be divided into 3 parts<br />There is an opening period of a few minutes where the scene is being set and first impressions are being formed<br />A middle period in which the conversation will embrace the organization, the job itself and you and your potential fit. This is where you will be asked many questions.<br />The closing period-again a few minutes- will be an opportunity for the interviewer to summarize and to indicate the process from here. You will also be able to ask questions here if you haven’t had a prior opportunity to do so.<br />Exhibit only the required skills<br />Don’t Lie<br /><br />Watch your body language!<br />Give a firm, dry handshake<br />Make eye contact with all members of the panel<br />Smile to show your interest and enthusiasm<br />Avoid extravagant hand gestures<br />Sit slightly forward to indicate involvement<br /><br />Body Language: What signals are you sending?<br />Positive Signals<br />Leaning forward = interest<br />Smiling = friendly<br />Nodding = attentive and alert<br />Eye contact = curious and focused<br />Negative Signals<br />Crossed arms = defensive<br />Fidgeting hands or tapping feet = nervous or bored<br />Lack of eye contact = untrustworthy<br />Leaning back= discomfort<br /><br />TECHNICAL INTERVIEW<br />PREPARING FOR TECHNICAL INTERVIEW<br />In the early years of engineering, students think that in interviews, hi-fi technology is asked which is very complex and difficult. <br /> So they don’t think of learning or refreshing the technical concepts keeping interview in mind.<br />But the companies ask those technical questions which we have learnt like, what is amplifier, counter, XOR GATE, what is microprocessor, what is signal, what are pointers, data structures, what is linking, what are motors, gears etc., depending on your branch and your skill set that you have mentioned in your resume.<br />PREPARING FOR TECHNICAL INTERVIEW<br />When you apply, you look at the pattern of interview, the area of work of the company. You can get to know on what subjects they would ask questions in interview. You can study those two, three subjects in depth. You also have to just touch all the subjects especially electives.<br />For software companies, prepare the languages you know like C, C++, Java, etc..<br />TECHNICAL INTERVIEW<br /><br />Keep all your certificates, mark cards and resume in a file and carry your project reports to the interview. <br /><br />At the interview centre meet the people who have finished their interview, and ask them what they were asked in the interview. Around 50% of the technical questions that were asked to them will be asked to you. So get to know the answers of those questions. <br />TECHNICAL INTERVIEW<br /> Enter the interview room with a smile saying ‘may I come in sir?’ go near the chair and shake hands with the interviewer firmly. Generally oldies don’t shake hand and young interviewers prefer doing it. <br />Sit only after they ask you to sit. Sit straight and make comfortable posture with legs open (don’t cross them). <br />Give a fresh, eager, alert smiling look. Technical interviewers may not ask HR questions, but to start with, they ask ‘ tell about yourself’, you can tell about yourself in brief. c<br />TECHNICAL INTERVIEW<br />Then they may ask ‘what are your favorite subjects?’ Name at least 2 to 3 subjects which you have studied in depth. <br /><br />The questions asked will only be on basics of these subjects.<br /> They will surely ask questions about the projects you have done and electives you have mentioned in your Resume.<br />Prepare in depth about your projects, papers and Area of Interest. Specifically your core.<br />They will ask why you chose this branch.<br />TECHNICAL INTERVIEW<br /> The questions just look simple. <br /><br />They may grill you if your answers don’t look confident or if you try to bluff.<br /><br /> If you don’t know, you can say ‘sir we don’t have that in our syllabus’ or ‘sir I am not remembering it’ or ‘I don’t know sir’.<br /><br />When they ask about projects you can spent more time on them, as you will be more comfortable with the projects you have done. <br />TECHNICAL INTERVIEW<br />Non-CS students who apply for software companies, should say, they at least know one programming language, generally C; and should be prepared to face questions like what are strings, pointers, header files or simple ‘for loop’ usage programs.<br /><br />Speak clearly and convince your answers to them. Don’t rush at your answers and end up stammering, getting confused. Speak slowly and steadily; such are the guys who impress more. <br /><br />HR INTERVIEW<br />There are many questions that HR managers from different companies ask. Let me list some of the questions and answers in a format, which I think, can be better ones. <br /><br />There can be hundreds of good answers, which can be given, based on your views, thoughts, personality, goals, expectations and finally the mood. <br />Prepare for the HR questions like<br />Self description<br />Family background<br />Asked to know the social, cultural and economic background of your family.<br />Besides describing the family bkgnd, mention basic ethos and good principless which have been imbibed in you by your family environment.<br />Strength and weakness<br />How much you know about yourself<br />Success and failures<br />This job is not a bed of roses………….<br /><br />HR INTERVIEW FAQ’S<br />First thing in your HR interview will be Introduce yourself – prepare and present it well.<br />How was your written test?<br />Why do you want to work in a software company?<br />After scoring good marks in HSC why did you score less in engineering?<br />Why do you want to join our company?<br />What are your strengths or why should we hire you only?<br />What weakness do you have?<br />Who is your role model?<br />Your Hobbies? <br />Where do you see yourself in 5 years time?<br />How would your friends describe you in 3 words?<br /><br /><br />HR INTERVIEW some unexpected questions<br />Consider yourself as C. E. O., what do you do for growth of the company?<br />How can you improve employee relationships in the company?<br />You said you are innovative; you better suit to join a product company rather than our services company.<br />You being weak in communicating skills do you expect you will get the job?<br />What has been your biggest achievement to date?<br />HR INTERVIEW<br /> Back to imaging again. The day prior to the interview you sit alone and rehearse the interview.<br /> It’s like taking your interview by yourself.<br /> Ask HR questions to yourself and answer them loudly as you do in an interview.<br /> You can anticipate even technical questions and rehearse. <br />Do you have any questions?<br />What would my career prospects be like? <br />What training/support could I expect?<br />What would the key objectives be in the first 6 months of the job? <br />How will my performance be measured? <br /><br /><br />However….<br />Do not ask questions just for the sake of it<br />Do not ask questions if you should already know the answer e.g. if it is in the company literature<br />Do not ask about fringe benefits – that conversation can take place when you have been offered the job<br />And remember….it may be that all your questions have been answered over the course of the interview<br /><br /><br />SUMMARY<br /><br /><br />Establish a connection by relating to each interviewer. Note the wording that is used by each interviewer and when appropriate use similar words. Maintain eye contact with each of the interviewers throughout the interview. <br />7. Sit comfortably and erectly, but don’t sit stiffly, slouching or sprawled over the chair. <br />8. Project confidence and a positive attitude. Maintain awareness of your voice, posture, energy level, and enthusiasm. Make hand gestures to emphasize important points, but avoid distracting gestures or making too many hand gestures. <br /><br /><br /><br /><br />Be attentive. Listen to each question carefully and don’t interrupt. If you aren't sure of what is being asked, politely request that the question be repeated. <br /> Close the interview with a strong closing statement of your qualifications for the job. <br /> Thank the interviewers. Shake their hands individually and thank each interviewer by name.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-6045584279386201152008-08-06T09:07:00.000-07:002008-12-23T04:01:37.822-08:00GROUP DISCUSSIONWhy do we have group discussion? <br />Group discussion allows you to exchange information and ideas and gives you the experience of working in a team.<br /> In the work place, discussions enable management to draw on the ideas and expertise of staff, and to acknowledge the staff as valued members of a team. <br />PURPOSE OF G.D. IN RECRUITMENT<br />G.D. is to check<br />How you behave, participate and contribute in a group.<br />How much importance do you give to the group objective as well as your own.<br />How well do you listen to viewpoints of others.<br />How open minded are you in accepting views contrary to your own.<br />What is group discussion?<br />A topic is given and 8 to 10 of you are allowed to speak on the subject for around 10 minutes. <br />How they evaluate?<br />Personality<br />Knowledge<br />Communication skills<br />Leadership traits <br />Personality <br />DRESS<br />The clothes need not be costly, dazzling or of latest fashion; they should be clean, neat and well stitched.<br />It improves confidence<br />Don’t try new<br />Polished footwear<br />Body language<br />Your movements and posture must be active, positive, alive and responsive enough to make the group and the examiner take to you immediately.<br />It gives signal to a person’s frame of mind.<br />Postures are said to divulge what is on one’s mind<br />Tone and voice<br />More than words, it is the tone that conveys the message<br />News reading<br />A tone that orders or commands, hurts the listener’s ego and self esteem.<br />Cultivate a voice that is lively and cheerful and conveys a request.<br />Countenance <br />A cheerful countenance is most important for a good appearance.<br />A ready, pleasant and spontaneous smile invariably conveys friendliness and creates a favourable impression. <br />Self confidence, optimism and amicability automatically create cheerfulness and bring happy smile to the face. <br />Manners <br />It is one’s manners that leave a lasting impression on others.<br />There are people who stand out not for their intellectual abilities but for their good manners. <br />A courteous, helpful, polite and interested person automatically draws people to himself.<br />KNOWLEDGE<br />In a GD knowledge of the subject concerned, backed by common sense will help you deal with any situation and win laurels.<br />The greater your knowledge of subjects, the more interested, enthusiastic and confident will you be and the more fluent and forceful would be your speech and contribution.<br />Books, perodicals, daily newspaper<br />Besides reading, a great deal can be learnt from the talks by and speeches of experts.<br />COMMUNICATION SKILL<br />An idea can be appreciated only when it is expressed powerfully and effectively.<br />Shakespeare’s Mark Antony could transform a hostile mob into a quiescent crowd with his words<br />British PM Winston Churchill inspired his country with his oratorical skills to continue their fight during the darkest hours of the II world war. <br />Gandhi, Nehru,…….<br />Effective communication is not an inborn triat; it can be learnt and mastered.<br />ROLE PLAYERS<br />INITIATOR<br />INFORMER<br />ILLUSTRATOR<br />COORDINATOR<br />ORIENTER<br />Negative Roles to be Avoided <br />DISGRUNTLED NON-PARTICIPANT:<br />ATTACKER<br />DOMINATOR<br />CLOWN<br />How do you face it? <br />Usually the topic is debatable, so one needs to quickly decide whether you are far or against the given topic. <br />I suggest, try to be different in your choice among the group.<br />You are given some 2 minutes time to make points about the subject. <br />If you initiate, you will get the advantage, but don’t initiate without ideas. It’s better to speak after two to three have spoken.<br />Be cool and look fresh.<br /> <br />How do you face it?<br />Don’t look at the judges<br />Speak clearly and loudly facing all. Try to anchor the group, not dominate it <br />Clearly explain your ideas with few weighted words. Don’t speak too much of nonsense.<br />Don’t murmur or stammer.<br />Don’t criticize others.<br />Always look at the person who is speaking and nod your head so that judges will see that you are listening.<br /><br /><br />How do you face it?<br /><br />If somebody is speaking more, you can say ‘you have spoken enough, let’s give chance to this person’ or ‘I agree with him’ or ‘you are going out of topic, let’s stick to the topic’<br /> Speak around 2-3 times. I mean don’t speak just once for 2 long minutes and keep quite for rest of the time, so try to speak in bursts. If somebody is listening to the discussion from outside, he should see that you are alive inside.<br />Try to conclude yourself (if they ask to)<br />One can practice mock GD with their friends to become familiarize with it. “We the people” and “The Big Fight” in NDTV had inspired me.<br />What is Brainstorming?<br /> Brainstorming is an excellent way of developing many creative solutions to a problem.<br /> It works by focusing on a problem, and then coming up with very many radical solutions to it.<br /> Ideas should deliberately be as broad and odd as possible, and should be developed as fast as possible.<br /> Brainstorming is a lateral thinking process <br /> It is designed to help you break out of your thinking patterns into new ways of looking at things.<br /> During brainstorming sessions there should be no criticism of ideas. <br />Group Brainstorming<br />Group brainstorming can be very effective as it uses the experience and creativity of all members of the group.<br /> When individual members reach their limit on an idea, another member's creativity and experience can take the idea to the next stage.<br /> Therefore, group brainstorming tends to develop ideas in more depth than individual brainstorming. <br />POSITIVE TRAITS<br />NEGATIVE TRAITS<br />Summary<br />Be assertive <br />A patient listener<br />Right language<br />Be analytical and fact-oriented<br />Maximize participation<br />Respect other speakers<br />Show leadership abilities <br />Be precise<br />Accept criticism ( thank if criticized on right thing)Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-51771206878852556052008-08-02T07:09:00.000-07:002008-12-23T04:01:37.822-08:00Freshers Aproach - Complete questions and answers1. GENERAL FAQ<br />2.<br />1.1 How is the IT field?<br />""Market is good or bad, we should get a good job"". Always fresher should keep this<br />mentality. Market is really very good. We need not worry about market status. Keep on trying till you get a good job. Do fight with your job hunting. Surely you will win.<br /><br />1.2 Do we need to study any mainframe/ testing/ .NET, etc?<br />For fresher, absolutely no need for computer courses. Aptitude, C, C++ is enough to get a<br />good job and there is no need of practical knowledge. A good guidance is hundred times better than a computer course.<br />If you got degree before 2004 and not strong in any of the software language, better join<br />some computer courses like testing/ mainframe/ .NET, prepare a fake a resume with one year<br />experience and do apply regularly. In the interview, many times they don’t ask about your experience. Your technical knowledge and way to explain the project is enough to get a job.<br /><br />1.3 How to get call letters from companies?<br /><br />Create one Yahoo ID and register it in to the following yahoo groups.<br />nestjobs (nestjobs-subscribe@yahoogroups.com), chetana, freshers<br />You use to get at least 100 mails daily regarding recruitment. Don't use your personal id,<br />create a new one. One more point, Every Wednesday, follow "Economic Times or Times of India"(Bangalore openings) and "The Hindu"(Chennai openings) without fail. There you can find more opportunities Try to get past one year Economic Times and Hindu papers from library. Collect all the jobs related ids.(including experience also.)<br />Apply to all the ids. You will be regularly getting interview calls from companies.<br />Visit these blogs : http://latestjobopening.blogspot.com/<br /> http://jobcollector.blogspot.com/<br /><br /><br /><br />1.4 How do we prepare resume?<br />Freshers: Companies like Infosys, TCS and Wipro expects your percentage from 10th<br />onwards, so it is better include all your curriculum (10th, 12th, all Degree) percentage in your resume.<br /><br />Resumes should be scanable it should be simple and easy to get information within a single look. It should not contain unwanted information.<br />Experience: You resume should have the following details, apart from the basic details.<br />1. Company name<br />2. Project name<br />3. Project duration<br />4. Client<br />5. Team size<br />6. Role<br />7. Project description<br />8. Activities (We have to mention our project activities)<br />9. Platform<br />You can get sample resume formats from section 6 of this document.<br /><br />1.5 How do we apply?<br />If you get any openings specific to your skill set, follow as indicted in the advertisement.<br />If you are applying for multiple companies, without advertisements or for positions not<br />specific to your skill sets,<br />1. Prepare a generalized cover letter, ascii format resume(plain text format resume) and<br />Word format resume<br />2. Paste your covering letter followed by the plaintext resume in the compose box of your<br />mail<br />3. Attach your word format resume.<br />4. Subject should be like, “Resume for Software Engineer (C, C++, JAVA and VC++)”<br />5. Type your id in “TO’ field and bulk of ids in “BCC” field, do apply.<br /><br />1.6 How do we receive job mails?<br />Visit - http://latestjobopening.blogspot.com/<br /> http://jobcollector.blogspot.com/<br /><br />1.7 Where do we get company model question papers?<br />If you get a call letter for written test, from any companies then go to the following sites...<br />http://allplacementpaper.blogspot.com/<br /><br />Collect the previous question papers and prepare well. Never miss to go to that site before<br />you go for Interview/Test. There may be a chance to get the same question papers.<br /><br />1.8 What are the books we have to prepare before we go for test/ interview?<br />Aptitude:<br />Arithmetic Reasoning - R.S.Agarwal<br />Barron’s GRE Guide.<br />Shakuntala Devi, George summer puzzle books<br />Technical Books:<br />For freshers, C and C++ is enough to get a job.<br />Let us C, C++, Exploring C - YASHAVANT P. KANETKAR<br />Turbo C++ - Robert lafore (A very good guide to get basic idea about C++ and OOPS)<br />Complete Reference – C, C++<br /><br />1.9 Where do we get the details about companies and details?<br />http://all-faqs.blogspot.com/<br />1.10 Am I suitable for IT field?<br />Anyone who has completed a graduation from an affiliated university is suitable for IT field.<br />IT field does not expect any specialization from your graduation but it expect good problem solving,<br />logical thinking and good communication skills. This can be achieved along with your curriculum<br />subjects by spending an hour per day. R.S. Agarwal is good subject oriented book for preparing<br />aptitude. Any MBA entrance book is suitable to prepare logical reasoning etc. In fact anyone who is not technically strong but having logical thinking skills is very much suitable for this field. It does not mean that technical people are not suitable.<br /><br />1.11 Employee reference for MNC’s<br />If anyone need reference to attend written test or interview or forwarding resume kindly<br />contact any of our career guidance team members. Our career guidance team maintains the spool of reference and provides you when the need arises.<br /><br />2. COMPANY TEST PATTERNS<br />2.1 How to prepare for Infosys?<br />There is nothing to worry about the Infosys written test. It is easy if you keep your mind cool.<br />There will be 10 questions in aptitude test, each of different marks & without multiple choices.<br />Duration is 1 hr & you have to get at least 7-8 correct to get short-listed. You had to put down the<br /><br /><br />procedure also in the paper. These puzzles are similar to the one in Shakuntala & George Summers. Attempt all questions, as there is no negative marking. No problem if we guess also. Mostly there will be questions on time & distance, probability, puzzles (George Summers), watch questions (related to time), escalator problem, completion of series & profit-loss questions.<br />Verbal is very easy. There will be 45 multiple-choice questions to be answered in 30 min.<br />Attempt all questions. Mostly there will be completion of sentences (20 Q), correction of sentences (10Q) reading comprehension (5Q), synonyms & antonyms (10Q).<br />Short listing is mainly based on aptitude not on verbal. Concentrate more on aptitude. We<br />can do very silly mistakes there. So be cool.<br />Regarding interview, firstly it’s not a technical interview. It is purely HR. It will be around<br />20-30 min. They will even ask 2-3 puzzles. They are easy. If we don’t answer any of them also there is no problem. You should be confident whether it is right or wrong. If you are through the written test then you will be almost through the interview. They almost select everyone in the interview. So concentrate more on the written test.<br /><br />2.2 How to prepare for TCS?<br />There were 3 main sections verbal, aptitude and reasoning. Generally any company will not<br />change the question paper for a year. So, you people can give importance to 2004 Question Papers. You can collect the sample QP from the about websites. We can see QP from 1995 onwards . Preparing all those papers is enough to get placement. There will be section cut off. Aptitude any one can clear. But In verbal section only we can beat others.<br />Don’t miss to prepare all the verbal section from 1995 onwards. The choices given to<br />synonym and antonym part will be changed. But the question may be the same one. So, Open "MS WORD" and collect synonym and antonyms for all the words found in all the QP.<br /><br />Regarding interview:<br />They check only the confidential level of the candidate. They never expect you to answer for<br />each and every question. All they need to check is how bold you are, how much confidence you have on you. always don’t expect questions from Areas of Interest. Always have a pleasant smile in your face and keep yourself very cool. That is more important than anything. They may sometime ask very basic questions like what is the version of WINDOWS you have worked on? But answers for them are very much important. For non-computer students the interview will be very simple. They need not worry that they don’t know much technically.<br />Then HR interview, you should be very careful here. They may ask very tricky questions.<br />Think twice before answering to these questions. The general questions in HR interview will be, why do you want to join TCS? What do you want to become after 3 years? Why TCS should take you in?<br /><br />Be confident and be cool, which is enough to clear TCS interview.<br /><br /><br /><br />3. USEFUL WEBSITES<br />3.1 Company question paper sites<br />http://allplacementpaper.blogspot.com/<br /><br />3.2 Technical document sites<br /><br />Source Code http://examplesourcecode.blogspot.com/<br /><br />C Programming http://cprogrammings.blogspot.com/<br /><br />SQL Server Interview Questions with answers http://sqlserverfaqs.blogspot.com/<br /><br />Oracle Interview Questions and Answers http://oracleiqs.blogspot.com/<br /><br />Quality Analysis and Testing ,WinRunner ,Load Runner Interview Questions and Answers http://qualityanalysisfaqs.blogspot.com/<br /><br />All companies placement papers for past 10 years http://allplacementpaper.blogspot.com/<br /><br />All fresher’s resources http://allfreshers.blogspot.com/<br /><br /><br />Interview Puzzles with answers http://puzzleszone.blogspot.com/<br /><br /><br />.Net Interview Questions and Answers http://dotnetframeworkfaq.blogspot.com/<br /><br /><br />C#.Net Interview Questions and Answers http://microsoftcsharp.blogspot.com/<br /><br /><br />ASP.Net Interview Questions and Answers http://www.aspfaqs.blogspot.com/<br /><br /><br />ADO.Net Interview Questions and Answers http://www.adofaqs.blogspot.com/<br /><br /><br />VB.Net Interview Questions and Answers http://www.vbfaqs.blogspot.com/<br /><br /><br />Data structures and algorithms Interview Questions and Answers http://datastructurefaqs.blogspot.com/<br /><br /><br />Quick Test Professional Interview Questions and Answers http://qtpfaqs.blogspot.com/<br /><br /><br />WCF- WPF .Net 3.0 Interview Questions and Answers http://wpf-wcffaq.blogspot.com/<br /><br /><br />Java Interview Questions and Answers http://javaqanda.blogspot.com<br /><br /><br />SAP Interview Questions and Answers http://sapque.blogspot.com/<br /><br /><br />Mainframes Interview Questions and Answers http://mainframesfaqs.blogspot.com/<br /><br /><br />Perl, shell, vb, java, scripts Interview Questions and Answers http://scriptingfaqs.blogspot.com/<br /><br /><br />VC++ Interview Questions and Answers http://vcprofessional.blogspot.com/<br /><br /><br />VC++ and MicroSoft Technologies Job postings http://latestjobopening.blogspot.com/<br /><br /><br />Job postings from Naukri, monster http://jobcollector.blogspot.com/<br /><br /><br />Guide for Finance, investments, loans http://wise-finance.blogspot.com/<br /><br /><br />General Guides http://feedlines.blogspot.com/<br /><br /><br /><br /><br />3.3 Puzzle sites<br />http://puzzleszone.blogspot.com/<br /><br />5. INTERVIEW TIPS<br /><br />5.1 Common interview questions<br />1. Tell me about yourself<br />The most often asked question in interviews. You need to have a short statement prepared in<br />your mind. Be careful that it does not sound rehearsed. Limit it to work-related items unless<br />instructed otherwise. Talk about things you have done and jobs you have held that relate to the<br />position you are interviewing for. Start with the item farthest back and work up to the present.<br /><br />2. Why did you leave your last job?<br />Stay positive regardless of the circumstances. Never refer to a major problem with<br />management and never speak ill of supervisors, co-workers or the organization. I f you do, you will be the one looking bad. Keep smiling and talk about leaving for a positive reason such as an<br />opportunity, a chance to do something special or other forward-looking reasons.<br /><br />3. What experience do you have in this field?<br />Speak about specifics that relate to the position you are applying for. If you do not have<br />specific experience, get as close as you can.<br /><br />4. Do you consider yourself successful?<br />You should always answer yes and briefly explain why. A good explanation is that you have<br />set goals, and you have met some and are on track to achieve the others.<br /><br />5. What do co-workers say about you?<br />Be prepared with a quote or two from co-workers. Either a specific statement or a paraphrase<br />will work. Jill Clark, a co-worker at Smith Company, always said I was the hardest workers she had ever known. It is as powerful as Jill having said it at the interview herself.<br /><br />6. What do you know about this organization?<br />This question is one reason to do some research on the organization before the interview.<br />Find out where they have been and where they are going. What are the current issues and who are the major players?<br /><br />7. What have you done to improve your knowledge in the last year?<br />Try to include improvement activities that relate to the job. A wide variety of activities can be<br />mentioned as positive self-improvement. Have some good ones handy to mention.<br /><br />8. Are you applying for other jobs?<br />Be honest but do not spend a lot of time in this area. Keep the focus on this job and what you<br />can do for this organization. Anything else is a distraction.<br /><br />9. Why do you want to work for this organization?<br />This may take some thought and certainly, should be based on the research you have done on<br />the organization. Sincerity is extremely important here and will easily be used. Relate it to your longterm career goals.<br /><br />10. Do you know anyone who works for us?<br />Be aware of the policy on relatives working for the organization. This can affect your answer<br />even though they asked about friends not relatives. Be careful to mention a friend only if they are well thought of.<br /><br />11. What kind of salary do you need?<br />A loaded question. A nasty little game that you will probably lose if you answer first. So, do<br />not answer it. Instead, say something like, that’s a tough question. Can you tell me the range for this position? In most cases, the interviewer, taken off guard, will tell you. If not, say that it can depend on the details of the job. Then give a wide range.<br /><br />12. Are you a team player?<br />You are, of course, a team player. Be sure to have examples ready. Specifics that show you<br />often perform for the good of the team rather than for yourself is good evidence of your team attitude. Do not brag; just say it in a matter-of-fact tone? This is a key point.<br /><br />13. How long would you expect to work for us if hired?<br />Specifics here are not good. Something like this should work: I’d like it to be a long time. Or<br />As long as we both feel I’m doing a good job.<br /><br />14. Have you ever had to fire anyone? How did you feel about that?<br />This is serious. Do not make light of it or in any way seem like you like to fire people. At the<br />same time, you will do it when it is the right thing to do. When it comes to the organization versus the individual who has created a harmful situation, you will protect the organization. Remember firing is not the same as layoff or reduction in force.<br /><br />15. What is your philosophy towards work?<br />The interviewer is not looking for a long or flowery dissertation here. Do you have strong<br />feelings that the job gets done? Yes. That’s the type of answer were that works best here. Short and positive, showing a benefit to the organization.<br /><br />16. If you had enough money to retire right now, would you?<br />Answer yes if you would. But since you need to work, this is the type of work you prefer. Do<br />not say yes if you do not mean it.<br /><br />17. Have you ever been asked to leave a position?<br />If you have not, say no. If you have, be honest, brief and avoid saying negative things about<br />the people or organization involved.<br /><br />18. Explain how you would be an asset to this organization?<br />You should be anxious for this question. It gives you a chance to highlight your best points as<br />they relate to the position being discussed. Give a little advance thought to this relationship.<br /><br />19. Why should we hire you?<br />Point out how your assets meet what the organization needs. Do not mention any other<br />candidates to make a comparison.<br /><br />20. Tell me about a suggestion you have made?<br />Have a good one ready. Be sure and use a suggestion that was accepted and was then<br />considered successful. One related to the type of work applied for is a real plus.<br /><br />21. What irritates you about co-workers?<br />This is a trap question. Think real hard but fail to come up with anything that irritates you. A<br />short statement that you seem to get along with folks is great.<br /><br />22. What is your greatest strength?<br /><br />Numerous answers are good, just stay positive. A few good examples: Your ability to<br />prioritize, Your problem-solving skills, Your ability to work under pressure, Your ability to focus on projects, Your professional expertise, Your leadership skills, Your positive attitude<br /><br />23. Tell me about your dream job.<br />Stay away from a specific job. You cannot win. If you say the job you are contending for is it,<br />you strain credibility. If you say another job is it, you plant the suspicion that you will be dissatisfied with this position if hired. The best is to stay genetic and say something like: A job where I love the work, like the people, can contribute and can’t wait to get to work.<br /><br />24. Why do you think you would do well at this job?<br />Give several reasons and include skills, experience and interest.<br /><br />25. What are you looking for in a job?<br />See answer # 23<br /><br />26. What kind of person would you refuse to work with?<br />Do not be trivial. It would take disloyalty to the organization, violence or lawbreaking to get<br />you to object. Minor objections will label you as a whiner.<br /><br />27. What is more important to you: the money or the work?<br />Money is always important, but the work is the most important. There is no better answer.<br /><br />28. What would your previous supervisor say your strongest point is?<br />There are numerous good possibilities: Loyalty, Energy, Positive attitude, Leadership, Team<br />player, Expertise, Initiative, Patience, Hard work, Creativity, Problem solver<br /><br />29. Tell me about a problem you had with a supervisor?<br />Biggest trap of all. This is a test to see if you will speak ill of your boss. If you fall for it and<br />tell about a problem with a former boss, you may well below the interview right there. Stay positive and develop a poor memory about any trouble with a supervisor.<br /><br />30. What has disappointed you about a job?<br />Don’t get trivial or negative. Safe areas are few but can include: Not enough of a challenge.<br />You were laid off in a reduction Company did not win a contract, which would have given you more responsibility.<br /><br />31. Tell me about your ability to work under pressure?<br />You may say that you thrive under certain types of pressure. Give an example that relates to<br />the type of position applied for.<br /><br />32. Do your skills match this job or another job more closely?<br />Probably this one. Do not give fuel to the suspicion that you may want another job more than<br />this one.<br /><br />33. What motivates you to do your best on the job?<br />This is a personal trait that only you can say, but good examples are: Challenge, Achievement<br />and Recognition.<br /><br />34. Are you willing to work overtime? Nights? Weekends?<br />This is up to you. Be totally honest.<br /><br />35. How would you know you were successful on this job?<br />Several ways are good measures: You set high standards for yourself and meet them. Your<br />outcomes are a success. Your boss tells you that you are successful.<br /><br />36. Would you be willing to relocate if required?<br />You should be clear on this with your family prior to the interview if you think there is a<br />chance it may come up. Do not say yes just to get the job if the real answer is no. This can create a lot of problems later on in your career. Be honest at this point and save yourself future grief.<br /><br />37. Are you willing to put the interests of the organization ahead of your own?<br />This is a straight loyalty and dedication question. Do not worry about the deep ethical and<br />philosophical implications. Just say yes.<br /><br />38. Describe your management style.<br />Try to avoid labels. Some of the more common labels, like progressive, salesman or<br />consensus, can have several meanings or descriptions depending on which management expert you listen to. The situational style is safe, because it says you will manage according to the situation, instead of one size fits all.<br /><br />39. What have you learned from mistakes on the job?<br />Here you have to come up with something or you strain credibility. Make it small, well intentioned mistake with a positive lesson learned. An example would be working too far ahead of colleagues on a project and thus throwing coordination off.<br /><br />40. Do you have any blind spots?<br />Trick question. If you know about blind spots, they are no longer blind spots. Do not reveal<br />any personal areas of concern here. Let them do their own discovery on your bad points. Do not hand it to them.<br /><br />41. If you were hiring a person for this job, what would you look for?<br />Be careful to mention traits that are needed and that you have.<br /><br />42. Do you think you are overqualified for this position?<br />Regardless of your qualifications, state that you are very well qualified for the position.<br /><br />43. How do you propose to compensate for your lack of experience?<br />First, if you have experience that the interviewer does not know about, bring that up: Then,<br />point out (if true) that you are a hard working quick learner.<br /><br />44. What qualities do you look for in a boss?<br />Be generic and positive. Safe qualities are knowledgeable, a sense of humor, fair, loyal to<br />subordinates and holder of high standards. All bosses think they have these traits.<br /><br />45. Tell me about a time when you helped resolve a dispute between others?<br />Pick a specific incident. Concentrate on your problem solving technique and not the dispute<br />you settled.<br /><br />46. What position do you prefer on a team working on a project?<br />Be honest. If you are comfortable in different roles, point that out.<br /><br />47. Describe your work ethic.<br />Emphasize benefits to the organization. Things like, determination to get the job done and<br />work hard but enjoy your work are good.<br /><br />48. What has been your biggest professional disappointment?<br />Be sure that you refer to something that was beyond your control. Show acceptance and no<br />negative feelings.<br /><br />49. Tell me about the most fun you have had on the job.<br />Talk about having fun by accomplishing something for the organization.<br /><br />50. Do you have any questions for me?<br />Always have some questions prepared. Questions prepared where you will be an asset to the<br />organization are good. How soon will I be able to be productive? And what type of projects will I be able to assist on? are examples.<br /><br />5.2 Job Interviewing Do’s and Don’ts<br />Here are the keys to successful job interviewing. Follow these simple rules and you should<br />achieve success in this important phase of job-hunting.<br />Do take a practice run to the location where you are having the interview -- or be sure you<br />know exactly where it is and how long it takes to get there.<br />Do your research and know the type of job interview you will be encountering. (See types of<br />job interviews.) And do prepare and practice for the interview, but don’t memorize or overrehearse<br />your answers. (See our some of the best collections of interview questions.)<br />Do dress the part for the job, the company and the industry. And do err on the side of<br />conservatism. If you’re not sure, you should consider reading our article, when Job-Hunting:<br />Dress for Success.<br />Do plan to arrive about 10 minutes early. Late arrival for a job interview is never excusable.<br />If you are running late, do phone the company.<br />Do greet the receptionist or assistant with courtesy and respect. This is where you make your<br />first impression.<br />Don’t chew gum during the interview.<br />If presented with a job application, do fill it out neatly, completely, and accurately.<br />Do bring extra resumes to the interview. (Even better, if you have a job skills portfolio, do<br />bring that with you to the interview.)<br />Don’t rely on your application or resume to do the selling for you. No matter how qualified<br />you are for the position, you will need to sell yourself to the interviewer.<br />Do greet the interviewer(s) by title (Ms., Mr., and Dr.) and last name if you are sure of the<br />pronunciation. (If you’re not sure, do ask the receptionist about the pronunciation before<br />going into the interview.<br />Do shake hands firmly. Don’t have a limp or clammy handshake!<br />Do wait until you are offered a chair before sitting. And do remember body language and<br />posture: sit upright and look alert and interested at all times. Don’t fidget or slouch.<br />Don’t tell jokes during the interview.<br />Do make good eye contact with your interviewer(s).<br />Do show enthusiasm in the position and the company.<br />Don’t smoke, even if the interviewer does and offers you a cigarette. And don’t smoke<br />beforehand so that you smell like smoke. And do brush your teeth, use mouthwash, or have a<br />breath mint before the interview.<br />Do avoid using poor language, slang, and pause words (such as "like," "uh” and "um").<br />Don't be soft-spoken. A forceful voice projects confidence.<br />Do have a high confidence and energy level, but don't be overly aggressive.<br />Don't act as though you would take any job or are desperate for employment.<br />Do avoid controversial topics.<br />Don't say anything negative about former colleagues, supervisors, or employers.<br />Do make sure that your good points come across to the interviewer in a factual, sincere<br />manner.<br />Don't ever lie. Answer questions truthfully, frankly and succinctly. And don't over-answer<br />questions.<br />Do stress your achievements. And don't offer any negative information about yourself.<br />Don’t answer questions with a simple "yes" or "no." Explain whenever possible. Describe<br />those things about yourself that showcase your talents, skills, and determination. Give<br />examples.<br />Do show off the research you have done on the company and industry when responding to<br />questions. (See our Guide to Researching Companies.)<br />Don’t bring up or discuss personal issues or family problems.<br />Do remember that the interview is also an important time for you to evaluate the interviewer<br />and the company she represents.<br />Don’t respond to an unexpected question with an extended pause or by saying something like,<br />"boy, that’s a good question." And do repeat the question out loud or ask for the question to<br />be repeated to give you a little more time to think about an answer. Also, a short pause before<br />responding is okay.<br />Do always conduct yourself as if you are determined to get the job you are discussing. Never<br />close the door on an opportunity until you are sure about it.<br />Don’t answer cell phone calls during the interview, and do turn off (or set to silent ring) your<br />cell phone and/or pager.<br />Do show what you can do for the company rather than what the company can do for you.<br />Don’t inquire about salary, vacations, bonuses, retirement, or other benefits until after you’ve<br />received an offer. Be prepared for a question about your salary requirements, but do try and<br />delay salary talk until you have an offer. (You might consider visiting our salary tutorial for<br />more tips and strategies.)<br />Do ask intelligent questions about the job, company, or industry. Don’t ever not ask any<br />questions -- it shows a lack of interest.<br />Do close the interview by telling the interviewer(s) that you want the job and asking about the<br />next step in the process. (Some experts even say you should close the interview by asking for<br />the job.)<br />Do try and get business cards from each person you interviewed with -- or at least the correct<br />spelling of their first and last names. And don’t make assumptions about simple names -- was<br />it Jon or John -- get the spelling.<br />Do immediately take down notes after the interview concludes so you don’t forget crucial<br />details.<br /><br /> MOTIVATING WORDS<br />Tell yourself you are a great individual and believe in your self, for if you don’t believe<br />in your self, no one else will believe in you. Create your own life and then go out and live it.<br />The law of averages tells us you must achieve more, if you are trying more. More, more and<br />more. The more self-confidence you have the less you will be affected by temporary setbacks (never final, always temporary) and short-term disappointments. The more self-confidence you have the likely it is that you will live a life full of achievement, riches, satisfaction and pure bliss.<br />MY FRIEND, YOU ARE EXTRAORDINARY!! The odds are greater than 50 crore to 1<br />against their ever being anyone with the unique combination of talents, skills, and abilities that you possess. You are unique, never forget my friend. The unbelievable achievements that you are capable of, no one knows, not even your self. Exploit your strengths and starve your weaknesses. Yes, of course there is more to it than this but not much more. "WE ARE WHAT WE THINK ABOUT!" YOU MUST! You must make up your mind to look at you honestly and make future decisions based on your uniqueness. NOW! TODAY! THIS VERY MOMENT is time to realize how extraordinary you are.<br />Albert Einstein used his brain.<br />Napoleon used his power.<br />Thomas Edison used his brain.<br />Thatz why they reached that position. Use your brain my friend. You can reach a<br />unbelievable position. You can.<br /><br />The psychologist Abraham Maslow says the story of the human race is the story of men and<br />women selling themselves short. The great majority of people tend to compare themselves<br />unfavorably with others. They dwell on there own weaknesses and limitations and they usually end up with far less then they are really capable of. Instead of taking control of their life and enjoying high levels of self-esteem, self-respect and personal pride, the average person just gets by from day to day. GOD put you here on this glorious earth to do more than "just get by." If self-confidence and the self-esteem that goes with it is so desirable, why is it so few people have enough self-confidence to live the lives that are possible for them?<br />From time to time, (rarely) we have seen people with naturally high levels of self-confidence.<br />These people have gone on to achieve extraordinary things. In studying the lives of these superachievers we have found that "some" of them started out with high levels of self-confidence, which they learned from there parents, quite fortunately, in early childhood. But, most of them started out like most of us with down deep feelings of inferiority and inadequacy. Because of criticism and lack of love and other mistakes parents made in early childhood, we grow up with little self-esteem and feel less than others.<br />The starting point in developing a high level of self-confidence and in reality becoming an<br />EXCELLENT human being is to think through and to decide upon your valves. For example, what is really, really important to you? How do you define values? Having defined a clear set of values, not vague, not unsure, but clear, concise, values will cause you to develop the convictions and enthusiasm necessary for self-confidence. Your starting point toward higher self-confidence and personal greatness is to clarify your values for yourself. Ask yourself what you truly believe in! (?) What do you stand for? What will you not stand for? What would you pay for? Work for? or even DIE FOR????<br />Make your own list and remember, unshakeable self-confidence comes from unshakeable<br />commitment to your values. When deep down inside yourself you know you will never violate your highest principles you experience a deep sense of "personal power" and confidence that<br />empowers you to deal with life openly and honestly and with complete self-confidence in almost<br />every human situation.<br />Did you know that Edison failed over 9000 (that’s thousand) times before perfecting the light<br />bulb! How many of us would have thrown in the "proverbial" towel at 20 failures, 150 failures or at the 8000th failure. After Edison had invented and produced the light-bulb a reporter asked him how it felt to fail over 9000 times. Edison replied, "I was glad I found 9000 ways not to invent the light bulb! From this point forward Edison went on to receive 1,093 patents, more than any other person in U.S. history.<br /><br /><br />Read as many books, and magazines that are positive inspirational and motivational as you<br />possibly can. Study the lives of the people who have a positive message to share with all of us, nd<br />especially in the given field you have chosen to be great at.<br /><br />Nothing in life that is worthy is ever too hard to achieve, if you have the courage to try it<br />and you have the faith to believe. Faith is a force that is greater than knowledge or power or skill.<br />"The secret of success in life is for u to be ready for your opportunity when it comes."<br />"Success comes in cans, not cannot."<br />"There are no secrets to success. It is the result of preparation, hard work, learning from failure."<br />"Self-trust is the first secret of success."<br />"Success is going from failure to failure without loss of enthusiasm."<br />"We can succeed at almost anything for which we have unlimited enthusiasm."<br />Dear friend, you should get Strength to battle with difficulties and overcome them. You<br />should get Patience enough to toil until some good is accomplished. You should hope enough to<br />remove all anxious fears concerning the future.<br />Emotional decisions come from the heart, thinking ones from the brain. You should not take<br />any emotional decisions. This is the age we all take only emotional decisions. Ask your brain always, it will tell you, what is correct and wrong.<br /> To have a positive day keep the following in mind:<br />1. Every problem has a solution.<br />2. Failures always lead to learning something you can use later.<br />3. Many times you must take a step back before u take two steps forward.<br />4. After a crisis is always an opportunity.<br />5. You control your thoughts and feelings.<br />6. You make the choices that determine your fate.<br />Michael Jordan wordings. (He is famous US basket ball player.)<br />1. I have missed more than 9000 shots in my career. I have lost almost 300 games. 26 times, I have been trusted to take the game winning shot and missed. I have failed over and over and over again in my life. And that is why I succeed.<br />2. I can accept failure, but I can’t accept not trying.<br />3. I have always believed that if you put in the work, the results will come. I don’t do things halfheartedly. Because I know if I do, then I can expect half-hearted results.<br />4. If you are trying to achieve, there will be roadblocks. I have had them; everybody has had them.<br />5. Obstacles don’t have to stop you. If you run into a wall, don’t turn around and give up. Figure out how to climb it, go through it, or work around it.<br /><br />9. AT ANY COST DON’T LET YOUR HOPE DOWN, WE ARE HERE<br />TO SUPPORT YOU<br />Always keep in mind that ‘what do you want right now?' 'What is lacking behind YOU to get<br />that?' 'What has to be done to get as early as possible?'<br />To overcome all the above mentioned questions, always there is only one thing with<br />you...That is 'Continuous hard work without loosing rays of hope'....You should not lose your hope even you didn't get job after a month or two months or even a year(Just for sake I am telling<br />this)...But no one will do that...You should not stop initiation (whatever you have to do to get job) or approach towards getting job from your side ...You just have to keep on trying to achieve whatever you want?...I am sure you will do that because you are in that situation and also I can support you to the extend I can...See if you think you can always you can...Isn't it?...<br />Don't loose your hope and always have positive attitude in your mind...Think always about<br />getting job and do something related to that (which can add value to get a job. we will also help you what you need to do. Nothing should be there in your mind apart from getting job.<br />For example, If you walking along the road suppose you are seeing an advertisement during that time even that is not related to yours but you should be able to notice or something has to be triggered on your mind regarding your job...Because opportunities can come in any way, you should aware and should not miss that one...It won't come again...To really understand this I can tell you N number of examples even from my friends circle and from my own experience also...You don't attend courses by paying 30 to 50 thousand.....This is I am telling you from my own experience...Because even I didn't know how to type in computer keyboard also I didn't attend for any courses when I got selected into TCS...You don't have to worry about technical knowledge for a fresher....The company which hires you will give you lots of training in software. Just you have to prepare to clear the written test and interview to get into the company.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-25106037008510440852008-07-25T11:04:00.001-07:002008-12-23T04:01:37.822-08:00Questions Paper formatThis is just a sample format of the questions for practicing only. Do not bring this material to the office at any cost.<br /><br />Mathematics questions:<br /><br />1. If a number is increased by 20% and then decreased by 20%., then the final number will be<br /><br />Ans: 4% less<br /><br />2. A cricketer has an average score of 24 runs in 24 innings. How many runs must he score in the 25th innings to make his average 25?<br /><br />Ans: 49<br /><br />3. Evaluate 617 + 6.017 +0.617 + 6.0017<br /><br />Ans: 629.6357<br /><br />4. 0.05* 0.4 /0.98 = <br /><br />Ans: none of these<br /><br />5. The age of a father is 3 times that of his son. After 20 years he will be twice as old as his son. What is current age of father?<br /><br />Ans: 60 years<br /><br />6. If 9/x = x/144 , x = ?<br /><br />Ans: 36<br /><br />7. A number is twice the first and thrice the second and their average is 44. What is the largest number?<br /><br />Ans : 72<br /><br />8. A can do a work in 8 days and B can do it in 24 days. In how many days they can together do it?<br /><br />Ans: 6 days<br /><br />9. A trader fixes the price of article 30 % above the cost price. If he allows a discount of 10% find his gain %<br /><br />Ans: 17 %<br /><br />10. Find the unit digit in the product (256*27*159*182)<br /><br />Ans: 6<br /><br /><br />SECTION II<br /><br />1) Starting from a point, Raju walked 12 meters towards north, he turned right and walked 10 meters; he again turned right and walked 12 meters, then he turned left and walked 5 meters. How far is he now and in which direction from the starting point?<br />Ans: 15 m towards east<br /><br />2) Raghu ranks 19th in the class of 40. What is his rank from the left?<br />Ans: 22<br /><br />3) Sudha is taller than Pushpa.but shorter than Malathi; Geetha is shorter than Vijju; Vijju is not as tall as pushpa. Who should come in the middle if all stand in a row according to height?<br />Ans: Pushpa<br /><br />4) Drama is related to Director in the same way as Magazine is related to<br />Ans: Editor<br /><br />5) In a certain code CLOCK is written KCOLC. How is STEPS written in that code?<br />Ans: SPETS<br /><br />6) If “light” is called “dark”; “dark” is called “green”; “green” is called “blue”; “blue” is called “red” ; ”red” is called “white” is called “yellow” what is the color of blood ?<br />Ans: White<br /><br />7) In a certain code language “123” means “ hot filter coffee”; “356” mean “very hot day”; and “589” means “ day and night” Which digit in that code means “very”<br />Ans: 6<br /><br />8) How many such 7s are there in the following number sequence which are immediately followed by 4 but not immediately preceded by 8?<br /><br />5 4 7 8 9 7 4 3 8 7 5 7 4 7 8 7 4 1 2 7 4 5 7 9 4<br /><br />Ans: Three<br /><br />9) In a telephone directory which of the following names will appear in the middle ?<br /><br />a) Rajrathnam b) Rajrathanam c) Rajratnam d) Rajratanam e) Raajrathnam<br /><br />Ans: Rajrathanam<br /><br />10) In a basket, there are some apples which are getting doubled for every one minute. If the basket becomes full with apples within an hour, when would it have been exactly half?<br />Ans: At the 59th minute<br /><br />SECTION III<br /><br />COMPREHENSIVE PASSAGE I<br /><br />1) Trinidad and Tobago is /are<br />Ans: One country composed of two islands<br /><br />2) Tourists have been attracted by Trinidad and Tobago mainly because of its<br />Ans: Music and Dance<br /><br />3) Investors are attracted towards Trinidad and Tobago mainly because of its<br />Ans: Oil deposits<br /><br />4) The flowers of Trinidad resembles those of<br />Ans: South America<br /><br />5) The topography of Tobago is marked by<br />Ans: Sugarcane fields<br /><br />COMPREHENSIVE PASSAGE II<br /><br />1) The passage is about:<br />Ans: Day care for babies<br /><br />2) A baby is likely to feel more at ease with<br />Ans: an infant<br /><br />3) Dr. Benjamin Spock<br />Ans: Writes books on babies<br /><br />4)According to the passage, to provide care for their babies working parents should<br />Ans: Find a private home with other infants<br /><br />5) Pediatrician<br />Ans: A child specialist<br /><br />PART III<br /><br />Read the following sentences carefully and tick one of the options which is very close to the bolded and underlined word in the sentence:<br /><br />11) A batsman walking back to the pavilion before the umpire has given verdict is a rare sight these days.<br />Ans: Judgement<br /><br />12) Four countries – Brazil, Russia, India & China – are likely to play a significant role in the world economy sooner than 2050, a new report by international consultants Goldman Sachs has said.<br />Ans: Important<br /><br />13) Andhra Pradesh government is planning to impose tariff at the rate of one rupee a unit on power consumed by agriculture pump sets in corporate forms<br />Ans: Enforce<br /><br />14) A human cell contains some hundred thousand different proteins which have numerous important functions.<br />Ans: Several<br /><br />15)Expert in meterological dept are quite skeptical about the benefits from the cloud seeding operations for which the government has so far paid nearly Rs. 7 crores to the contracters.<br />Ans: Doubtful<br /><br />Tick the right spelling of the word from the given options<br /><br />16)Ans: Immortal<br /><br />17) Ans: Symmetrical<br /><br />18)Ans: Encyclopedia<br /><br />19)Ans: Mortgage<br /><br />20)Ans: Dictionary<br /><br /><br /><br />Written communication: Duration 10 minutes<br /><br />Please write an email apologizing to the customer for serving him/her with a non-vegetarian pizza instead of a vegetarian pizza.<br /><br /><br />Typing Test Passage ( Typing Master Software) Duration 2 minutes<br /><br />1. Reflection<br />2. A History of PhotographySumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-78484385322753231902008-07-25T11:02:00.002-07:002008-12-23T04:01:37.822-08:00Instruction for interview - Voice ProcessBefore you come for the interview, I would like to give certain Hints & tips for success at interview.<br /><br />About our Company:<br /><br />Our parent company is First American Corporation. Its Indian operation is First Indian Corporation. We have two branches in India, one in Bangalore & other at Hyderabad. The head office is at Dallas, USA. Previously, our office was at ITPL and in January, we shifted our office to Bagamane Tech Park, located in CV Raman Nagar. We are about 2,500 employees working at Bagamane & about 2000 at Hyderabad, and nearly 36,000 employees worldwide. We mainly deal with Mortgage information. We have software, BPO- Voice & Non-voice comprising of more than 100 processes at FIC. For more information about our company, you can visit the websites: http://www.firstindiancorp.com and www.firstam.com<br /><br />You will be having 4 rounds of interview as stated earlier.<br /><br />Round 1: Aptitude Test (General English & Maths)<br /><br />This will cover your basic Maths course related to Profit & loss, ratio & proportion, problems on work & time,<br />For better score, please refer Quantitative Aptitude by R.S Agarwal available at Gangarams or Sapna Book House.<br /><br />Round 2: HR<br />You are asked to tell about yourself.<br /><br />Round 3: Voice Test<br />Here you are tested on the US Accent.<br />.<br />Round 4: Operations Manager Round<br />This is the most important of all the rounds. Here you are asked to tell more about yourself.<br /><br />In the HR & Operations Manager round, you need to speak about your family background, your educational qualifications, technical qualification, your strengths and finally your work experiences in different companies and reason for leaving the company in each case. Please mention your role and responsibilities in each work experience and stress on how you can implement those work experience in the new job to provide a quality work and for the growth of the company.<br /><br />Note: Please wish the interviewer before you take the seat with a warm shake hand.<br /><br />Here is sample format for How to speak in the interview taken me (Anil Kumar) as example:<br /><br />Good Morning Sir, this is Anil, a B.Sc Graduate seeking a prospective & growth oriented job. I was born and brought up in Bangalore. My father is a section officer at Vidhana Soudha. My mother is a retired head constable. I have two younger sisters. Both of them working medical transcriptionist at Maxhealthscirbe located at Koramangala.About my educational qualification, I did my SSLC from Sri Saraswathi Vidya Mandira located at Chamarajpet. I completed my PUC with first class from BHS First Grade College located at 4th Block Jayanagar. My optional subjects were Physics, Chemistry, Mathematics & Biology. Then I completed my graduation BSc with First class from the same college in 1998. My optional subjects were Physics, Chemistry & Mathematics since I loved Maths & Chemistry very much. In my school days, I was weak in Maths and there were certain times wherein I developed fever thinking of Maths. Then I was introduced my Maths teacher Vijaydvaja, who imparted the basic fundamental of mathematics to me. Later on, I met my Maths guru Sri B V Nagaraj, Principal of Bangalore High School, where I went for Maths & Science coaching. My Guru BV Nagaraj, implemented confidence in Maths and Vedic Maths helped me to master Maths.<br /><br />About my technical qualification, I have done 6 months course in Diploma in Computer Applications from St Joseph College. Later on, I did 2 years course in Honor diploma in Software Engineering from Aptech computers, MG Road with a brief exposure to C, C++, Java, Oracle, Internet & other technical aspects.<br /><br />About my work experience, I first worked as a office assistant at Universal Academy located at 4th Block Jayanagar for a period of 3 months. My job role was to maintain student’s academics information in a database. I worked there for a period of three months as I got good offer to work as Subject Specialist for chemistry at Asian Institute of Technology which is located in Jayanagar. My job role was to prepare questionnaires for IIT-JEE, CET & other engineering entrance exams. I worked there for 1 year as it was a contract.<br /><br />Then, I entered the BPO section as Insurance Claim Processor at Dharma Systems, located in Koramangala. My Job profile was to enter patient information of various American hospitals into a Database called Medsuite which was sent to Insurance company for processing the medical claims. I was also responsible for training the new joinees and generation of daily report of issues related the work and mail it to the head office located in USA. There, I worked for 2 years. I am unable to continue in that company since it is a two year contract. Last week, we received a mail from USA for cutting down the staff members.<br /><br />About my hobbies & interests, I like conducting science experiments. From the childhood days, I used to do lot of science experiments especially chemistry like preparation of different chemical compounds like Sulphuric acid, phosphorus pentoxide etc. at home. I had also constructed a telescope during my school days. In my college days, I was introduced to Vedic Maths by my Friend Yogesh, which made me an expert in Mathematics. I have published 4 books in Maths for college students. During my free time, I handle tuitions for college & High school students. I love watching movies and listening to music.<br /><br /> I came to know about your company from my ex-colleague Gokul , who is working in your company. He told me that job is related to mortgage information. He told me that FIC offers a good working environment for the employees which motivate them to work with pleasure. This encouraged me to seek a job in your company. He also told about his job profile that this job involves searching information on internet based on certain criteria. I have good knowledge about internet & I am aware of search engines like yahoo, Google & hotmail which are use to get information related to news, entertainment etc. I feel that it is an interesting assignment for challenging person like me to work here to provide a quality work to the company. I possess good analyzing skills and can understand the nature of job quickly. I am willing to work in shift if the job demands. I am flexible to work individually as well as in teams as per the company requirements. I came to know from Gokul that this job demands good analyzing and searching skills. I have worked efficiently providing quality work to my previous companies. If you provide me an opportunity, I can dedicate myself to provide a quality work for a better growth & prospects of the company.<br /><br />Note:<br />1) Speak clearly with medium speed so that everyone can understand what you speak.<br />2) Present yourself as a special person by speaking about your talents if you have. For example, painting, sports, dancing, singing etc.<br />3) Talk about your roles and responsibilities in your previous company and how you used to manage the work.<br />4) Please write in a piece of paper about what to speak in the interview in the above format and practice in front of a mirror.<br />5) Put stress on your willingness to work in the company.<br />6) Be confident, please put in your best efforts and leave the rest to God.<br /><br />Tips for making the resume:<br /><br />Let the resume contains at least two pages in the format as specified by me. I don’t want any resume of only one page. Let it have the following headlines:<br /><br />Career Objective:<br /><br />Job specialization:<br /><br />Academic Details:<br /><br />Technical qualifications: any basic computer course that you have done.<br /><br />Work experience: company name, designation, role and duration.<br /><br />Personal details:<br /><br />Hobbies and Interests: Like playing chess, debate and extra curricular activities<br /><br />Languages known:<br />Some common questions asked during the HR and Operations Manager rounds:<br /><br />1) Tell about yourself :<br />Ans: Refer the document for this question.<br /><br />2) What salary are you expecting?<br />Ans: As per company standards but negotiable depending upon my performance.<br /><br />3) Why do you want to leave your previous company?<br />Ans: Give a valid reason and do not mention that you are getting less salary in the current company where you are working. Instead, say that the job is not stable since it is on contract basis. Tell that you would like to have long term relationship with company where you work.<br /><br />4) Why should I offer you the job at FIC?<br />Or why should I hire you?<br />Ans: I came to know about your company from my friend Anil, who is working in Agency Refund department of your organization. He told me that FIC offers a good working environment for the employees which motivate them to work with pleasure. This encouraged me to seek a job in your company. He told me that job is related to mortgage information which involves searching information on internet based on certain criteria and one should possess good analyzing skills. I have good knowledge about internet & search engines like yahoo, Google & hotmail which are use to get information related to news, entertainment etc. I feel that it is an interesting assignment for challenging person like me to work here to provide a quality work to the company. I have worked efficiently being a good team player providing quality work to my previous companies. I possess good analyzing skills and can understand the nature of job quickly. I am willing to work in shift if the job demands. I am flexible to work individually as well as in teams as per the company requirements. I can contribute significantly to challenging assignments. I have been keen in learning things and implementing the new ideas as a continuous improvement initiative. If you provide me an opportunity to work in your organization, I can dedicate myself to provide a quality work for a better growth & prospects of the company.<br /><br />5) What are your strengths and weakness?<br />Ans: Tell something special about yourself like knowledge, ability to grasp the nature of job quickly, ability to handle the job individual without any extra support etc. But don’t say too much of it.<br /><br />6) Explain your roles in the previous company or explain your job profile in the previous company.<br />Ans: Try to present the nature of your job in the present company and give a clear picture of your roles and responsibilities. Also, tell about the challenges and problems you faced and how you tackled with your skills to become a good team player.<br /><br />7) What do you mean by Mortgage?<br />A loan to finance the purchase of real estate, usually with specified payment periods and interest rates.<br /><br />8) What is BPO?<br />BPO is the act of transferring some of an organization's repeated non-core and core business processes to an outside provider to achieve cost reductions while improving service quality.<br />Outsourcing gives you the right combination of people, processes and technology to operate effectively in the Global market place without burdening your time and budget.<br /><br />The most common business process that gets outsourced is call centers. Call centers and Help Desks of many multi national and fortune 500 companies are being outsourced to low waged, English speaking countries such as Philippines and India.<br /><br /><br /><br />9) What do you know about our company?<br /><br />First Indian Corporation Private Limited is a subsidiary of First American Corporation. It is a leading provider of offshore transaction and technology services to the Real Estate Information and Mortgage Industry with over 4,700 professionals in Bangalore and Hyderabad. Also, I came to know that FIC is launching its new operation in Mangalore in January 2007.<br /><br />First Indian Corporation is a pioneer in BPO industry in India having commenced its Image Processing operations in Hyderabad in 1994.<br />First Indian Corporation's primary focus is on the Title Insurance, Property Tax, Flood Certification, Default Management Services, Credit and Real Estate Information segments.<br /><br />The First American Corporation is America’s largest provider of business information products and services combining advanced analytics with its vast data resources. The corporation commands leading market share positions in many of the segments it operates with $8.10 billion revenue in 2005 with 35,000 employees worldwide.<br /><br />10) Where do you see yourself in 5 years?<br />I would like to see myself as a professional who is well equipped with knowledge, who can perform at his best and would like to lead a group of people who are ambitious and can work towards the fulfillment of their ambitions and help them in developing creative thoughts and contributing them towards the growth of my society, my organization & for my people.<br /><br />11) What is your career goal or ambition?<br />Well, everybody looks for good pay, and would love to work with deep industry and business process expertise, broad global resources and with a work environment where you would have work & life balance both.<br /><br />12) Tell something about your family background.<br /><br />13) Tell something about your hobbies.<br /><br />14) Are you willing to work in night shift?<br /><br />It is better to take a print out of the information that I have sent and practice it before coming to the interview.<br /><br />Please quote my name, employee id, email Id and department name on your resume and in the interview, tell the HR/Manager that you are my friend and personally know each other because the interview is strictly through employee reference only. Please meet me in person at the reception of FIC (3rd Floor) before coming for the interview for better acknowledgement.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-79005084295979773952008-07-25T11:02:00.001-07:002008-12-23T04:01:37.823-08:00Instructions for interview - non voice ProcessBefore you come for the interview, I would like to give certain Hints & tips for success at interview.<br /><br /><br />You will be having 5 rounds of interview :<br /><br />Round 1: Aptitude Test (General English & Maths)<br /><br />This will cover your basic Maths course related to Profit & loss, ratio & proportion, problems on work & time,<br />For better score, please refer Quantitative Aptitude by R.S Agarwal available at Gangarams or Sapna Book House.<br /><br />Round 2: Typing Test<br />Speed: Minimum 30-35 words per minute and good accuracy above 90%<br /><br />Round 3: Written Communications<br />Here you will be asked to write a letter to test your vocabulary & grammatical skills<br /><br />Round 4: Non Verbal Reasoning<br />For this, you can again refer a book of Verbal and Non Verbal reasoning by RS Agarwal<br /><br />Round 4: HR<br />You are asked to tell about yourself.<br /><br />Round 5: Operations Manager Round<br />This is the most important of all the rounds. Here you are asked to tell more about yourself.<br /><br />In the HR & Operations Manager round, you need to speak about your family background, your educational qualifications, technical qualification, your strengths and finally your work experiences in different companies and reason for leaving the company in each case. Please mention your role and responsibilities in each work experience and stress on how you can implement those work experience in the new job to provide a quality work and for the growth of the company.<br /><br />Note: Please wish the interviewer before you take the seat with a warm shake hand.<br /><br />Here is sample format for How to speak in the interview taken me (Anil Kumar) as example:<br /><br />Good Morning Sir, this is Anil, a B.Sc Graduate seeking a prospective & growth oriented job. I was born and brought up in Bangalore. My father is a section officer at Vidhana Soudha. My mother is a retired head constable. I have two younger sisters. Both of them working medical transcriptionist at Maxhealthscirbe located at Koramangala.About my educational qualification, I did my SSLC from Sri Saraswathi Vidya Mandira located at Chamarajpet. I completed my PUC with first class from BHS First Grade College located at 4th Block Jayanagar. My optional subjects were Physics, Chemistry, Mathematics & Biology. Then I completed my graduation BSc with First class from the same college in 1998. My optional subjects were Physics, Chemistry & Mathematics since I loved Maths & Chemistry very much. In my school days, I was weak in Maths and there were certain times wherein I developed fever thinking of Maths. Then I was introduced my Maths teacher Vijaydvaja, who imparted the basic fundamental of mathematics to me. Later on, I met my Maths guru Sri B V Nagaraj, Principal of Bangalore High School, where I went for Maths & Science coaching. My Guru BV Nagaraj, implemented confidence in Maths and Vedic Maths helped me to master Maths.<br /><br />About my technical qualification, I have done 6 months course in Diploma in Computer Applications from St Joseph College. Later on, I did 2 years course in Honor diploma in Software Engineering from Aptech computers, MG Road with a brief exposure to C, C++, Java, Oracle, Internet & other technical aspects.<br /><br />About my work experience, I first worked as a office assistant at Universal Academy located at 4th Block Jayanagar for a period of 3 months. My job role was to maintain student’s academics information in a database. I worked there for a period of three months as I got good offer to work as Subject Specialist for chemistry at Asian Institute of Technology which is located in Jayanagar. My job role was to prepare questionnaires for IIT-JEE, CET & other engineering entrance exams. I worked there for 1 year as it was a contract.<br /><br />Then, I entered the BPO section as Insurance Claim Processor at Dharma Systems, located in Koramangala. My Job profile was to enter patient information of various American hospitals into a Database called Medsuite which was sent to Insurance company for processing the medical claims. I was also responsible for training the new joinees and generation of daily report of issues related the work and mail it to the head office located in USA. There, I worked for 2 years. I am unable to continue in that company since it is a two year contract. Last week, we received a mail from USA for cutting down the staff members.<br /><br />About my hobbies & interests, I like conducting science experiments. From the childhood days, I used to do lot of science experiments especially chemistry like preparation of different chemical compounds like Sulphuric acid, phosphorus pentoxide etc. at home. I had also constructed a telescope during my school days. In my college days, I was introduced to Vedic Maths by my Friend Yogesh, which made me an expert in Mathematics. I have published 4 books in Maths for college students. During my free time, I handle tuitions for college & High school students. I love watching movies and listening to music.<br /><br /> Note:<br />1) Speak clearly with medium speed so that everyone can understand what you speak.<br />2) Present yourself as a special person by speaking about your talents if you have. For example, painting, sports, dancing, singing etc.<br />3) Talk about your roles and responsibilities in your previous company and how you used to manage the work.<br />4) Please write in a piece of paper about what to speak in the interview in the above format and practice in front of a mirror.<br />5) Put stress on your willingness to work in the company.<br />6) Be confident, please put in your best efforts and leave the rest to God.<br /><br />Tips for making the resume:<br /><br />Let the resume contains at least two pages in the format as specified by me. I don’t want any resume of only one page. Let it have the following headlines:<br /><br />Career Objective:<br /><br />Job specialization:<br /><br />Academic Details:<br />Technical qualifications: any basic computer course that you have done.<br /><br />Work experience: company name, designation, role and duration.<br /><br />Personal details:<br />Hobbies and Interests: Like playing chess, debate and extra curricular activities<br /><br />Languages known:<br />Some common questions asked during the HR and Operations Manager rounds:<br /><br />1) Tell about yourself :<br />Ans: Refer the document for this question.<br /><br />2) What salary are you expecting?<br />Ans: As per company standards but negotiable depending upon my performance.<br /><br />3) Why do you want to leave your previous company?<br />Ans: Give a valid reason and do not mention that you are getting less salary in the current company where you are working. Instead, say that the job is not stable since it is on contract basis. Please do not say any thing about family problem for discontinuing your previous job. Instead you can tell that I want deliver quality work and enhance my job skill and that these qualities are not found in your present company where you are working.Tell that you would like to have long term relationship with company where you work.<br /><br />4) Why should I offer you the job at FIC?<br />Or why should I hire you?<br />Ans: I came to know about your company from my friend Anil, who is working in Agency Refund department of your organization. He told me that FIC offers a good working environment for the employees which motivate them to work with pleasure. This encouraged me to seek a job in your company. He told me that job is related to mortgage information which involves searching information on internet based on certain criteria and one should possess good analyzing skills. I have good knowledge about internet & search engines like yahoo, Google & hotmail which are use to get information related to news, entertainment etc. I feel that it is an interesting assignment for challenging person like me to work here to provide a quality work to the company. I have worked efficiently being a good team player providing quality work to my previous companies. I possess good analyzing skills and can understand the nature of job quickly. I am willing to work in shift if the job demands. I am flexible to work individually as well as in teams as per the company requirements. I can contribute significantly to challenging assignments. I have been keen in learning things and implementing the new ideas as a continuous improvement initiative. If you provide me an opportunity to work in your organization, I can dedicate myself to provide a quality work for a better growth & prospects of the company.<br /><br />5) What are your strengths and weakness?<br />Ans: Tell something special about yourself like knowledge, ability to grasp the nature of job quickly, ability to handle the job individual without any extra support etc. But don’t say too much of it.<br /><br />6) Explain your roles in the previous company or explain your job profile in the previous company.<br />Ans: Try to present the nature of your job in the present company and give a clear picture of your roles and responsibilities. Also, tell about the challenges and problems you faced and how you tackled with your skills to become a good team player.<br /><br />7) What do you mean by Mortgage?<br />A loan to finance the purchase of real estate, usually with specified payment periods and interest rates.<br /><br />8) What is BPO?<br />BPO is the act of transferring some of an organization's repeated non-core and core business processes to an outside provider to achieve cost reductions while improving service quality.<br />Outsourcing gives you the right combination of people, processes and technology to operate effectively in the Global market place without burdening your time and budget.<br /><br />The most common business process that gets outsourced is call centers. Call centers and Help Desks of many multi national and fortune 500 companies are being outsourced to low waged, English speaking countries such as Philippines and India.<br /><br /><br /><br />9) What do you know about our company?<br /><br />First Indian Corporation Private Limited is a subsidiary of First American Corporation. It is a leading provider of offshore transaction and technology services to the Real Estate Information and Mortgage Industry with over 5,000 professionals in Bangalore and Hyderabad. Also, I came to know that FIC has launching its new operation in Mangalore from January 2007.<br /><br />First Indian Corporation is a pioneer in BPO industry in India having commenced its Image Processing operations in Hyderabad in 1994.<br />First Indian Corporation's primary focus is on the Title Insurance, Property Tax, Flood Certification, Default Management Services, Credit and Real Estate Information segments.<br /><br />The First American Corporation is America’s largest provider of business information products and services combining advanced analytics with its vast data resources. The corporation commands leading market share positions in many of the segments it operates with $8.10 billion revenue in 2005 with 35,000 employees worldwide.<br /><br />10) Where do you see yourself in 5 years?<br />I would like to see myself as a professional who is well equipped with knowledge, who can perform at his best and would like to lead a group of people who are ambitious and can work towards the fulfillment of their ambitions and help them in developing creative thoughts and contributing them towards the growth of my society, my organization & for my people.<br /><br />11) What is your career goal or ambition?<br />Well, everybody looks for good pay, and would love to work with deep industry and business process expertise, broad global resources and with a work environment where you would have work & life balance both.<br /><br />12) Tell something about your family background.<br /><br />13) Tell something about your hobbies.<br /><br />14) Are you willing to work in night shift?Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-50571814146703955832008-07-25T11:00:00.001-07:002008-12-23T04:01:37.823-08:00Verbal questions1. Depreciation: deflation, depression, devaluation, fall, slump<br />2. Deprecate : feel and express disapproval,<br />3. Incentive : thing one encourages one to do (stimulus)<br />4. Echelon : level of authority or responsibility<br />5. Innovation : make changes or introduce new things<br />6. Intermittent : externally stopping and then starting<br />7. Detrimental: harmful<br />8. Conciliation : make less angry or more friendly<br /><br />9. Orthodox: conventional or traditional, superstitious<br /><br />10. Fallible : liable to error<br /><br />11. Volatile : ever changing<br /><br />12. Manifest: clear and obvious<br /><br />13. Connotation : suggest or implied meaning of expression<br /><br />14. Reciprocal: reverse or opposite<br /><br />15. Agrarian : related to agriculture<br /><br />16. Vacillate : undecided or dilemma<br /><br />17. Expedient : fitting proper, desirable<br /><br />18. Simulate : produce artificially resembling an existing one.<br /><br />19. Access : to approach<br /><br />20. Compensation: salary<br /><br />21. Truncate : shorten by cutting<br /><br />22. Adherence : stick<br /><br />23. Heterogeneous: non similar things<br /><br />24. Surplus : excessive<br /><br />25. Assess : determine the amount or value<br /><br />26. Cognizance : knowledge<br /><br />27. Retrospective : review<br /><br />28. Naive : innocent, rustic<br /><br />29. Equivocate : tallying on both sides, lie, mislead<br /><br />30. Postulate : frame a theory<br /><br />31. Latent : dormant, secret<br /><br />32. Fluctuation : wavering,<br /><br />33. Eliminate : to reduce<br /><br />34. Affinity : strong liking<br /><br />35. Expedite : hasten<br /><br />36. Console : to show sympathy<br /><br />37. Adversary : opposition<br /><br />38. Affable : lovable or approachable<br /><br />39. Decomposition : rotten<br /><br />40. Agregious : apart from the crowd, especially bad<br /><br />41. Conglomeration: group, collection<br /><br />42. Aberration: deviation<br /><br />43. Augury : prediction<br /><br />44. Creditability : ability to common belief, quality of being credible<br /><br />45. Coincident: incidentally<br /><br />46. Constituent : accompanying<br /><br />47. Differential : having or showing or making use of<br /><br />48. Litigation : engaging in a law suit<br /><br />49. Moratorium: legally or officially determined period of delay before<br />fulfillment of the agreement of paying of debts.<br /><br />50. Negotiate : discuss or bargain<br /><br />51. Preparation : act of preparing<br /><br />52. Preponderant : superiority of power or quality<br /><br />53. Relevance : quality of being relevant<br /><br />54. Apparatus : appliances<br /><br />55. Ignorance : blindness, in experience<br /><br />56. Obsession: complex enthusiasm<br /><br />57. precipitate : speed, active<br />58. corroborative: refutable<br />59. obnoxious : harmless<br />60. sanction: hinder<br />61. empirical: experimental<br />62. aborigine: emigrant<br /> 63. corpulent : emaciated<br /> 64. officious : pragmate <br />65. Agitator : Firebrand :: Renegade : Turncoat<br /><br />66. Burst : Sound :: Tinder : Fire<br /><br />67. Star : cluster :: Tree : clump<br /><br />68. Piston : Cylinder :: elevator : shaft<br /><br />69. Mitigate : punishment :: commute : sentence<br /><br />70. Erudite : scholar :: illiterate : ignorant<br /><br />71. Fire : Ashes :: explosion : debris<br /><br />72. mason : wall :: Author : Book<br /><br />73. Fire : Ashes :: Event : memories<br /> 74. (a) cheerleaders : pompoms<br />(b) audience:seats<br />(c) team:goalposts<br />(d) conductor:podium<br />(e) referee:decision<br /><br />Ans. (a)<br /><br />75. archipelago:islands::<br /><br />(a) arbor:bower<br />(b) garden:flower<br />(c) mountain:valley<br />(d) sand:dune<br />(e) constellation:star<br /><br />Ans. (a)<br /><br /><br />76. crow:boastful ::<br /><br />(a) smirk:witty<br />(b) conceal:s;y<br />(c) pout:sulky<br />(d) blush:coarse<br />(e) bluster:unhappy<br /><br />Ans. (a)<br /><br /><br />77. bracket:shelf ::<br /><br />(a) hammer:anvil<br />(b) girder:rivet<br />(c) strut:rafter<br />(d) valve:pipe<br />(e) bucket:well<br /><br />Ans. (a)<br /><br /><br />78. taxonomy:classification ::<br /><br />(a) etymology:derivation<br />(b) autonomy:authorization<br />(c) economy:rationalization<br />(d) tautology:justification<br />(e) ecology:urbanisation<br /><br />Ans. (a)<br /><br /><br />79. moderator:debate ::<br /><br />(a) legislator:election<br />(b) chef:banquet<br />(c) auditor:lecture<br />(d) conspirator:plot<br />(e) umpire:game<br /><br />Ans. (a)<br /><br /><br />80. glossary:words ::<br /><br />(a) catalogue:dates<br />(b) atlas:maps<br />(c) almanac:synonyms<br />(d) thesaurus:rhymes<br />(e) lexicon:numbers<br /><br />Ans. (a)<br /><br /><br />81. lumber: bear ::<br /><br />(a) roost:hen<br />(b) bray:donkey<br />(c) waddle:goose<br />(d) swoop:hawk<br />(e) chirp:sparrow<br /><br />Ans. (a)<br /><br /><br />82. celerity:snail ::<br /><br />(a) indolence:sloth<br />(b) cunning:weasel<br />(c) curiosity:cat<br />(d) humility:peacock<br />(e) obstinacy:mule<br /><br />Ans. (a)<br /><br /><br />83. wood:sand ::<br /><br />(a) coal:burn<br />(b) brick:lay<br />(c) oil:polish<br />(d) metal:burnish<br />(e) stone:quarry<br /><br />Ans. (a)<br /><br /><br />84. carpenter:saw ::<br /><br />(a) stenographer:typist<br />(b) painter:brush<br />(c) lawyer:brief<br />(d) runner:sneakers<br />(e) seamstress:scissors<br /><br />Ans. (a)<br /><br /><br />85. horns:bull ::<br /><br />(a) mane:lion<br />(b) wattles:turkey<br />(c) antlers:stag<br />(d) hooves:horse<br />(e) wings:eagle<br /><br />Ans. (a)<br /><br /><br />86. gullible:duped ::<br /><br />(a) credible:cheated<br />(b) careful:cautioned<br />(c) malleable:moulded<br />(d) myopic:mislead<br />(e) articulate:silenced<br /><br />Ans. (a)<br /><br /><br />87. marathon:stamina ::<br /><br />(a) relay:independence<br />(b) hurdle:perseverance<br />(c) sprint:celerity<br />(d) job:weariness<br />(e) ramble:directness<br /><br />Ans. (a)<br /><br /><br />88. Skin:man ::<br /><br />(a) hide:animal<br />(b) jump:start<br />(c) peel:potato<br />(d) eat:food<br />(e) wool:cloth<br /><br />Ans. (a)<br /><br /><br />89. Bamboo:Shoot ::<br /><br />(a) Bean:Sprout<br />(b) Peas:Pod<br />(c) Potato:Eye<br />(d) Carrot:Root<br />(e) Leaf:Stem<br /><br />Ans. (a)<br /><br /><br />90. Deflect:Missile ::<br /><br />(a) Siege:Castle<br />(b) Distract:Attraction<br />(c) Protect:Honour<br />(d) Drop:Catch<br />(e) Score:Goal<br /><br />Ans. (a)<br /><br /><br />91. Editor:magazine ::<br /><br />(a) captain:ship<br />(b) actor:movie<br />(c) director:film<br />(d) player:team<br />(e) jockey:horse<br /><br />Ans. (a)<br /><br /><br />92. Volcano : Lava ::<br /><br />(a) Fault:earthquate<br />(b) crack:wall<br />(c) tunnel:dig<br />(d) water:swim<br />(e) floor:polish<br /><br />Ans. (a)<br /><br />93. Disregarded<br />(a) heed<br />(b) hopeful<br />(c) evade<br />(d) dense<br />Ans. (a)<br />94. Obviate<br />(a) becloud<br />(b) necessitate<br />(c) rationalize<br />(d) execute<br />Ans. (b)<br /><br />95. Superficial<br />(a) profound<br />(b) exaggerated<br />(c) subjective<br />(d) spirited<br />Ans. (a)<br />96. chief : tribe :: governer : state<br /><br />97. epaulette : shoulder :: tiara : head<br /><br />98. guttural : throat :: gastric : stomach<br /><br />99. inept : clever :: languid : active<br /><br />100. Erudite : scholar :: illiterate : ignorantSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-15587846043978690832008-07-25T10:56:00.001-07:002008-12-23T04:01:37.823-08:00RDBMS Concepts1. What is database?<br />A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose.<br /><br />2. What is DBMS?<br />It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications.<br /><br />3. What is a Database system?<br />The database and DBMS software together is called as Database system.<br /><br />4. Advantages of DBMS?<br />Ø Redundancy is controlled.<br />Ø Unauthorised access is restricted.<br />Ø Providing multiple user interfaces.<br />Ø Enforcing integrity constraints.<br />Ø Providing backup and recovery.<br /><br />5. Disadvantage in File Processing System?<br />Ø Data redundancy & inconsistency.<br />Ø Difficult in accessing data.<br />Ø Data isolation.<br />Ø Data integrity.<br />Ø Concurrent access is not possible.<br />Ø Security Problems.<br /><br />6. Describe the three levels of data abstraction?<br />The are three levels of abstraction:<br />Ø Physical level: The lowest level of abstraction describes how data are stored.<br />Ø Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data. <br />Ø View level: The highest level of abstraction describes only part of entire database.<br /><br />7. Define the "integrity rules"<br />There are two Integrity rules.<br />Ø Entity Integrity: States that "Primary key cannot have NULL value"<br />Ø Referential Integrity: States that "Foreign Key can be either a NULL value or should be Primary Key value of other relation.<br /><br />8. What is extension and intension?<br />Extension -<br />It is the number of tuples present in a table at any instance. This is time dependent.<br />Intension -<br />It is a constant value that gives the name, structure of table and the constraints laid on it.<br /><br />9. What is System R? What are its two major subsystems?<br />System R was designed and developed over a period of 1974-79 at IBM San Jose Research Center. It is a prototype and its purpose was to demonstrate that it is possible to build a Relational System that can be used in a real life environment to solve real life problems, with performance at least comparable to that of existing system.<br />Its two subsystems are<br />Ø Research Storage<br />Ø System Relational Data System.<br /><br />10. How is the data structure of System R different from the relational structure?<br />Unlike Relational systems in System R<br />Ø Domains are not supported<br />Ø Enforcement of candidate key uniqueness is optional<br />Ø Enforcement of entity integrity is optional<br />Ø Referential integrity is not enforced<br /><br />11. What is Data Independence?<br /> Data independence means that "the application is independent of the storage structure and access strategy of data". In other words, The ability to modify the schema definition in one level should not affect the schema definition in the next higher level.<br />Two types of Data Independence:<br />Ø Physical Data Independence: Modification in physical level should not affect the logical level. <br />Ø Logical Data Independence: Modification in logical level should affect the view level. <br /> NOTE: Logical Data Independence is more difficult to achieve<br /><br />12. What is a view? How it is related to data independence?<br />A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words, there is no stored file that direct represents the view instead a definition of view is stored in data dictionary.<br />Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users from the effects of restructuring and growth in the database. Hence accounts for logical data independence.<br /><br />13. What is Data Model?<br /> A collection of conceptual tools for describing data, data relationships data semantics and constraints.<br /><br />14. What is E-R model?<br />This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes.<br /><br />15. What is Object Oriented model?<br />This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes.<br /><br />16. What is an Entity?<br />It is a 'thing' in the real world with an independent existence.<br /><br />17. What is an Entity type?<br />It is a collection (set) of entities that have same attributes.<br /><br />18. What is an Entity set?<br />It is a collection of all entities of particular entity type in the database.<br /><br />19. What is an Extension of entity type?<br />The collections of entities of a particular entity type are grouped together into an entity set.<br /><br />20. What is Weak Entity set?<br />An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set.<br /><br />21. What is an attribute?<br />It is a particular property, which describes the entity.<br /><br />22. What is a Relation Schema and a Relation?<br />A relation Schema denoted by R(A1, A2, …, An) is made up of the relation name R and the list of attributes Ai that it contains. A relation is defined as a set of tuples. Let r be the relation which contains set tuples (t1, t2, t3, ..., tn). Each tuple is an ordered list of n-values t=(v1,v2, ..., vn).<br /><br />23. What is degree of a Relation?<br />It is the number of attribute of its relation schema.<br /><br />24. What is Relationship?<br />It is an association among two or more entities.<br /><br />25. What is Relationship set?<br />The collection (or set) of similar relationships.<br /><br />26. What is Relationship type? <br />Relationship type defines a set of associations or a relationship set among a given set of entity types. <br /><br />27. What is degree of Relationship type?<br />It is the number of entity type participating.<br /><br />25. What is DDL (Data Definition Language)?<br />A data base schema is specifies by a set of definitions expressed by a special language called DDL.<br /><br />26. What is VDL (View Definition Language)?<br />It specifies user views and their mappings to the conceptual schema.<br /><br />27. What is SDL (Storage Definition Language)?<br />This language is to specify the internal schema. This language may specify the mapping between two schemas.<br /><br />28. What is Data Storage - Definition Language?<br />The storage structures and access methods used by database system are specified by a set of definition in a special type of DDL called data storage-definition language.<br /><br />29. What is DML (Data Manipulation Language)?<br />This language that enable user to access or manipulate data as organised by appropriate data model.<br />Ø Procedural DML or Low level: DML requires a user to specify what data are needed and how to get those data.<br />Ø Non-Procedural DML or High level: DML requires a user to specify what data are needed without specifying how to get those data.<br /><br />31. What is DML Compiler?<br />It translates DML statements in a query language into low-level instruction that the query evaluation engine can understand.<br /><br />32. What is Query evaluation engine?<br />It executes low-level instruction generated by compiler.<br /><br />33. What is DDL Interpreter?<br />It interprets DDL statements and record them in tables containing metadata.<br /><br />34. What is Record-at-a-time?<br />The Low level or Procedural DML can specify and retrieve each record from a set of records. This retrieve of a record is said to be Record-at-a-time.<br /><br />35. What is Set-at-a-time or Set-oriented?<br />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.<br /><br />36. What is Relational Algebra?<br />It is procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation.<br /><br />37. What is Relational Calculus?<br />It is an applied predicate calculus specifically tailored for relational databases proposed by E.F. Codd. E.g. of languages based on it are DSL ALPHA, QUEL.<br /><br />38. How does Tuple-oriented relational calculus differ from domain-oriented relational calculus<br />The tuple-oriented calculus uses a tuple variables i.e., variable whose only permitted values are tuples of that relation. E.g. QUEL<br />The domain-oriented calculus has domain variables i.e., variables that range over the underlying domains instead of over relation. E.g. ILL, DEDUCE.<br /><br />39. What is normalization?<br />It is a process of analysing the given relation schemas based on their Functional Dependencies (FDs) and primary key to achieve the properties<br />Ø Minimizing redundancy<br />Ø Minimizing insertion, deletion and update anomalies. <br /><br />40. What is Functional Dependency? <br />A Functional dependency is denoted by X Y between two sets of attributes X and Y that are subsets of R specifies a constraint on the possible tuple that can form a relation state r of R. The constraint is for any two tuples t1 and t2 in r if t1[X] = t2[X] then they have t1[Y] = t2[Y]. This means the value of X component of a tuple uniquely determines the value of component Y.<br /><br />41. When is a functional dependency F said to be minimal?<br />Ø Every dependency in F has a single attribute for its right hand side.<br />Ø We cannot replace any dependency X A in F with a dependency Y A where Y is a proper subset of X and still have a set of dependency that is equivalent to F.<br />Ø We cannot remove any dependency from F and still have set of dependency that is equivalent to F.<br /><br />42. What is Multivalued dependency?<br />Multivalued dependency denoted by X Y specified on relation schema R, where X and Y are both subsets of R, specifies the following constraint on any relation r of R: if two tuples t1 and t2 exist in r such that t1[X] = t2[X] then t3 and t4 should also exist in r with the following properties<br />Ø t3[x] = t4[X] = t1[X] = t2[X]<br />Ø t3[Y] = t1[Y] and t4[Y] = t2[Y]<br />Ø t3[Z] = t2[Z] and t4[Z] = t1[Z] <br />where [Z = (R-(X U Y)) ]<br /> <br />43. What is Lossless join property?<br />It guarantees that the spurious tuple generation does not occur with respect to relation schemas after decomposition.<br /><br />44. What is 1 NF (Normal Form)?<br />The domain of attribute must include only atomic (simple, indivisible) values.<br /><br />45. What is Fully Functional dependency?<br />It is based on concept of full functional dependency. A functional dependency X Y is full functional dependency if removal of any attribute A from X means that the dependency does not hold any more.<br /><br />46. What is 2NF?<br />A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally dependent on primary key.<br /><br />47. What is 3NF?<br />A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following is true<br />Ø X is a Super-key of R.<br />Ø A is a prime attribute of R.<br />In other words, if every non prime attribute is non-transitively dependent on primary key.<br /><br />48. What is BCNF (Boyce-Codd Normal Form)?<br /> A relation schema R is in BCNF if it is in 3NF and satisfies an additional constraint that for every FD X A, X must be a candidate key.<br /> <br />49. What is 4NF?<br />A relation schema R is said to be in 4NF if for every Multivalued dependency X Y that holds over R, one of following is true<br />Ø X is subset or equal to (or) XY = R.<br />Ø X is a super key.<br /><br />50. What is 5NF?<br />A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ..., Rn} that holds R, one the following is true<br />Ø Ri = R for some i.<br />Ø The join dependency is implied by the set of FD, over R in which the left side is key of R. <br /><br />51. What is Domain-Key Normal Form?<br />A relation is said to be in DKNF if all constraints and dependencies that should hold on the the constraint can be enforced by simply enforcing the domain constraint and key constraint on the relation.<br /><br />52. What are partial, alternate,, artificial, compound and natural key?<br />Partial Key:<br />It is a set of attributes that can uniquely identify weak entities and that are related to same owner entity. It is sometime called as Discriminator.<br /><br />Alternate Key:<br /> All Candidate Keys excluding the Primary Key are known as Alternate Keys.<br /><br />Artificial Key:<br /> If no obvious key, either stand alone or compound is available, then the last resort is to simply create a key, by assigning a unique number to each record or occurrence. Then this is known as developing an artificial key.<br /> Compound Key:<br /> If no single data element uniquely identifies occurrences within a construct, then combining multiple elements to create a unique identifier for the construct is known as creating a compound key.<br /> Natural Key:<br /> When one of the data elements stored within a construct is utilized as the primary key, then it is called the natural key.<br /><br />53. What is indexing and what are the different kinds of indexing?<br />Indexing is a technique for determining how quickly specific data can be found.<br />Types:<br />Ø Binary search style indexing<br />Ø B-Tree indexing<br />Ø Inverted list indexing<br />Ø Memory resident table<br />Ø Table indexing<br /><br />54. What is system catalog or catalog relation? How is better known as?<br />A RDBMS maintains a description of all the data that it contains, information about every relation and index that it contains. This information is stored in a collection of relations maintained by the system called metadata. It is also called data dictionary.<br /><br />55. What is meant by query optimization?<br />The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as query optimization.<br /><br />56. What is join dependency and inclusion dependency?<br />Join Dependency:<br /> A Join dependency is generalization of Multivalued dependency.A JD {R1, R2, ..., Rn} is said to hold over a relation R if R1, R2, R3, ..., Rn is a lossless-join decomposition of R . There is no set of sound and complete inference rules for JD.<br /> Inclusion Dependency:<br /> An Inclusion Dependency is a statement of the form that some columns of a relation are contained in other columns. A foreign key constraint is an example of inclusion dependency.<br /><br />57. What is durability in DBMS?<br />Once the DBMS informs the user that a transaction has successfully completed, its effects should persist even if the system crashes before all its changes are reflected on disk. This property is called durability.<br /><br />58. What do you mean by atomicity and aggregation?<br />Atomicity:<br />Either all actions are carried out or none are. Users should not have to worry about the effect of incomplete transactions. DBMS ensures this by undoing the actions of incomplete transactions.<br /> Aggregation:<br /> A concept which is used to model a relationship between a collection of entities and relationships. It is used when we need to express a relationship among relationships.<br /><br />59. What is a Phantom Deadlock?<br />In distributed deadlock detection, the delay in propagating local information might cause the deadlock detection algorithms to identify deadlocks that do not really exist. Such situations are called phantom deadlocks and they lead to unnecessary aborts.<br /><br />60. What is a checkpoint and When does it occur?<br />A Checkpoint is like a snapshot of the DBMS state. By taking checkpoints, the DBMS can reduce the amount of work to be done during restart in the event of subsequent crashes.<br /><br />61. What are the different phases of transaction?<br />Different phases are<br />Ø Analysis phase<br />Ø Redo Phase<br />Ø Undo phase<br /><br />62. What do you mean by flat file database?<br />It is a database in which there are no programs or user access languages. It has no cross-file capabilities but is user-friendly and provides user-interface management.<br /><br />63. What is "transparent DBMS"?<br />It is one, which keeps its Physical Structure hidden from user.<br /><br />64. Brief theory of Network, Hierarchical schemas and their properties<br />Network schema uses a graph data structure to organize records example for such a database management system is CTCG while a hierarchical schema uses a tree data structure example for such a system is IMS.<br /><br />65. What is a query?<br /> A query with respect to DBMS relates to user commands that are used to interact with a data base. The query language can be classified into data definition language and data manipulation language.<br /><br />66. What do you mean by Correlated subquery?<br /> Subqueries, or nested queries, are used to bring back a set of rows to be used by the parent query. Depending on how the subquery is written, it can be executed once for the parent query or it can be executed once for each row returned by the parent query. If the subquery is executed for each row of the parent, this is called a correlated subquery.<br />A correlated subquery can be easily identified if it contains any references to the parent subquery columns in its WHERE clause. Columns from the subquery cannot be referenced anywhere else in the parent query. The following example demonstrates a non-correlated subquery.<br /> E.g. Select * From CUST Where '10/03/1990' IN (Select ODATE From ORDER Where CUST.CNUM = ORDER.CNUM)<br /><br />67. What are the primitive operations common to all record management systems?<br />Addition, deletion and modification.<br /><br />68. Name the buffer in which all the commands that are typed in are stored<br /> 'Edit' Buffer<br /><br />69. What are the unary operations in Relational Algebra?<br /> PROJECTION and SELECTION.<br /><br />70. Are the resulting relations of PRODUCT and JOIN operation the same?<br /> No.<br /> PRODUCT: Concatenation of every row in one relation with every row in another.<br /> JOIN: Concatenation of rows from one relation and related rows from another.<br /><br />71. What is RDBMS KERNEL?<br /> Two important pieces of RDBMS architecture are the kernel, which is the software, and the data dictionary, which consists of the system-level data structures used by the kernel to manage the database<br /> You might think of an RDBMS as an operating system (or set of subsystems), designed specifically for controlling data access; its primary functions are storing, retrieving, and securing data. An RDBMS maintains its own list of authorized users and their associated privileges; manages memory caches and paging; controls locking for concurrent resource usage; dispatches and schedules user requests; and manages space usage within its table-space structures<br />.<br />72. Name the sub-systems of a RDBMS<br /> I/O, Security, Language Processing, Process Control, Storage Management, Logging and Recovery, Distribution Control, Transaction Control, Memory Management, Lock Management<br /><br />73. Which part of the RDBMS takes care of the data dictionary? How<br /> Data dictionary is a set of tables and database objects that is stored in a special area of the database and maintained exclusively by the kernel.<br /><br />74. What is the job of the information stored in data-dictionary?<br /> The information in the data dictionary validates the existence of the objects, provides access to them, and maps the actual physical storage location.<br /><br />75. Not only RDBMS takes care of locating data it also<br /> determines an optimal access path to store or retrieve the data<br /><br />76. How do you communicate with an RDBMS?<br /> You communicate with an RDBMS using Structured Query Language (SQL)<br /><br />77. Define SQL and state the differences between SQL and other conventional programming Languages<br />SQL is a nonprocedural language that is designed specifically for data access operations on normalized relational database structures. The primary difference between SQL and other conventional programming languages is that SQL statements specify what data operations should be performed rather than how to perform them.<br /><br />78. Name the three major set of files on disk that compose a database in Oracle<br />There are three major sets of files on disk that compose a database. All the files are binary. These are<br />Ø Database files<br />Ø Control files<br />Ø Redo logs<br />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.<br />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.<br /><br />79. What is an Oracle Instance?<br />The Oracle system processes, also known as Oracle background processes, provide functions for the user processes-functions that would otherwise be done by the user processes themselves<br />Oracle database-wide system memory is known as the SGA, the system global area or shared global area. The data and control structures in the SGA are shareable, and all the Oracle background processes and user processes can use them.<br />The combination of the SGA and the Oracle background processes is known as an Oracle instance<br /><br />80. What are the four Oracle system processes that must always be up and running for the database to be useable<br /> The four Oracle system processes that must always be up and running for the database to be useable include DBWR (Database Writer), LGWR (Log Writer), SMON (System Monitor), and PMON (Process Monitor).<br /><br />81. What are database files, control files and log files. How many of these files should a database have at least? Why?<br />Database Files<br />The database files hold the actual data and are typically the largest in size. Depending on their sizes, the tables (and other objects) for all the user accounts can go in one database file-but that's not an ideal situation because it does not make the database structure very flexible for controlling access to storage for different users, putting the database on different disk drives, or backing up and restoring just part of the database.<br />You must have at least one database file but usually, more than one files are used. In terms of accessing and using the data in the tables and other objects, the number (or location) of the files is immaterial.<br />The database files are fixed in size and never grow bigger than the size at which they were created<br />Control Files<br />The control files and redo logs support the rest of the architecture. Any database must have at least one control file, although you typically have more than one to guard against loss. The control file records the name of the database, the date and time it was created, the location of the database and redo logs, and the synchronization information to ensure that all three sets of files are always in step. Every time you add a new database or redo log file to the database, the information is recorded in the control files.<br />Redo Logs<br />Any database must have at least two redo logs. These are the journals for the database; the redo logs record all changes to the user objects or system objects. If any type of failure occurs, the changes recorded in the redo logs can be used to bring the database to a consistent state without losing any committed transactions. In the case of non-data loss failure, Oracle can apply the information in the redo logs automatically without intervention from the DBA.<br />The redo log files are fixed in size and never grow dynamically from the size at which they were created.<br /><br />82. What is ROWID?<br /> The ROWID is a unique database-wide physical address for every row on every table. Once assigned (when the row is first inserted into the database), it never changes until the row is deleted or the table is dropped.<br />The ROWID consists of the following three components, the combination of which uniquely identifies the physical storage location of the row.<br />Ø Oracle database file number, which contains the block with the rows<br />Ø Oracle block address, which contains the row<br />Ø The row within the block (because each block can hold many rows)<br />The ROWID is used internally in indexes as a quick means of retrieving rows with a particular key value. Application developers also use it in SQL statements as a quick way to access a row once they know the ROWID<br /><br />83. What is Oracle Block? Can two Oracle Blocks have the same address?<br /> Oracle "formats" the database files into a number of Oracle blocks when they are first created-making it easier for the RDBMS software to manage the files and easier to read data into the memory areas.<br />The block size should be a multiple of the operating system block size. Regardless of the block size, the entire block is not available for holding data; Oracle takes up some space to manage the contents of the block. This block header has a minimum size, but it can grow.<br />These Oracle blocks are the smallest unit of storage. Increasing the Oracle block size can improve performance, but it should be done only when the database is first created.<br />Each Oracle block is numbered sequentially for each database file starting at 1. Two blocks can have the same block address if they are in different database files.<br /><br />84. What is database Trigger?<br /> A database trigger is a PL/SQL block that can defined to automatically execute for insert, update, and delete statements against a table. The trigger can e defined to execute once for the entire statement or once for every row that is inserted, updated, or deleted. For any one table, there are twelve events for which you can define database triggers. A database trigger can call database procedures that are also written in PL/SQL.<br /><br />85. Name two utilities that Oracle provides, which are use for backup and recovery.<br /> Along with the RDBMS software, Oracle provides two utilities that you can use to back up and restore the database. These utilities are Export and Import.<br />The Export utility dumps the definitions and data for the specified part of the database to an operating system binary file. The Import utility reads the file produced by an export, recreates the definitions of objects, and inserts the data<br />If Export and Import are used as a means of backing up and recovering the database, all the changes made to the database cannot be recovered since the export was performed. The best you can do is recover the database to the time when the export was last performed.<br /><br />86. What are stored-procedures? And what are the advantages of using them.<br />Stored procedures are database objects that perform a user defined operation. A stored procedure can have a set of compound SQL statements. A stored procedure executes the SQL commands and returns the result to the client. Stored procedures are used to reduce network traffic.<br /><br />87. How are exceptions handled in PL/SQL? Give some of the internal exceptions' name<br /> PL/SQL exception handling is a mechanism for dealing with run-time errors encountered during procedure execution. Use of this mechanism enables execution to continue if the error is not severe enough to cause procedure termination.<br />The exception handler must be defined within a subprogram specification. Errors cause the program to raise an exception with a transfer of control to the exception-handler block. After the exception handler executes, control returns to the block in which the handler was defined. If there are no more executable statements in the block, control returns to the caller.<br />User-Defined Exceptions<br />PL/SQL enables the user to define exception handlers in the declarations area of subprogram specifications. User accomplishes this by naming an exception as in the following example:<br /> ot_failure EXCEPTION;<br />In this case, the exception name is ot_failure. Code associated with this handler is written in the EXCEPTION specification area as follows:<br />EXCEPTION<br /> when OT_FAILURE then<br /> out_status_code := g_out_status_code;<br /> out_msg := g_out_msg;<br />The following is an example of a subprogram exception:<br />EXCEPTION<br /> when NO_DATA_FOUND then<br /> g_out_status_code := 'FAIL';<br /> RAISE ot_failure;<br />Within this exception is the RAISE statement that transfers control back to the ot_failure exception handler. This technique of raising the exception is used to invoke all user-defined exceptions.<br />System-Defined Exceptions<br />Exceptions internal to PL/SQL are raised automatically upon error. NO_DATA_FOUND is a system-defined exception. Table below gives a complete list of internal exceptions.<br /><br />PL/SQL internal exceptions.<br /><br />Exception Name Oracle Error<br /><br />CURSOR_ALREADY_OPEN ORA-06511<br />DUP_VAL_ON_INDEX ORA-00001<br />INVALID_CURSOR ORA-01001<br />INVALID_NUMBER ORA-01722<br />LOGIN_DENIED ORA-01017<br />NO_DATA_FOUND ORA-01403<br />NOT_LOGGED_ON ORA-01012<br />PROGRAM_ERROR ORA-06501<br />STORAGE_ERROR ORA-06500<br />TIMEOUT_ON_RESOURCE ORA-00051<br />TOO_MANY_ROWS ORA-01422<br />TRANSACTION_BACKED_OUT ORA-00061<br />VALUE_ERROR ORA-06502<br />ZERO_DIVIDE ORA-01476<br /><br />In addition to this list of exceptions, there is a catch-all exception named OTHERS that traps all errors for which specific error handling has not been established.<br /><br />88. Does PL/SQL support "overloading"? Explain<br /> The concept of overloading in PL/SQL relates to the idea that you can define procedures and functions with the same name. PL/SQL does not look only at the referenced name, however, to resolve a procedure or function call. The count and data types of formal parameters are also considered.<br />PL/SQL also attempts to resolve any procedure or function calls in locally defined packages before looking at globally defined packages or internal functions. To further ensure calling the proper procedure, you can use the dot notation. Prefacing a procedure or function name with the package name fully qualifies any procedure or function reference.<br /><br />89. Tables derived from the ERD<br /> a) Are totally unnormalised<br /> b) Are always in 1NF<br /> c) Can be further denormalised<br /> d) May have multi-valued attributes<br /><br /> (b) Are always in 1NF<br /><br />90. Spurious tuples may occur due to<br /> i. Bad normalization <br /> ii. Theta joins<br /> iii. Updating tables from join<br /> a) i & ii b) ii & iii<br /> c) i & iii d) ii & iii<br /><br /> (a) i & ii because theta joins are joins made on keys that are not primary keys.<br /><br />91. A B C is a set of attributes. The functional dependency is as follows<br /> AB -> B<br /> AC -> C<br /> C -> B<br /> a) is in 1NF<br /> b) is in 2NF<br /> c) is in 3NF<br /> d) is in BCNF<br /><br /> (a) is in 1NF since (AC)+ = { A, B, C} hence AC is the primary key. Since C B is a FD given, where neither C is a Key nor B is a prime attribute, this it is not in 3NF. Further B is not functionally dependent on key AC thus it is not in 2NF. Thus the given FDs is in 1NF.<br /><br />92. In mapping of ERD to DFD<br /> a) entities in ERD should correspond to an existing entity/store in DFD<br /> b) entity in DFD is converted to attributes of an entity in ERD<br /> c) relations in ERD has 1 to 1 correspondence to processes in DFD<br /> d) relationships in ERD has 1 to 1 correspondence to flows in DFD<br /><br /> (a) entities in ERD should correspond to an existing entity/store in DFD<br /><br />93. A dominant entity is the entity<br /> a) on the N side in a 1 : N relationship<br /> b) on the 1 side in a 1 : N relationship<br /> c) on either side in a 1 : 1 relationship<br /> d) nothing to do with 1 : 1 or 1 : N relationship<br /><br />(b) on the 1 side in a 1 : N relationship<br /><br />94. Select 'NORTH', CUSTOMER From CUST_DTLS Where REGION = 'N' Order By<br />CUSTOMER Union Select 'EAST', CUSTOMER From CUST_DTLS Where REGION = 'E' Order By CUSTOMER<br />The above is<br /> a) Not an error<br /> b) Error - the string in single quotes 'NORTH' and 'SOUTH'<br /> c) Error - the string should be in double quotes<br /> d) Error - ORDER BY clause<br /><br />(d) Error - the ORDER BY clause. Since ORDER BY clause cannot be used in UNIONS<br /><br />95. What is Storage Manager? <br />It is a program module that provides the interface between the low-level data stored in database, application programs and queries submitted to the system. <br /> <br />96. What is Buffer Manager?<br />It is a program module, which is responsible for fetching data from disk storage into main memory and deciding what data to be cache in memory. <br /><br />97. What is Transaction Manager?<br />It is a program module, which ensures that database, remains in a consistent state despite system failures and concurrent transaction execution proceeds without conflicting.<br /><br />98. What is File Manager?<br />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. <br /><br />99. What is Authorization and Integrity manager?<br />It is the program module, which tests for the satisfaction of integrity constraint and checks the authority of user to access data. <br /><br />100. What are stand-alone procedures?<br />Procedures that are not part of a package are known as stand-alone because they independently defined. A good example of a stand-alone procedure is one written in a SQL*Forms application. These types of procedures are not available for reference from other Oracle tools. Another limitation of stand-alone procedures is that they are compiled at run time, which slows execution.<br /><br />101. What are cursors give different types of cursors.<br />PL/SQL uses cursors for all database information accesses statements. The language supports the use two types of cursors<br />Ø Implicit<br />Ø Explicit<br /><br />102. What is cold backup and hot backup (in case of Oracle)?<br />Ø Cold Backup:<br />It is copying the three sets of files (database files, redo logs, and control file) when the instance is shut down. This is a straight file copy, usually from the disk directly to tape. You must shut down the instance to guarantee a consistent copy.<br />If a cold backup is performed, the only option available in the event of data file loss is restoring all the files from the latest backup. All work performed on the database since the last backup is lost.<br />Ø Hot Backup:<br />Some sites (such as worldwide airline reservations systems) cannot shut down the database while making a backup copy of the files. The cold backup is not an available option.<br />So different means of backing up database must be used - the hot backup. Issue a SQL command to indicate to Oracle, on a tablespace-by-tablespace basis, that the files of the tablespace are to backed up. The users can continue to make full use of the files, including making changes to the data. Once the user has indicated that he/she wants to back up the tablespace files, he/she can use the operating system to copy those files to the desired backup destination.<br />The database must be running in ARCHIVELOG mode for the hot backup option.<br />If a data loss failure does occur, the lost database files can be restored using the hot backup and the online and offline redo logs created since the backup was done. The database is restored to the most consistent state without any loss of committed transactions.<br /><br />103. What are Armstrong rules? How do we say that they are complete and/or sound<br />The well-known inference rules for FDs <br />Ø Reflexive rule : <br /> If Y is subset or equal to X then X Y.<br />Ø Augmentation rule:<br /> If X Y then XZ YZ.<br />Ø Transitive rule:<br /> If {X Y, Y Z} then X Z.<br />Ø Decomposition rule :<br /> If X YZ then X Y.<br />Ø Union or Additive rule:<br /> If {X Y, X Z} then X YZ.<br />Ø Pseudo Transitive rule :<br /> If {X Y, WY Z} then WX Z.<br /> Of these the first three are known as Amstrong Rules. They are sound because it is enough if a set of FDs satisfy these three. They are called complete because using these three rules we can generate the rest all inference rules.<br /><br />104. How can you find the minimal key of relational schema?<br />Minimal key is one which can identify each tuple of the given relation schema uniquely. For finding the minimal key it is required to find the closure that is the set of all attributes that are dependent on any given set of attributes under the given set of functional dependency.<br /> Algo. I Determining X+, closure for X, given set of FDs F<br />1. Set X+ = X<br />2. Set Old X+ = X+<br />3. For each FD Y Z in F and if Y belongs to X+ then add Z to X+<br />4. Repeat steps 2 and 3 until Old X+ = X+<br /><br />Algo.II Determining minimal K for relation schema R, given set of FDs F<br />1. Set K to R that is make K a set of all attributes in R<br />2. For each attribute A in K<br />a. Compute (K - A)+ with respect to F<br />b. If (K - A)+ = R then set K = (K - A)+<br /><br /><br />105. What do you understand by dependency preservation?<br />Given a relation R and a set of FDs F, dependency preservation states that the closure of the union of the projection of F on each decomposed relation Ri is equal to the closure of F. i.e.,<br />((PR1(F)) U … U (PRn(F)))+ = F+<br /> if decomposition is not dependency preserving, then some dependency is lost in the decomposition.<br /><br />106. What is meant by Proactive, Retroactive and Simultaneous Update.<br />Proactive Update:<br /> The updates that are applied to database before it becomes effective in real world .<br />Retroactive Update:<br /> The updates that are applied to database after it becomes effective in real world .<br />Simulatneous Update:<br /> The updates that are applied to database at the same time when it becomes effective in real world .<br /><br />107. What are the different types of JOIN operations?<br />Equi Join: This is the most common type of join which involves only equality comparisions. The disadvantage in this type of join is that thereSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-50738535613486889552008-07-25T10:54:00.001-07:002008-12-23T04:01:37.823-08:00Interview GuideINTRODUCTION<br /> <br /><br /> " Given with all the facilities would you like to work in a team or as an individual?"<br /> "Sir... as.... an individual"<br /> This was my answer when Infosys HR manager had asked me in my first interview. It's not unlikely that you don't do such mistakes in your initial interviews and loose the golden chances. Initially I didn't have even a rough idea about how the campus interviews are conducted, what they require, what to prepare, how to face etc. Those were my series of debacles, which taught me the finer tunes of the interviews. It took me around 10 interviews to finally cross the hurdle. I tell you 10 is a very big number.<br /> I only want that a capable candidate should not suffer because of his ignorance. I don’t want others to follow the series of failures as I underwent. Keeping this point in mind, I have tried to show the inner views of the campus interviews, which are also generalized for walk in interviews. I have tried to portray my experiences, my approaches and the steps that I think are apt for one to succeed.<br /> Here my aim is not just restricted for the people to know only about interviews, but also to aim at improving ones overall personality.<br /> My special thanks to Mr. Syed Salahudddin who encouraged me consistently to take up the project and worked parallely with me to finish this. I owe a great deal to the officer.<br /> I thank all my classmates and hostel mates esp. Mushtaq, Majid, Sawood and Nishant who stood by me and gave their full support and help.<br /> I request you to take these things seriously and read every time before you go for any interview. I also want this material to be forwarded to the people who could get benefited. These are just the views of one person, which might be wrongly interpreted also. So I want you to meet experienced people and try to generalize the things. I wish all the best for your endeavours. Thank you.<br /><br />Sajid Ali Kalmani<br /> <br /><br /><br /><br /> 1. SKILLS<br /><br />There are basically three skills, which are necessarily required to succeed in the interviews.<br />They are:<br />1. Aptitude<br />2. Communication skills<br />3. Technical skills<br />4. Attitude/Personality-this is transparent to candidates.<br />(Candidates can lack one or more skills if they want the job by some shortcut means, but those who want the job fair and square, must possess all the above skills. You know what I mean). Let me consider myself a common man and tell you how I improved my skills. Then you can generalize them better.<br /><br />1.1 APTITUDE<br /><br />This is the first and most important step in climbing the success ladder. What’s aptitude? It’s ones ability to…, to…, leave it, I am not getting the definition. But let me tell you, aptitude is nothing but the combination of your basics, brain power, knowledge, commonsense, speed, accuracy, intelligent guessing, anticipation, decision-making and above all the positive approach. Aptitude test is like a 100 metre sprint with the lane width of just 6 inches. Overall, aptitude is your logic. Sometimes it is difficult and sometimes easy (Kabhi Kashi Kabhie Rome).<br />Some have aptitude by birth (they are natural puzzle solvers). They can easily catch up how to solve numericals and analytical problems. They need to identify themselves and polish their approach. Others have to work like dogs.<br />It took interest in puzzles when I was in 8th standard. That made me learn maths basics well. Maths Olympiad training and exam made me go for puzzles with mathematical approach. My craze for puzzles continued to PU and till B.E. In 1st semester I became the member of mathemagic magazine, which publishes varieties of puzzles from literature to numericals to chess puzzles etc. I seriously involved in solving them and sending answers to the editor. It was only in the second year that I heard that there is a company Infosys that asks only puzzles to recruit its employees. My happiness knew no bounds [patient keliddu mosaru anna, doctor heliddoo mosaru anna].<br />I wrote the aptitude test for over 15 companies and I don’t know the disappointment of not getting short-listed after the written test. Frankly speaking I never prepared for aptitude tests. That’s why I was seen playing cricket throughout my engineering. So I request you, not to look at me and decide that written tests are nothing. I had a friend who had 78% of aggregate and was good at everything but couldn’t clear written test for 15 companies. At last he cleared somehow and further path was easy for him to sail through. Let me tell you how you could improve your aptitude.<br /> First & second year students can go for puzzles. Buy puzzle books like Shakuntala Devi, George Summers, Narula etc. and try to solve them. If you don’t get the answer, then see carefully the way the puzzle has been solved in the book. If you solve some 200 and odd puzzles then you imbibe the approach to solve any puzzle. This improves your analytical ability. Then you can switch over to numerals. Many companies ask verbal questions, for that you need not mug up the dictionary or thesaurus. You can read different books, novels, and magazines and learn words steadily.<br /> For final year student going for puzzles is optional. It’s better to go for quantitative aptitude book. Agarwal is the best one. Read the solved problems and once you understand them, solve the unsolved ones. For verbal, comprehension and analytical questions you can go for Barron’s GRE or any other good book.<br /> This preparation for aptitude is must for any engineer appearing the written test for almost any company.<br /> The two things that make you succeed in the interview are preparation and confidence.<br />Preparation + Confidence = Success ---------------------- (1)<br />After good preparation confidence comes automatically which makes you perform well. So confidence ~ Preparation<br />So from--- (1)<br />Preparation + Preparation = Success<br /> Preparation = Success<br /> 2<br />This implies that if you prepare well, you are already half succeeded.<br /> This was the mistake that I repeated several times. I didn’t prepare well for the interview,( esp. technical skills ) and thought that somehow by luck I might get into but by the time I realized that there is nothing called luck, I had carried my file nearly a deca-times.<br />After preparation how to smash written test will be dealt later.<br /> Those who intend to copy in the written test should be careful, as some companies ask you to explain how you arrived at the answer, especially puzzles.<br /><br /><br /><br />1.2 COMMUNICATION SKILLS<br /><br /> In campus interviews, there are many people who don’t know much of technical stuff, but by clearing the written, somehow they get into the company by campus interview. It is because they speak great English. I don’t think it’s much different in walk–in interviews. Having good communication skills is an art, which can be mastered by any one. The efficient and flexible person learns it faster. The English you speak should be error free, fluent and clear. It need not be fast. You should be able to convey yourself well before the interviewer.<br /> I know speaking good English is a problem for many engineering guys; it’s a myth that only English medium guys speak good English. It’s also a myth that they don’t rise above a certain level. But I deny that. I studied my primary level in Kannada medium. But I don’t think I was rejected in the interviews because of my communication skills. My flexibility helped me. <br />What did I do to improve these skills?<br /> I made couple of English speaking friends at the college and used to talk to them for long hours. English movies did help too. Apart from story and action I concentrated on the accent and the way the actors used to deliver the dialogues. Giving pause and timing were very important. I used to stare at newsreaders and imagine myself reading it. I tried to read newspapers in the way they did. Sunit Tandon was really good.<br /> In home I used to tune to discussions, interviews of stars, sportsmen and follow them. Wasim Akram, Srikanth, Shahrukh Khan really inspired me. One can take a leaf out of Harsha’s commentary.<br /> These are some of the ways by which you can improve your English. You can even try other methods.<br /> Before doing any thing you can sit back and think what you have and what you lack. If your grammar is weak get a grammar book and study it from the scratch. If you can’t spell it properly go for dictionary or scripts and work on it, instead of cribbing about it for years. One should always aim at improving oneself. Always tell to yourself “Next year I will be a better person in knowledge, experience, attitude and everything.”<br /> For 8th semester guys it is better late than never, you can start now while others can learn steadily. One should enjoy learning things and not take it as a burden. <br /> Communication skills are very important for engineers and also for management students. So try to overcome your weaknesses. How do you improve is entirely left to you. It’s beyond just reading the books. It’s better start speaking English with your friends. <br /> Jamat people acquire communicating skills well, so I request them to preach in English.<br /> First and second year guys have enough time if they realize. 8th semester guys should be efficient and fast enough, learn faster and enjoy your learning. <br /> With preparation, I believe even some one like Sadiq* pasha can make it. And without preparation some one like Nayeemuddin** may not make it. Getting through the interview can be very easy if you wish.<br /> <br />* - Till 6 sem he had passed only four subjects viz., M1, M2, M3 and M4. Then he literally went mad.<br />** - Topper to MMC College, presently doing his PG course in London.<br /><br /><br />1.2 TECHNICAL SKILLS<br /><br /><br /> In the early years of engineering, students think that in interviews, hi-fi technology is asked which is very complex and difficult. So they don’t think of learning or refreshing the technical concepts keeping interview in mind. I was also one among them. But the truth is that the companies ask those technical questions which we have learnt like, what is amplifier, counter, XOR GATE, what is microprocessor, what is signal, what are pointers, data structures, what is linking, what are motors, gears etc., depending on your branch.<br /> If they ask something else you can happily say “Sir that was not there in our syllabus”. They switch over.<br /> The only difference between engineers and others is; we learn technical skills and others don’t. So if you want to call yourself an engineer see whether you have basic technical skills.<br /> So right from 3rd semester you start looking back at all the subjects you have steadied and recall their basics now and then.<br /> When you apply, you look at the pattern of interview, the area of work of the company. You can get to know on what subjects they would ask questions in interview. You can study those two, three subjects in depth, I mean in detail. You also have to just touch all the subjects superficially, esp. electives.<br /> As I said, the questions asked by companies vary based on their type (software or hardware) and your branch.<br /> For example, E&C students have to prepare technical in depth for hardware companies like Delphi, L&T, etc. But software companies don’t know much of electronics, So E&C students can relax a bit but you should know at least ‘C’ and puzzles.<br />Computer guys must prepare technically well. Usually students take their favourite subjects as DSC, Operating System, C++, etc.<br />For Mechanical boys technical skills are must. If they don’t know technical, they know nothing.<br /><br /> Mechanical – Technical = IP (Ignorant People)<br /><br /> So, most of your preparation time goes for studying technical aspects. Technical aspects means not advanced technology, but only the basics of subjects you studied as I said. The study should be thorough. I will list some of the technical questions asked often later.<br /> All most all the companies ask about your project work in detail. So study everything about all your projects. It’s better if you go through advanced technology in technical magazines and business aspects of the companies.<br /><br />‘C’<br /><br /> Those who appear for software companies must at least know one computer language. If it’s C, it’s well. So I recommend all most all students to learn ‘C’ in depth by buying different ‘C’ books; Kanitkar is good writer.<br /><br /><br />1.4 ATTITUDE/ PERSONALITY<br /><br /> Everyone has his own; in-built personality and attitude towards life. It cannot be changed so easily. If some one wants to change them or develop good personality with positive attitude, they require something that many lack. But it’s not impossible. At this stage not to make you boring, let me skip this part. It will be dealt after the interview part is revealed.<br /><br />1.5 APPLY<br /><br /> The companies that you apply are totally left to you. So before you apply you should have the rough idea about the type of company, its location, salary, bond, probable number of candidates the company requires, etc.<br /> Once you get to know the date, timing and location of the company, the first thing you should do is go to “Google” and then to the company site. Go through their recruitment section; watch out what skills they seek among you, the area in which they work etc.<br /> Then contact somebody who has been earlier interviewed by the same company, or who works in the company or who knows the test pattern of the company. Fetch out sufficient information.<br /><br /> Then sit and decide the subjects you are to prepare; like you may have to study verbal or puzzles, etc. Decide on which technical subjects you are going to prepare and start preparation thoroughly. This should be done minimum of 8 days prior to the interview.<br /> In these days study well. It’s like as if you are preparing for a war. So you should be as serious as hell. Don’t say ‘let me try my luck’. Say always ‘I can do anything and I will do it’.<br />-----------------------------------------------------------------------------------------------------------------<br /><br /><br /><br /><br /><br />2. ONE DAY PRIOR TO INTERVIEW<br /><br /><br /> This day you should keep everything ready. Your clothes, (shirt preferably plain and light, should be washed and pressed.), a pair of dark shoes, the file containing all your certificates, project reports, pen, tie etc.<br /> These all things should be kept ready even though if you are doubtful of clearing written test because many a times, I have run around like a dog in search of clothes, files, etc and because of this thing I even was late to Infosys interview.<br /><br /><br />2.1 IMAGING<br /><br /> Imaging is the most important philosophical aspect for any success. Let me explain imaging with an example.<br /> Do you think whenever Sachin scores a century it is only due to his game on the field? No! There is something which is responsible for it which is off the field.<br /> One day prior to the match Sachin imagines, sitting alone. He imagines: “Tomorrow I get up at 6 ‘O Clock. I will warm myself up for an hour, have break fast, take out my kit and go to the ground at 9 ‘O Clock. At 9:30 Saurav will go for toss, he wins it and selects fielding. I will stand at covers and field every ball that comes to me. Zaheer and Srinalth ball tidy spells. I will take a flying catch, etc. In spite of that, Ponting scores 140 runs, and the team score 359 runs.<br /> “I will open our batting. Initially I will take singles. Then I will charge McGrath. I score 50 in 15 overs. I will never go for paddle sweep, as there will be bounce for spinners. I will play aggressively. We will win and I will get man of the match award”<br /> Then next day Sachin will just repeat his images. This is called imaging techniques. Every successful person uses this. If you use this technique your confidence grows exponentially.<br /> So before you go to bed, lie down and start imaging in your mind. You go to the place, write test well, get short listed, give interview well, results announced, you are selected.<br /> More the depth you imagine more the success rate grows.<br /> I also recommend you to pray and ask the God to make you successful. Please sleep for at least 6 hours.<br /><br /><br />2.2 THE D-DAY<br /><br />Get up early & scan the news headlines, which may be asked in the interview. Don’t take tension, be calm and move around a bit quicker than usual. Wish everybody, talk louder and laugh heartily. It should seem to others that you have taken the interview so easily & lightly. But inside you should be composed, confident, fresh, alert and raring to go. Just keep saying to yourself “yes I gonna call it a day today”.<br /> Reach the centre for written test half an hour earlier.<br /><br />-----------------------------------------------------------------------------------------------------------------<br /><br /><br /><br /><br /><br />3. WRITTEN TEST----TACTICS<br /><br />My first written test was for Talisma. I was not shot listed. Afterwards I regret it because in interview they asked only puzzles (my favourite area) and the salary was 37k. Do you know why I did not clear the test? Because I had not carried my watch. Yes, you require a watch to manage the time. Sometimes you need to be as fast as a humming bird.<br /> Based on my experience I have written some tactics to crack the written test. You can follow your own methods also.<br /> If you have sufficient enough time, then you can start from the 1st question and go till last. The problem arises only when the questions are more & time is less. It’s like providing voice, data & multimedia through a narrow band.<br />1) After getting the paper it’s better to attend that section which looks easy to you. Many go for quantitative aptitude (numerical) questions. You can go for verbal at any time, but don’t spend much time on verbal because here you may have to guess a lot.<br />2) If there is –ve marking don’t guess the answers. You can guess when there is 50% chance. But I suggest don’t guess. If no –ve marks are there, tick all the questions. But beware, “some companies look at number of wrong answers too.<br /><br /><br />3.1 QUANTITATIVE<br /><br /><br />i) Here leave the tougher questions and move further.<br /><br />ii) Manage your time. Often look at the watch.<br />In PHOENIX written test, 100 questions were to be answered in 30 minutes. So each question was to be answered in 20 seconds. It so happened that the first 10 questions were lengthy (4-5 lines long) and hence took more time for reading them. I realized it sooner and skipped the lengthy questions. I moved further where there were single line easy questions. I finished them all & then came back to the lengthy ones at the end, so I ended up answering 90-95 questions, but many people who started with initial lengthy questions, took much time and ended up answering just 70-80 questions.<br />Hence plane your time properly.<br /><br />iii) Representation with figures<br /><br />As you read a problem or puzzle, you represent it with figures so that your brain can easily retain the problem for long time which makes you solve the problem quicker with faster analysis, for ex: let the question start like this, ‘A&B are couples. C is their son, D is C’s son and E is D’s wife. You can draw like <br /><br /> <br /> <br /><br />Or if the question is, A is older than E, E is older than C, D is of same age as A and so on. Then you can draw<br /> A = D > E > C<br />This representation makes you to compare or analyse the questions asked and answer fastly.<br />If they say a train of length ‘l’ and tunnel of length ‘L’, then immediately draw a rectangular tunnel and a rectangular train with horizontal intercepts as bogies; indicate the length as ‘L’.<br /><br />iv) After reading the question and after drawing their figure representations (not for all) subsequently, write down the related formula even if it is as simple as<br /> Speed = d / time<br /><br />v) If there is speed-distance problem, I suggest solving it at the end. Most of the time such questions eat up your precious time.<br /><br />vi) No company allows usage of calculators in the written test. Then how do you operate with fractions, say how do you calculate 29.11 x 41.24?<br />If you start doing it digit by digit, you will never dream of finishing the paper.<br />Here you can use some mental techniques, like instead of multiplying the fractions, it is better to approximate them to nearest integers. 29.11 can be increased to 30 and 41.24 can be reduced to 40. You should see that the amount that is increased in one number should be proportional to the value that is reduced in the other number. Then you get 30 x 40 = 120, as 29.11 x 41.24 = 120.04964<br />So you almost got the answer! If the options are 115, 120, 125, 135, you can tick for 120, while approximating even if you get around 118.5, you can tick 120.<br />If there is something like 41/7.2 then you can approximate 7.2 to 7 & correspondingly reduce the numerator to, say 40.<br /> Then you get 40/7 = 5.71 as 41/7.2 = 5.694: the approximation became almost accurate. <br /> You can master this technique when you practice this extensively. This saves your time like anything.<br /><br />vii) Use your common sense. If in a problem the height of a mountain is to be calculated and you get the answer as 15 km, you can straight away reject the answer because the highest peak in the world is only 9 km high. Then you can recalculate the problem.<br /> When I was writing for Ivega in a question about averages, they gave the ages of children, their average age etc and asked the age of the father. I calculated fast and got it as 7 years, which was ridiculous. I laughed at myself and solved it again. I got 35 years.<br /><br />viii) You should always have an eye on the options. If there are ridiculous answers, you can reject them and easily near the right answers.<br /><br />ix) Many students start solving a problem. They struggle, struggle and don’t get the answer, then decide to leave the question and go for the next one. Thus they lose 5 to 10 minutes easily. To avoid this one should anticipate the time a problem may consume. If you think some problem may consume more time, you skip it. It can always be answered at the end. Again this anticipation comes by practice.<br /><br /><br />3.2 VERBAL<br /><br />In verbal, you should always have a look at the options. If they ask the antonym of ‘beautiful’ and say you don’t know the meaning of it. You can look at the options that may read<br />1. Ugly<br />2. Smart<br />3. Handsome<br />4. Good looking<br /> In the given options, if you know that choices 2, 3 and 4 mean same thing, then you can blindly go for the first one.<br /><br /><br /><br /><br />3.3 PUZZLES<br /><br />Solving puzzles doesn’t come naturally to all. There is no particular rule to solve the puzzles, but there is an approach which can be mastered only by solving numerous puzzles. For the inexperienced ones, I suggest just three things to do while solving a puzzle i.e., just concentrate, concentrate and concentrate. If you don’t understand, read the puzzle three to four times and focus on it. Here you may lose your time in the trade off.<br />-----------------------------------------------------------------------------------------------------------------<br /><br />5. GROUP DISCUSSION<br /><br /><br />Group discussion is once again a filtering process. Here the communication ability and the ideas of a candidate are evaluated.<br /> A topic is given and 8 to 10 of you are allowed to speak on the subject for around 10 minutes. The topic of the GD is generic (simple). It may range from cricket to software industry, to Indian culture, to the future of humanity to anything, but it will be simpler. So one needs to have some kind of general awareness and needs to update with current affairs.<br /> Now how do you face it?<br />* Usually the topic is debatable, so one needs to quickly decide whether you are far or against the given topic. I suggest, try to be different in your choice the group. You are given some 2 minutes time to make points about the subject.<br />* If you initiate, you will get the advantage, but don’t initiate without ideas. It’s better to speak after two to three have spoken.<br />* Be cool and look fresh.<br />* Don’t look at the judges<br />* Speak clearly and loudly facing all. Try to anchor the group, not dominate it.<br />* Clearly explain your ideas with few weighted words. Don’t speak too much of nonsense.<br />* Don’t murmur or stammer.<br />* Don’t criticise others.<br />* Always look at the person who is speaking and nod your head so that judges will see that you are listening.<br />* If somebody is speaking more, you can say ‘you have spoken enough, let’s give chance to this person’ or ‘I agree with him’ or ‘you are going out of topic, let’s stick to the topic’<br />* Speak around 2-3 times. I mean don’t speak just once for 2 long minutes and keep quite for rest of the time, so try to speak in bursts. If somebody is listening to the discussion from outside, he should see that you are alive inside.<br />* Try to conclude yourself (if they ask to)<br /> One can practice mock GD with his friends to become familiarise with it. Actually Mandira Bedi’s group, ‘Extra Innings’ on Sony max on world cup 2003, had inspired me.<br />-----------------------------------------------------------------------------------------------------------------<br /><br />6. INTERVIEW- TECHNICAL<br /><br />Usually there are two interviews, one technical and a HR (human resources) . At this stage you are totally prepared and are confident. Let’s see how to fare in the interview.<br /> Dress neatly for the interview, preferably a light shirt with dark pants and dark shoes. You can wear a matching tie. Shave yourself cleanly, take a bath, comb your hair neatly and use a mild deodorant. Keep all your certificates, marks cards and resume in a file and carry your project reports to the interview.<br /> At the interview centre meet the guys who have finished their interview, and ask them what they were asked in the interview. Around 50% of the technical questions that were asked to them will be asked to you. So get to know the answers of those questions.<br /> Enter the interview room with a smile saying ‘may I come in sir?’ go near the chair and shake hands with the interviewer firmly. Generally oldies don’t shake hand and young interviewers prefer doing it. Sit only after they ask you to sit. Sit straight leaning backwards with legs open (don’t cross them). Give a fresh, eager, alert smiling look. Technical interviewers may not ask HR questions, but to start with, they may ask ‘ tell about yourself’, you can tell about yourself in brief (not literally). This will be dealt in HR section. Then they may ask ‘what are your favourite subjects?’ Name at least 2 to3 subjects which you have studied in depth. The questions asked will only be on basics of these subjects. They will surely ask questions about the projects you have done and electives you have mentioned in your bio-data.<br />The generally asked technical questions are:<br />Electronics and Communication<br />Analog circuits<br /> What is semiconductor diode?<br /> How does zener diode work as a voltage regulator?<br /> Explain transfer characteristics of transistor.<br /> How does a rectifier (usually bridged), RC coupled amplifier, oscillator work.<br />Digital fundamentals<br /> How to realize XOR gate using NAND gates<br /> Half adder, full adder, combinational logic.<br /> Sequential logic, flip flops, RS flip flop, synchronous and asynchronous counters.<br />Signals – op -amps<br /> what is signal?, convolution, Fourier series etc<br /> opamp, applications, filters, timers etc<br />Microprocessors<br /> architecture of 8085, 8086 and microcontrollers<br /> functions of pins, interrupts, instructions, interfacing<br /> programming simple programs<br />Communication<br /> What is AM, FM, multiplexing, TDM, FDM, receivers,<br /> What is PCM, sampling theorem, digital modulation techniques, vocoders, mobile communication (CDMA & GSM).<br /><br />Computer Science & Engineering<br />( Example FAQ in interviews)<br /><br />C, Data structures, C++ & OOPS:<br /><br />1) What is dequeue, priority queue, Dangling pointer etc.<br />2) Differentiate between Calloc & Malloc, structures & unions, *p++ & ++*p etc<br />3) What are: Polymorphism, virtual functions, encapsulation, data hiding etc<br />4) Do virtual constructors & destructors exist?<br />5) What is the memory used by an integer pointer, float pointer etc.<br />6) What are: binary tree, strictly binary tree, completely binary tree, almost complete binary tree, threaded binary tree, etc.<br />7) Conversion of expression from infix to postfix & to prefix<br />8) Evaluation of postfix and prefix expressions<br />9) Given inorder & preorder traversal or inorder & postorder traversal of a tree, build a tree. <br />10) Why prototypes are used?<br />11) What are inline functions and scope resolution<br />12) What are pre-processors? What is their use?<br />13) Which is efficient sorting algorithm? Why?<br /><br />||Note||: In most of the cases small program code is given & output is asked or to identify the error in it.<br /><br />Operating Systems:<br /><br />1) What is virtual memory? Differentiate between logical & physical memory<br />2) What are: demand paging, pure demand paging, page fault, page replacement, page replacement algorithms (LRU, Opt. FCFS etc), thrashing, paging, segmentation, external & internal fragmentation etc<br />3) Which technique does DOS (& UNIX) use? (Paging or Segmentation or both….)<br />4) What are scheduling algorithms? (FCFS, SJF, RR,…) [IBM]<br />5) Why you prefer SJF? Does it have any limitation?(ans: Starvation of longer processes) How do you over come it?( one solution is: by using priority queue with SJF)<br />6) What are semaphores and monitors?<br />7) What is critical section problem?<br />8) What is a process, BCP (Program Control Block)?<br />9) What is turnaround time, Throughput [IBM]?<br />10) What do you optimize using scheduling algorithms SJF, RR etc?<br />11) What is real time operating system, time sharing system, batch processing multiprogramming?<br />12) Differentiate Between multitasking and time-sharing system?<br />13) What is dead lock? Necessary condition<br />14) File accessing technique (direct, sequential)<br />15) File allocating techniques (contiguous, linked, indexed)<br />16) Free space management (rarely asked)<br />17) Head movement algorithms (FCFS, SHORTEST DISTANCE FIRST, SCAN,<br /> C-SCAN, LOOK, C-LOOK etc)<br /> <br /> Note: These questions on OS are asked only if you tell OS as your favourite subject.<br /><br />DBMS:<br />1) What is normalization? Why is it needed?<br />2) What are insertion, deletion, & modification anomalies?<br />3) What is first, second, or third normal forms?<br />4) Do you implement it in your project, how explain with example?<br />5) What is super key, a key, candidate key, primary key or minimal super key etc?<br />6) What is entity integrity, referential integrity etc?<br /><br />nn<br />SYETEM SOFTWARE: (rarely asked)<br />1) What is an interpreter, differentiate between compiler and interpreter? (MIND TREE)<br />2) What are assembler, linker, loader, and dynamic linker?<br />3) What are Yacc, Parsing techniques, LR, LL, LALR grammars?<br /><br /><br /><br />UNIX: (rarely asked)<br />1) Expand UNIX, who developed it, when & where?<br />2) What is file structure used in UNIX? [IBM]<br />3) Differentiate between UNIX & LINUX?<br />Some commands may be asked.<br /> <br /><br />JAVA & NETWORKING: (Rarely asked)<br />1) What is the significant feature of JAVA? (ANS: JVM JAVA virtual machine)<br />2) Difference between package, interface, classes etc?<br />3) Difference between interfaces & abstract classes?<br />4) What is class A, class B, class C, class D addresses? (CIP)<br />5) OSI & TCP (IP layer and their function may be asked)<br />6) What is routing?<br />7) Difference between routes, bridges, & gateways?<br />8) What is firewall?<br />9) Difference between UDP & TCP?<br />10) What is subnet?<br /><br /><br />Note: question on SS, UNIX, JAVA, NETWORKS, OOPS, C++ are asked only in the pure software companies or big MNC’s or dream companies or if you say it as your favourite subject.<br /><br /><br /><br /> <br /><br /><br />Mechanical related Questions<br />1) Orthographic views<br />2) Difference between I and III projection.<br />3) Difference between Otto cycles and Diesel cycles.<br />4) What are principal stress and compound stress?<br />5) State 0th, 1st, 2nd law of thermodynamics.<br />6) Explain Alumino thermite process.<br />7) Different types of welding and machining<br />8) Explain the importance of laser in modern mechanical field.<br />9) Applications of mechatronics.<br />[ I feel sorry; I couldn’t add questions from electrical, IT, civil, environmental etc. branches as minorities are always sidelined.<br /> These questions just look simple. They may grill you if your answers don’t look confident or if you try to bluff. If you don’t know, you can say ‘sir we don’t have that in our syllabus’ or ‘sir I am not remembering it’ or ‘I don’t know sir’.<br /> Maintain eye contact with the one you are speaking. While you are speaking give intermediate looks to the other interviewer. When they ask about projects you can spent more time on them, as you will be more comfortable with the projects you have done.<br /> Non-CS students who apply for software companies, should say, they at least know one programming language, generally C; and should be prepared to face questions like what are strings, pointers, header files or simple ‘for loop’ usage programs.<br /> Some software companies ask puzzles in their interview. This is the most challenging job to many people. There are chances that if they solve one or two asked puzzles they may get selected, other wise may get rejected. I have seen many good students struggling with puzzles, with tense and frightened look at the interviewers. Usually the puzzles asked will be simple. So be cool, take the paper and write down the figure representation of the puzzle and analyse it by fully focussing on it. Just forget that in front of you two (or more) enemies are sitting. Many students falter at this stage. One JC student who answered every question fired at him at Satyam interview was finally asked a puzzle. <br /><br />How do you divide this figure into 7 equal parts? <br /><br />The boy got tensed, struggled and gave up. He was rejected for not using common sense. By the way the answer was:<br /> <br /> <br /><br />So don’t panic, be cool and feel confident. Yes, here a bit of luck is counted.<br /> Speak clearly and convince your answers to them. Don’t rush at your answers and end up stammering, getting confused. Speak slowly and steadily; such are the guys who impress more. Smile in between (if you don’t know the answer) and don’t make too many hand movements. Don’t use complex terminology, which you don’t know. (Practicing mock interviews really helps a lot).<br /> The technical interview may last for 15 to 45 minutes. With good preparation many people find technical interview easy.<br /> If you do technical badly, then there is 90% chance of your rejection, if it was average, then one can do well in HR and get selected.<br /><br />6. HR INTERVIEW<br /><br /> Going into HR interview, you can be relaxed and feel free. But for few candidates HR section seems difficult. Usually HR interviewer will be a lady, so don’t get distracted. Just concentrate on her questions and your answers. This is very crucial stage of your life; if you stay focussed and perform well you will enjoy your future. There are many questions that HR managers from different companies ask. Let me list some of the questions and answers in a format, which I think, can be better ones. There can be hundreds of good answers, which can be given, based on your views, thoughts, personality, goals, expectations and finally the mood.<br />1) How was the written test?<br /> Sir, it was easy. I think I did well.<br />2) Tell me about yourself?<br /> Well, I was born in Dehradun. My father is Canara Bank Manager and mother is a housewife. I did my primary education in Royal Convent. My father was transferred to Banglore, when I was 14. I joined Kendriya Vidyalaya. I scored well in 10th with 95% aggregate for which I got CBSE scholarship. I did my 12th in the same school with 90% aggregate. When I was in 12th, I had participated in national level science exhibition held at Hydrabad. I wrote CET and secured 729 rank, even though I had got medical seat I took B.E. (Mechanical) in NIE …………. .<br />[In between they may ask questions about the scholarship you got and the exhibition you participated.]<br />3) Why did you leave medical seat?<br /> Right from my 10th standard I was interested in maths and I really didn’t enjoy biology labs. I wanted to learn the technology and do something in the technical field. So I opted engineering.<br />4) O.K. After scoring good marks at PU why did you score less in engineering?<br /> Sir, in PU we had 5-6 subjects to be studied in 14 months. But in engineering we have four-month semester and we need to study 8 subjects per semester. Moreover the labs are like lottery. If no output, then fail. So there is luck factor playing its part in engineering. Yes, I think I could have studied still well and could have performed still better.<br />5) Why do you want to work in a software company?<br /> When I took the seat in mechanical I didn’t know about software. But afterwards I thought, I better could have taken computer science branch because software is the fastest growing industry where one can build his career faster. Moreover I am flexible and efficient which make me suitable for learning the changing technologies faster and give my best.<br />[For mechanical or electronics companies]<br /> Sir, I wanted to study some core, solid field of engineering, so I chose the evergreen branch, Mechanical. After studying the technical concepts for 4 years, now I want to see how these subjects are applied in the industry. So I want to work in the field that I have studied and give my best to the company I am working in.<br />6) Why do you want to join our company?<br /> I have realized that software is the field where I can make a point. So basically I want to join a software firm like yours that works globally on cutting edge technologies and expose its employees to all the fields, which help the employees to excel.<br />[If the company is small like IVEGA, ONMOBILE, ITTIUM etc.]<br />sir, since your company is small, it can give every attention to each of your employees so that one gets to know all the things that’s happening in the company unlike some big firms like INFOSYS where some group is given some task and they are not allowed to see what’s happening on the other side. So one can grow faster in a smaller company like yours. So I prefer to work in your company.<br />[If the company is big like INFOSYS, TCS etc]<br />Sir, it makes me proud that there are few Indian companies which are global leaders today. The phenomenal growth of your company in last couple of years only speaks volume about your company. Yours is a SEI CMM level-5 company that gives its employees not only a challenging career, but also a rich work culture and rich values. I just want to be a part of that.<br />7) What do you expect from the company?<br /> Freedom! The company should give its employees the freedom of thoughts, ideas and proposals so that one is not restricted to something. One should be allowed to share his views on the things going on in the company so that both the employees and the company get benefited. By this the company can spot the areas in which an employee is good at and can extract good results by making him work on that area.<br />[Or you can say]<br />The company should encourage those who perform well and provide growth opportunities. It also can work on strengthening the employee relationship. I think a company should be like a family.<br />8) What are your strengths or why should we hire you only?<br />[You can say your strength with respect to the company but there are 4 things that a company usually expects from you. They are hard work, efficiency, flexibility and teamwork]<br /> I am efficient and flexible. I can learn faster and deliver faster which is required in software industry.<br />[You can say you are enthusiastic, creative, confident, have leadership qualities, communication skills, organisation skills, good memory etc, but support your answers with relevant examples. Here don’t try to bluff, if you want to bluff do it intelligently with proper expressions and emotions. For that you need to be an actor. You will win only when you out think your opponent. Out thinking is to know what the opponent is thinking and thinking beyond him. Wasim Akram had the ability to out think the batsmen and take them out with his variations. Sachin outthinks not only the bowler but even the opposite captain by improvising his shots. Vishwanathan Anand has to do the same thing.<br /> In an interview you need not defeat the interviewers but anticipate what they are expecting, what they are thinking about you and accordingly deliver the goods based on you and your preparation. It’s not as complex as it looks. Believe me.]<br />9) What weakness do you have?<br /> Well, I think I underestimate myself at times. (Or) I need to still improve in my communication skills. I am working on that. At times, I act carelessly, so I try to motivate myself always.<br /> [Don’t tell too many weaknesses, one or two are enough. Also mention the ways to overcome your weaknesses]<br /><br />10) What really motivates you?<br /> [Say who really motivates you]<br /> The achievements and sacrifice of all the great people in all the fields motivates me to do best in my field. The sheer thought of excelling in technical field and becoming a recognized individual in the industry motivates me.<br />[or]<br />The way my parents are struggling to educate me and their hope & blessings motivates me (or) Bill Gate motivates me (or) I am self-motivated.<br /><br /><br />Who is your role model?<br />[You can say anybody but you should know what you like about him or her]<br />[I had said]<br /> My role models are Sachin and Shahrukh Khan, because apart from their talent they worked hard and dedicated themselves to their field and rose to stardom right from the scratch. I mean to say, they justified their talents to the full extent. I like their consistency [You can say Bill Gate, Narayan Murthy, Sports persons. Your Father, Scientist, politician or anybody. By the way many say, east or west ‘Vivekananda’ is best]<br />11) Your Hobbies?<br />[They see your resume or bio data and ask about whatever is written there. So prepare well thought resume. About hobbies say some quality hobbies (of course you should cultivate them) like writing articles, quizzing, organizing tournaments or competitions, knowing new cars, meeting new peoples and places, singing, sports, etc.<br /> Eighty percent of students write, ‘reading books and playing cricket’. Please avoid these two options as they have become default and moreover interviewers will be fed up seeing same hobbies again and again. So don’t put up something that makes interviewers boring and lose interest in you. You need to out think and present yourself as an interesting, curious, fresh and raring to go kind of candidate.<br />12) What are your future goals?<br /> Right now I want to get into a good software/hardware/mechanical company like yours, stick to the company forever and grow along with the company.<br />13) O.K. What about your higher studies?<br /> Sir, after my engineering I just want to get into the industry, see how it works and how I work in it. So I am not opting for higher studies at this stage. And also, as I am from a middle class family my parents can’t afford for my higher studies.<br />14) Are you comfortable with our two-year agreement?<br /> Yes sir, I am pretty comfortable with that.<br /> Like this some companies may pour hundreds of questions. So don’t be impatient, show them that you have temperament and patience to work hard. Be modest and down to earth. Some companies may ask just a couple of HR questions, you should know earlier itself what you are going to speak. The people who can speak well without preparation are very very rare. <br /> Interviewers may ask some unexpected complex questions like:<br />1) Consider yourself as C. E. O., what do you do for growth of the company?<br />2) How can you improve employee relationships in the company?<br />3) What can you do to avoid sexual harassment in the company?<br />4) You said you are innovative; you better suit to join a product company rather than our services company.<br />5) You being weak in communicating skills do you expect you will get the job?<br />Take a breath, take your time to think and answer in a positive and optimistic way. Don’t leave hope or surrender at any stage.<br /> Companies ask whether you have friends and enjoy their company. This is to test whether you can work in a team. So always say you have pretty good number of friends and you enjoy their company. Never ever agree to work alone.<br /> I forgot to tell one thing, about imaging again. The day prior to the interview you sit alone and rehearse the interview. It’s like taking your interview by yourself. Ask HR questions to yourself and answer them loudly as you do in an interview. You can anticipate even technical questions and rehearse. This technique is very, very effective. Don’t think that you are the only one who has to do this; even ‘Amitabh Bachchan’ rehearses before acting. <br /> By the end of the interview you will get the clue whether you stand the chance or not. Even if you don’t have hope don’t leave the centre, wait till the results are announced. Koun jane Khuda ko aapka kounsa sajda pasand ajaae!<br />-----------------------------------------------------------------------------------------------------------------<br /><br />7. RESULTS<br />7.1 CELEBRATION<br /> Selected!! Wow that’s nice. Celebrations are totally left to you. But I suggest, if you want to party and have fun, do it on the same night as after couple of days you lose the josh of your success. After you get selected I swear, you won’t get sleep in next couple of nights. So ultimately everything has to be fought and earned. Believe in yourself, not in luck. Luck never made a mad man wise.<br />7.2 NOT SELECTED<br /> Earlier I used to laugh the phrase “failures are stepping stones”, but now I think that failures are building blocks of your personality that make you stronger every time you fail. <br /> So you have failed irrespective of your efforts and endeavours; no problem. You can say to yourself ‘this was not my company, there are hundred more good companies and I will get into a better one’. I know how bitter the disappointment is, but life does not stop. The show must go on and on. This day you have not lost anything but gained something. You have gained experience, which makes you handle pressure in a better manner next time. You have got to interact with few people and got to know your shortcomings, on which you can always work and improve yourself. Yeah, I know how difficult it is to take these things positively. When I had failed in my first four interviews, I was so much disappointed that when one of my friends asked “Hey still you have not been selected? This time I wish you will be selected”. I had replied sarcastically “I am ready to face hundred interviews”. That day I came and watched the film ‘Kabhi Han and Kabhi Na’ which changed my way of thinking. In the film the character Suneel is a normal guy with ambitions and the desire to get his girl. To succeed or to get what he wants he tries in every way, he even lies here and there but does not succeed. But he does not feel guilty or disappointed at all. He keeps telling his parents that one day he will become a successful person. He tries again, but fails. He is restless; he looks more fresh and optimistic every time he tries. Ultimately he loses his love for whom he had yearned several years. But even then he smiles and hopes he will succeed some day. Kundan Shah has directed the movie very much realistically.<br /> This movie inspired me so much so that when I failed afterwards I never felt the disappointment. Again next time with a smile on the face and hope in my eyes I went for the interview. So I strongly recommend you to watch KHKN which is the story of optimism. <br /> You can look back what were the areas in which you didn’t perform well. Sit and work on those areas. And again with new hope and a fresh look apply for the next company. You may fail hundred times, but one day will surely be yours and that day you will feel like you have conquered the world. Feeling dejected makes you miss your moments. Good moments don’t come often in our life; one should live every moment that comes his way. Say yesterday, you had failed and today you have your brother’s wedding. If you are dejected, nervous and don’t enjoy the occasion and after couple of days if you get a better job, you will repent throughout your life that you could have enjoyed your brother’s wedding.<br /> ‘When a door is closed for us, we tend to look at the closed door for so long that we never observe the other opened doors’. When I had failed in Infosys I was so disappointed for weeks that I never realized when the companies, TCS, CTS, L&T came and went away. So please don’t get carried away with your failures. One more thing, always stay focussed on one particular thing. Say you have five call letters, please never ever think that you have so many calls and you can get into one or the other. Otherwise you will land up nowhere. Hence aim only the interview, you have right ahead and just do it.<br /> There is nothing called success because success is purely virtual and has no boundaries. So always commit to CANI (Constant And Never-ending Improvement), then what ever they call success, money, fame will all be yours. <br />-----------------------------------------------------------------------------------------------------------------<br /><br />8. ATTITUDE<br /><br /> Company HR managers are psychologists. They can gauge the personality of the candidates by evaluating the answers given by them. So even by preparing perfect answers and bluffing perfectly you can’t prove yourself to be a person with solid attitude. Short term preparation doesn’t help this out. So if you start now you will find the difference after few years.<br /> So basically what should you do to get the job? You should impress the interviewers. You can do it by giving brilliant technical answers, knowing, explaining and appreciating company’s performance or business plans (for this you should be knowing what’s happening in the industry), telling your achievements, delivering emotional dialogues or portraying your personality which improves them.<br /> Changing our personality fully is difficult as few aspects are innate in us, which are unchangeable, but we can develop good attitude by commitment and practice. What’s actually attitude? It is the conception and the way with which we look at the things around us, people around us and behave or lead our life accordingly.<br /> I was too much of philosophical when I was in 2nd semester. I did lot of soul searching and set certain values for myself. Most of the time I followed them and it really paid off. The advantages that I got were, I never experienced mental stress and never had personal problems with anybody. The main advantage was that I enjoyed every moment that came my way and at the end of the day I am not complaining; I am happy.<br /> So let me list few tips that can help you. Even if you refer some personality books(I have heard Shiv Khera’s book ‘You can win’ is mind-blowing), you will find these things in some or the other way.<br />1) Enthusiasm: - A man without enthusiasm is like an animal. Enthusiasm is the urge or curiosity to know, learn, do and experience new things and moments. With this one can lead a thrilling life, without which the life becomes just a routine like a machine. So this is the age, when your blood should rush to make you energetic to do (Positive) what you can.<br />2) Angry young man: - Never get angry. If some body makes you angry, just laugh at them, laugh at the situation. Think that you are the master of the moment and you just don’t get out of control. In anger, if you shout at others or beat them, ultimately you have to repent about what you have said or done. Moreover by shouting or beating you are not changing anybody. So never lose your temper, let whatever happens: being cool and patient is an asset.<br />3) Laugh at yourself: - If you can’t laugh at others, somebody will laugh at both them and you. Life is to enjoy, and laughter is its tool. When you laugh at others it’s OK, but the problem comes only when others laugh at you; you feel humiliated and tend to become short tempered. Instead one can learn to laugh at oneself. This avoids ego problems, makes you more social and down to earth person. So there is no use in thinking yourself as a great personality and behaving like a king because people always like modest individuals.<br />4) Criticise: - Don’t criticise anybody. By doing that again you are not changing him to a good person. Criticism only spoils your personality. You won’t get anything if you comment on others.<br /> Weak minds talk about people,<br /> Average minds talk about events.<br /> Strong minds talk about ideas.<br />5) Learn: - Have the hunger to learn the things you don’t know. Let it be technical knowledge, general knowledge, etiquettes etc. So learn the things eagerly and sincerely. Everyday you should feel you are improving.<br />6) Groupism: - Even if you wish, you can’t work alone after you get the job. So those who like loneliness and are reserved; open yourself and make friends. Meet new people and share your views and knowledge. By this you can learn effective communication and develop leadership qualities. For leadership skills you can opt to become the captain in the cricket field and see how best you can manage the players. You can organize competitive events and try to lead in your project groups.<br />7) Optimism: - Even if you are at dire straits, hope for the best. Even if you are dying hope that you would live. This what makes life sweater. Always believe you can bounce back and win. Never give up.<br /> Whatever you do you should not disturb, hurt or harm others. Being selfish doesn’t make you happy; making others happy makes you happy. Hence, always work for the welfare of the society.<br /> Still there are hundreds of aspects that can make your personality a rock solid. In this regard you can refer the personality development books.<br /> Your personality is measured not by your words but by your thoughts and behavior. So over the time anybody can develop ‘positive attitude’, if they are serious about it. With proper workout even a ‘khajoor’ (stupid) can become a dignified person.<br />-----------------------------------------------------------------------------------------------------------------<br /> <br /><br /><br />9. JUICY EVENTS AT INTERVIEW<br /><br />1) For TCS interview I had worn a new shirt and had fixed a new pen in my shirt pocket. The first technical question, ‘write 8085 program to sort 10 numbers…’ the interviewer was explaining. Mean while I tried to take out my pen from my pocket but the new pen was so tight that it was not coming out at all. I pulled, pulled and pulled for around one minute, but the pen was stuck their like a virus. The other interviewer was enjoying the scene. Ultimately I asked ‘Sir can I have your pen?’<br />“You should”, came the reply.<br />With such a situation, who can come out successful?<br />2) In L&T ‘C’ test, one of my friends solved a ‘C’ program and wrote the output as 200 unfortunately, which was the right answer. But he saw a ‘C’ punter in front of him, who had written 105 as the output for the same program. So he stroke off 200 and wrote 105 beside it.<br /> In the interview, interviewer took his ‘C’ answer sheet and asked ‘how did you get 105 after getting 200?<br />“Sir, later I thought the answer might be 105 so I changed it to 105”.<br />“Can you explain how did you get 105 with the given program?”<br />The candidate was bewildered, he replied<br />“Sir….. No sir……I……….actually guessed it”<br />“Why did you guess 105 only?”<br />“Sir…… because ………105 is my lucky number”<br />And rest is the history.<br /><br />3) One candidate went to CTS interview; of course he was a Kannadiga. His was the last interview of the day. The interviewer asked, “Who is the CM of Karnataka?”<br />The candidate replied with great confidence, “Sir, K. M. Krishnamurthy”.<br />Ultimately he was selected. By the way K. M. Krishnamurthy was his project batch mate<br />4) By the end of 2002 I was so obsessed with the film ‘Devdas’ that I had watched it 10 times. In MindTree interview I mimicked “Shahrukh” as Devdas. I had remembered all his dialogues. Interviewers felt really happy and said they never had experienced such an entertainment at interviews. That was my best interview.<br />5) In some interview, a guy called “Ehtisham” showed different Karate skills in front of the interviewers. [They didn’t take him because they feared one day he might kick them too].<br />6) For a software company, 9 from our class were short listed for the Ist interview. For 8 of us they asked which programming languages we knew. We said we didn’t know anything except ‘C’. But one guy said he knew many languages and smashed every question that came his way. Unfortunately that guy was rejected. We all were short listed for the next interview. Finally 5 of us were selected for the company.<br />-----------------------------------------Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-24311632920125442932008-07-25T10:34:00.001-07:002008-12-23T04:01:37.823-08:00LOGICAL SECTIONDirections: For questions 30-39 fill the missing number or letter in the given series<br />30. a, c, e, g, _<br /><br />(a) h<br />(b) i<br />(c) d<br />(d) j<br />Ans. B<br /><br />31. a, e, i, m, q, u, _, _<br /><br />(a) y,c<br />(b) b,f<br />(c) g,i<br />(d) none<br />Ans. A<br />32. ay , bz , cw , dx ,__<br /><br />(a) gu<br />(b) ev<br />(c) fv<br />(d) eu<br />Ans. D<br />33. 1, 2, 3, 5, 7, 11, __<br /><br />(a) 15<br />(b) 9<br />(c) 13<br />(d) 12<br />Ans. C (series of prime numbers)<br />34. kp , lo , mn , __<br /><br />(a) nm<br />(b) np<br />(c) op<br />(d) pq<br />Ans. A<br />35. R,M,__,F,D,__<br /><br />(a) I, C<br />(b) A, Q<br />(c) L, N<br />(d) B, Q<br />Ans. A<br />36. ___, ayw, gec, mki, sqo<br /><br />(a) awx<br />(b) usq<br />(c) prs<br />(d) lmn<br />Ans. B<br />37. 1, 3, 4, 8, 15, 27, __<br /><br />(a) 60<br />(b) 59<br />(c) 43<br />(d) 50<br />Ans D<br />38. 0, 2, 3, 5, 8, 10, 15, 17, 24, 26,__<br /><br />(a) 45<br />(b) 55<br />(c) 35<br />(d) 48<br />Ans. C<br />39. 2, 5, 9, 19, 37,__<br /><br />(a) 64<br />(b) 55<br />(c) 75<br />(d) 40<br />Ans C<br />Directions for questions 40 to 45: Select the alternative that logically follows form the two given statements.<br />40. All scientists are fools. All fools are literates.<br /><br />(a)All literates are scientists<br />(b) All scientists are literates<br />(c) No scientists are literates<br />(d) Both (a) and (b) are correct<br />Ans. B<br />41. No apple is an orange. All bananas are oranges.<br /><br />(a) All apples are oranges<br />(b) Some apples are oranges<br />(c) No apple is a banana<br />(d) None of the above<br />Ans. A<br />42. All pens are elephants. Some elephants are cats.<br /><br />(a) Some pens are cats<br />(b) No pens are cats<br />(c) All pens are cats<br />(d) None of the above<br />Ans. D<br />43. All shares are debentures.No debentures are deposits.<br /><br />(a) All shares are deposits<br />(b) Some shares are deposits<br />(c) No shares are deposits<br />(d) None of the above<br />Ans. C<br />44. Many fathers are brothers. All brothers are priests.<br /><br />(a) No father is a priest<br />(b) Many fathers are not priests<br />(c) Many fathers are priests<br />(d) Both (b) and (c)<br />Ans. B<br />45. Some green are blue. No blue are white.<br /><br />(a) No green are white<br />(b) Some green are white<br />(c) No green are white<br />(d) None of the above<br />Ans. B<br />46. If the word "CODING" is represented as DPEJOH , then the word "CURFEW" can be represented?<br /><br />(a) dvsgfx<br />(b) dvshfx<br />(c) dgshfx<br />(d) dtsgfy<br />Ans. A<br />47. If in a certain code "RANGE" is coded as 12345 and "RANDOM" is coded as 123678, then the code for the word "MANGO" would be<br /><br />(a) 82357<br />(b) 84563<br />(c) 82346<br />(d) 82543<br />Ans. D<br />Directions for questions 48-50:The questions are based on the following data<br />In a class of 150 students 55 speak English;85 speak Telugu and 30 speak neither English nor Telugu<br />48. How many speak both English and Telugu?<br /><br />(a) 10<br />(b) 15<br />(c) 20<br />(d) 12<br />Ans. C<br />49.How many speak only Telugu?<br /><br />(a) 55<br />(b) 45<br />(c) 65<br />(d) none of the above<br />Ans.C<br />50.How many speak at least one of the two languages?<br /><br />(a) 120<br />(b) 100<br />(c) 250<br />(d) 50<br />Ans. A<br /><br />Refer R.S Agarwal books for more questions of the same kind<br />Verbal -- Page 254 problems 53 to56<br /> 246 eg.2<br /> Page 104 Exercise.3a (Series Questions)<br /> Page 354-355 8,13,<br /> Page 115<br /><br />Nonverbal -- Pages 5,41,54,108,145,158Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-1823749648127895610.post-80148020728878700912008-07-25T10:33:00.000-07:002008-12-23T04:01:37.823-08:00ARITHMETIC SECTIONThis section consists of 29 problems. The questions are simple though time consuming.<br />1. If a boat is moving in upstream with velocity of 14 km/hr and goes downstream with a velocity of 40 km/hr, then what is the speed of the stream ?<br /><br />(a) 13 km/hr<br />(b) 26 km/hr<br />(c) 34 km/hr<br />(d) none of these<br />Ans. A<br />2. Find the value of ( 0.75 * 0.75 * 0.75 - 0.001 ) / ( 0.75 * 0.75 - 0.075 + 0.01)<br /><br />(a) 0.845<br />(b) 1.908<br />(c) 2.312<br />(d) 0.001<br />Ans. A<br />3. A can have a piece of work done in 8 days, B can work three times faster than the A, C can work five times faster than A. How many days will they take to do the work together ?<br /><br />(a) 3 days<br />(b) 8/9 days<br />(c) 4 days<br />(d) can't say<br />Ans. B<br />4. A car travels a certain distance taking 7 hrs in forward journey, during the return journey increased speed 12km/hr takes the times 5 hrs.What is the distance travelled<br /><br />(a) 210 kms<br />(b) 30 kms<br />(c) 20 kms<br />(c) none of these<br />Ans. B<br />5. Instead of multiplying a number by 7, the number is divided by 7. What is the percentage of error obtained ?<br />6. Find (7x + 4y ) / (x-2y) if x/2y = 3/2 ?<br /><br />(a) 6<br />(b) 8<br />(c) 7<br />(d) data insufficient<br />Ans. C<br />7. A man buys 12 lts of liquid which contains 20% of the liquid and the rest is water. He then mixes it with 10 lts of another mixture with 30% of liquid.What is the % of water in the new mixture?<br /><br />8. If a man buys 1 lt of milk for Rs.12 and mixes it with 20% water and sells it for Rs.15, then what is the percentage of gain?<br /><br />9. Pipe A can fill a tank in 30 mins and Pipe B can fill it in 28 mins.If 3/4th of the tank is filled by Pipe B alone and both are opened, how much time is required by both the pipes to fill the tank completely ?<br />10. If on an item a company gives 25% discount, they earn 25% profit. If they now give 10% discount then what is the profit percentage.<br />(a) 40%<br />(b) 55%<br />(c) 35%<br />(d) 30%<br />Ans. D<br />11. A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be finished. How many men were there originally?<br /><br />(a) 110 men<br />(b) 130 men<br />(c) 100 men<br />(d) none of these<br />Ans. A<br />12. In simple interest what sum amounts of Rs.1120/- in 4 years and Rs.1200/- in 5 years ?<br />(a) Rs. 500<br />(b) Rs. 600<br />(c) Rs. 800<br />(d) Rs. 900<br />Ans. C<br />13. If a sum of money compound annually amounts of thrice itself in 3 years. In how many years<br />will it become 9 times itself.<br /><br />(a) 6<br />(b) 8<br />(c) 10<br />(d) 12<br />Ans A<br />14. Two trains move in the same direction at 50 kmph and 32 kmph respectively. A man in the slower train<br />observes the 15 seconds elapse before the faster train completely passes by him.<br />What is the length of faster train ?<br /><br />(a) 100m<br />(b) 75m<br />(c) 120m<br />(d) 50m<br />Ans B<br />15. How many mashes are there in 1 squrare meter of wire gauge if each mesh<br />is 8mm long and 5mm wide ?<br /><br />(a) 2500<br />(b) 25000<br />(c) 250<br />(d) 250000<br />Ans B<br />16. x% of y is y% of ?<br /><br />(a) x/y<br />(b) 2y<br />(c) x<br />(d) can't be determined<br />Ans. C<br />17. The price of sugar increases by 20%, by what % should a housewife reduce the consumption of sugar so that expenditure on sugar can be same as before ?<br /><br />(a) 15%<br />(b) 16.66%<br />(c) 12%<br />(d) 9%<br />Ans B<br />18. A man spends half of his salary on household expenses, 1/4th for rent, 1/5th for travel expenses, the man deposits the rest in a bank. If his monthly deposits in the bank amount 50, what is his monthly salary ?<br /><br />(a) Rs.500<br />(b) Rs.1500<br />(c) Rs.1000<br />(d) Rs. 900<br />Ans C<br />20. The population of a city increases @ 4% p.a. There is an additional annual increase of 4% of the population due to the influx of job seekers, find the % increase in population after 2 years ?<br />21. The ratio of the number of boys and girls in a school is 3:2 Out of these 10% the boys and 25% of girls are scholarship holders. % of students who are not scholarship holders.?<br />22. 15 men take 21 days of 8 hrs. each to do a piece of work. How many days of 6 hrs. each would it take for 21 women if 3 women do as much work as 2 men?<br /><br />(a) 30<br />(b) 20<br />(c) 19<br />(d) 29<br />Ans. A<br />23. A cylinder is 6 cms in diameter and 6 cms in height. If spheres of the same size are made from the material obtained, what is the diameter of each sphere?<br /><br />(a) 5 cms<br />(b) 2 cms<br />(c) 3 cms<br />(d) 4 cms<br />Ans C<br />24. A rectangular plank (2)1/2 meters wide can be placed so that it is on either side of the diagonal of a square shown below.(Figure is not available)What is the area of the plank?<br />Ans :7*(2)1/2<br />25. The difference b/w the compound interest payble half yearly and the simple interest on a<br />certain sum lent out at 10% p.a for 1 year is Rs 25. What is the sum?<br /><br />(a) Rs. 15000<br />(b) Rs. 12000<br />(c) Rs. 10000<br />(d) none of these<br />Ans C<br />26. What is the smallest number by which 2880 must be divided in order to make it into a<br />perfect square ?<br /><br />(a) 3<br />(b) 4<br />(c) 5<br />(d) 6<br />Ans. C<br />27. A father is 30 years older than his son however he will be only thrice as old as the son after 5 years<br />what is father's present age ?<br /><br />(a) 40 yrs<br />(b) 30 yrs<br />(c) 50 yrs<br />(d) none of these<br />Ans. A<br /><br />28. An article sold at a profit of 20% if both the cost price and selling price would be Rs.20/- the profit would be 10% more. What is the cost price of that article?<br />29. If an item costs Rs.3 in '99 and Rs.203 in '00.What is the % increase in price?<br /><br />(a) 200/3 %<br />(b) 200/6 %<br />(c) 100%<br />(d) none of these<br />Ans. ASumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-1823749648127895610.post-23066455236049756962008-07-25T10:23:00.001-07:002008-12-23T04:01:37.823-08:00C Faq'sSection 1. Declarations and Initializations<br /><br />1.1: How do you decide which integer type to use?<br /><br />A: If you might need large values (above 32,767 or below -32,767),<br /> use long. Otherwise, if space is very important (i.e. if there<br /> are large arrays or many structures), use short. Otherwise, use<br /> int. If well-defined overflow characteristics are important and<br /> negative values are not, or if you want to steer clear of sign-<br /> extension problems when manipulating bits or bytes, use one of<br /> the corresponding unsigned types. (Beware when mixing signed<br /> and unsigned values in expressions, though.)<br /><br /> Although character types (especially unsigned char) can be used<br /> as "tiny" integers, doing so is sometimes more trouble than it's<br /> worth, due to unpredictable sign extension and increased code<br /> size. (Using unsigned char can help; see question 12.1 for a<br /> related problem.)<br /><br /> A similar space/time tradeoff applies when deciding between<br /> float and double. None of the above rules apply if the address<br /> of a variable is taken and must have a particular type.<br /><br /> If for some reason you need to declare something with an *exact*<br /> size (usually the only good reason for doing so is when<br /> attempting to conform to some externally-imposed storage layout,<br /> but see question 20.5), be sure to encapsulate the choice behind<br /> an appropriate typedef.<br /><br /> References: K&R1 Sec. 2.2 p. 34; K&R2 Sec. 2.2 p. 36, Sec. A4.2<br /> pp. 195-6, Sec. B11 p. 257; ISO Sec. 5.2.4.2.1, Sec. 6.1.2.5;<br /> H&S Secs. 5.1,5.2 pp. 110-114.<br /><br />1.4: What should the 64-bit type on a machine that can support it?<br /><br />A: The forthcoming revision to the C Standard (C9X) specifies type<br /> long long as effectively being at least 64 bits, and this type<br /> has been implemented by a number of compilers for some time.<br /> (Others have implemented extensions such as __longlong.)<br /> On the other hand, there's no theoretical reason why a compiler<br /> couldn't implement type short int as 16, int as 32, and long int<br /> as 64 bits, and some compilers do indeed choose this<br /> arrangement.<br /><br /> See also question 18.15d.<br /><br /> References: C9X Sec. 5.2.4.2.1, Sec. 6.1.2.5.<br /><br />1.7: What's the best way to declare and define global variables<br /> and functions?<br /><br />A: First, though there can be many "declarations" (and in many<br /> translation units) of a single "global" (strictly speaking,<br /> "external") variable or function, there must be exactly one<br /> "definition". (The definition is the declaration that actually<br /> allocates space, and provides an initialization value, if any.)<br /> The best arrangement is to place each definition in some<br /> relevant .c file, with an external declaration in a header<br /> (".h") file, which is #included wherever the declaration is<br /> needed. The .c file containing the definition should also<br /> #include the same header file, so that the compiler can check<br /> that the definition matches the declarations.<br /><br /> This rule promotes a high degree of portability: it is<br /> consistent with the requirements of the ANSI C Standard, and is<br /> also consistent with most pre-ANSI compilers and linkers. (Unix<br /> compilers and linkers typically use a "common model" which<br /> allows multiple definitions, as long as at most one is<br /> initialized; this behavior is mentioned as a "common extension"<br /> by the ANSI Standard, no pun intended. A few very odd systems<br /> may require an explicit initializer to distinguish a definition<br /> from an external declaration.)<br /><br /> It is possible to use preprocessor tricks to arrange that a line<br /> like<br /><br /> DEFINE(int, i);<br /><br /> need only be entered once in one header file, and turned into a<br /> definition or a declaration depending on the setting of some<br /> macro, but it's not clear if this is worth the trouble.<br /><br /> It's especially important to put global declarations in header<br /> files if you want the compiler to catch inconsistent<br /> declarations for you. In particular, never place a prototype<br /> for an external function in a .c file: it wouldn't generally be<br /> checked for consistency with the definition, and an incompatible<br /> prototype is worse than useless.<br /><br /> See also questions 10.6 and 18.8.<br /><br /> References: K&R1 Sec. 4.5 pp. 76-7; K&R2 Sec. 4.4 pp. 80-1; ISO<br /> Sec. 6.1.2.2, Sec. 6.7, Sec. 6.7.2, Sec. G.5.11; Rationale<br /> Sec. 3.1.2.2; H&S Sec. 4.8 pp. 101-104, Sec. 9.2.3 p. 267; CT&P<br /> Sec. 4.2 pp. 54-56.<br /><br />1.11: What does extern mean in a function declaration?<br /><br />A: It can be used as a stylistic hint to indicate that the<br /> function's definition is probably in another source file, but<br /> there is no formal difference between<br /><br /> extern int f();<br /><br /> and<br /><br /> int f();<br /><br /> References: ISO Sec. 6.1.2.2, Sec. 6.5.1; Rationale<br /> Sec. 3.1.2.2; H&S Secs. 4.3,4.3.1 pp. 75-6.<br /><br />1.12: What's the auto keyword good for?<br /><br />A: Nothing; it's archaic. See also question 20.37.<br /><br /> References: K&R1 Sec. A8.1 p. 193; ISO Sec. 6.1.2.4, Sec. 6.5.1;<br /> H&S Sec. 4.3 p. 75, Sec. 4.3.1 p. 76.<br /><br />1.14: I can't seem to define a linked list successfully. I tried<br /><br /> typedef struct {<br /> char *item;<br /> NODEPTR next;<br /> } *NODEPTR;<br /><br /> but the compiler gave me error messages. Can't a structure in C<br /> contain a pointer to itself?<br /><br />A: Structures in C can certainly contain pointers to themselves;<br /> the discussion and example in section 6.5 of K&R make this<br /> clear. The problem with the NODEPTR example is that the typedef<br /> has not been defined at the point where the "next" field is<br /> declared. To fix this code, first give the structure a tag<br /> ("struct node"). Then, declare the "next" field as a simple<br /> "struct node *", or disentangle the typedef declaration from the<br /> structure definition, or both. One corrected version would be<br /><br /> struct node {<br /> char *item;<br /> struct node *next;<br /> };<br /><br /> typedef struct node *NODEPTR;<br /><br /> and there are at least three other equivalently correct ways of<br /> arranging it.<br /><br /> A similar problem, with a similar solution, can arise when<br /> attempting to declare a pair of typedef'ed mutually referential<br /> structures.<br /><br /> See also question 2.1.<br /><br /> References: K&R1 Sec. 6.5 p. 101; K&R2 Sec. 6.5 p. 139; ISO<br /> Sec. 6.5.2, Sec. 6.5.2.3; H&S Sec. 5.6.1 pp. 132-3.<br /><br />1.21: How do I declare an array of N pointers to functions returning<br /> pointers to functions returning pointers to characters?<br /><br />A: The first part of this question can be answered in at least<br /> three ways:<br /><br /> 1. char *(*(*a[N])())();<br /><br /> 2. Build the declaration up incrementally, using typedefs:<br /><br /> typedef char *pc; /* pointer to char */<br /> typedef pc fpc(); /* function returning pointer to char */<br /> typedef fpc *pfpc; /* pointer to above */<br /> typedef pfpc fpfpc(); /* function returning... */<br /> typedef fpfpc *pfpfpc; /* pointer to... */<br /> pfpfpc a[N]; /* array of... */<br /><br /> 3. Use the cdecl program, which turns English into C and vice<br /> versa:<br /><br /> cdecl> declare a as array of pointer to function returning<br /> pointer to function returning pointer to char<br /> char *(*(*a[])())()<br /><br /> cdecl can also explain complicated declarations, help with<br /> casts, and indicate which set of parentheses the arguments<br /> go in (for complicated function definitions, like the one<br /> above). See question 18.1.<br /><br /> Any good book on C should explain how to read these complicated<br /> C declarations "inside out" to understand them ("declaration<br /> mimics use").<br /><br /> The pointer-to-function declarations in the examples above have<br /> not included parameter type information. When the parameters<br /> have complicated types, declarations can *really* get messy.<br /> (Modern versions of cdecl can help here, too.)<br /><br /> References: K&R2 Sec. 5.12 p. 122; ISO Sec. 6.5ff (esp.<br /> Sec. 6.5.4); H&S Sec. 4.5 pp. 85-92, Sec. 5.10.1 pp. 149-50.<br /><br />1.22: How can I declare a function that can return a pointer to a<br /> function of the same type? I'm building a state machine with<br /> one function for each state, each of which returns a pointer to<br /> the function for the next state. But I can't find a way to<br /> declare the functions.<br /><br />A: You can't quite do it directly. Either have the function return<br /> a generic function pointer, with some judicious casts to adjust<br /> the types as the pointers are passed around; or have it return a<br /> structure containing only a pointer to a function returning that<br /> structure.<br /><br />1.25: My compiler is complaining about an invalid redeclaration of a<br /> function, but I only define it once and call it once.<br /><br />A: Functions which are called without a declaration in scope<br /> (perhaps because the first call precedes the function's<br /> definition) are assumed to be declared as returning int (and<br /> without any argument type information), leading to discrepancies<br /> if the function is later declared or defined otherwise. Non-int<br /> functions must be declared before they are called.<br /><br /> Another possible source of this problem is that the function has<br /> the same name as another one declared in some header file.<br /><br /> See also questions 11.3 and 15.1.<br /><br /> References: K&R1 Sec. 4.2 p. 70; K&R2 Sec. 4.2 p. 72; ISO<br /> Sec. 6.3.2.2; H&S Sec. 4.7 p. 101.<br /><br />1.25b: What's the right declaration for main()?<br /> Is void main() correct?<br /><br />A: See questions 11.12a to 11.15. (But no, it's not correct.)<br /><br />1.30: What am I allowed to assume about the initial values<br /> of variables which are not explicitly initialized?<br /> If global variables start out as "zero", is that good<br /> enough for null pointers and floating-point zeroes?<br /><br />A: Uninitialized variables with "static" duration (that is, those<br /> declared outside of functions, and those declared with the<br /> storage class static), are guaranteed to start out as zero, as<br /> if the programmer had typed "= 0". Therefore, such variables<br /> are implicitly initialized to the null pointer (of the correct<br /> type; see also section 5) if they are pointers, and to 0.0 if<br /> they are floating-point.<br /><br /> Variables with "automatic" duration (i.e. local variables<br /> without the static storage class) start out containing garbage,<br /> unless they are explicitly initialized. (Nothing useful can be<br /> predicted about the garbage.)<br /><br /> Dynamically-allocated memory obtained with malloc() and<br /> realloc() is also likely to contain garbage, and must be<br /> initialized by the calling program, as appropriate. Memory<br /> obtained with calloc() is all-bits-0, but this is not<br /> necessarily useful for pointer or floating-point values (see<br /> question 7.31, and section 5).<br /><br /> References: K&R1 Sec. 4.9 pp. 82-4; K&R2 Sec. 4.9 pp. 85-86; ISO<br /> Sec. 6.5.7, Sec. 7.10.3.1, Sec. 7.10.5.3; H&S Sec. 4.2.8 pp. 72-<br /> 3, Sec. 4.6 pp. 92-3, Sec. 4.6.2 pp. 94-5, Sec. 4.6.3 p. 96,<br /> Sec. 16.1 p. 386.<br /><br />1.31: This code, straight out of a book, isn't compiling:<br /><br /> int f()<br /> {<br /> char a[] = "Hello, world!";<br /> }<br /><br />A: Perhaps you have a pre-ANSI compiler, which doesn't allow<br /> initialization of "automatic aggregates" (i.e. non-static<br /> local arrays, structures, and unions). (As a workaround, and<br /> depending on how the variable a is used, you may be able to make<br /> it global or static, or replace it with a pointer, or initialize<br /> it by hand with strcpy() when f() is called.) See also<br /> question 11.29.<br /><br />1.31b: What's wrong with this initialization?<br /><br /> char *p = malloc(10);<br /><br /> My compiler is complaining about an "invalid initializer",<br /> or something.<br /><br />A: Is the declaration of a static or non-local variable? Function<br /> calls are allowed only in initializers for automatic variables<br /> (that is, for local, non-static variables).<br /><br />1.32: What is the difference between these initializations?<br /><br /> char a[] = "string literal";<br /> char *p = "string literal";<br /><br /> My program crashes if I try to assign a new value to p[i].<br /><br />A: A string literal can be used in two slightly different ways. As<br /> an array initializer (as in the declaration of char a[]), it<br /> specifies the initial values of the characters in that array.<br /> Anywhere else, it turns into an unnamed, static array of<br /> characters, which may be stored in read-only memory, which is<br /> why you can't safely modify it. In an expression context, the<br /> array is converted at once to a pointer, as usual (see section<br /> 6), so the second declaration initializes p to point to the<br /> unnamed array's first element.<br /><br /> (For compiling old code, some compilers have a switch<br /> controlling whether strings are writable or not.)<br /><br /> See also questions 1.31, 6.1, 6.2, and 6.8.<br /><br /> References: K&R2 Sec. 5.5 p. 104; ISO Sec. 6.1.4, Sec. 6.5.7;<br /> Rationale Sec. 3.1.4; H&S Sec. 2.7.4 pp. 31-2.<br /><br />1.34: I finally figured out the syntax for declaring pointers to<br /> functions, but now how do I initialize one?<br /><br />A: Use something like<br /><br /> extern int func();<br /> int (*fp)() = func;<br /><br /> When the name of a function appears in an expression like this,<br /> it "decays" into a pointer (that is, it has its address<br /> implicitly taken), much as an array name does.<br /><br /> An explicit declaration for the function is normally needed,<br /> since implicit external function declaration does not happen in<br /> this case (because the function name in the initialization is<br /> not part of a function call).<br /><br /> See also questions 1.25 and 4.12.<br /><br /><br />Section 2. Structures, Unions, and Enumerations<br /><br />2.1: What's the difference between these two declarations?<br /><br /> struct x1 { ... };<br /> typedef struct { ... } x2;<br /><br />A: The first form declares a "structure tag"; the second declares a<br /> "typedef". The main difference is that you subsequently refer<br /> to the first type as "struct x1" and the second simply as "x2".<br /> That is, the second declaration is of a slightly more abstract<br /> type -- its users don't necessarily know that it is a structure,<br /> and the keyword struct is not used when declaring instances of it.<br /><br />2.2: Why doesn't<br /><br /> struct x { ... };<br /> x thestruct;<br /><br /> work?<br /><br />A: C is not C++. Typedef names are not automatically generated for<br /> structure tags. See also question 2.1 above.<br /><br />2.3: Can a structure contain a pointer to itself?<br /><br />A: Most certainly. See question 1.14.<br /><br />2.4: What's the best way of implementing opaque (abstract) data types<br /> in C?<br /><br />A: One good way is for clients to use structure pointers (perhaps<br /> additionally hidden behind typedefs) which point to structure<br /> types which are not publicly defined.<br /><br />2.6: I came across some code that declared a structure like this:<br /><br /> struct name {<br /> int namelen;<br /> char namestr[1];<br /> };<br /><br /> and then did some tricky allocation to make the namestr array<br /> act like it had several elements. Is this legal or portable?<br /><br />A: This technique is popular, although Dennis Ritchie has called it<br /> "unwarranted chumminess with the C implementation." An official<br /> interpretation has deemed that it is not strictly conforming<br /> with the C Standard, although it does seem to work under all<br /> known implementations. (Compilers which check array bounds<br /> carefully might issue warnings.)<br /><br /> Another possibility is to declare the variable-size element very<br /> large, rather than very small; in the case of the above example:<br /><br /> ...<br /> char namestr[MAXSIZE];<br /><br /> where MAXSIZE is larger than any name which will be stored.<br /> However, it looks like this technique is disallowed by a strict<br /> interpretation of the Standard as well. Furthermore, either of<br /> these "chummy" structures must be used with care, since the<br /> programmer knows more about their size than the compiler does.<br /> (In particular, they can generally only be manipulated via<br /> pointers.)<br /><br /> C9X will introduce the concept of a "flexible array member",<br /> which will allow the size of an array to be omitted if it is<br /> the last member in a structure, thus providing a well-defined<br /> solution.<br /><br /> References: Rationale Sec. 3.5.4.2; C9X Sec. 6.5.2.1.<br /><br />2.7: I heard that structures could be assigned to variables and<br /> passed to and from functions, but K&R1 says not.<br /><br />A: What K&R1 said (though this was quite some time ago by now) was<br /> that the restrictions on structure operations would be lifted<br /> in a forthcoming version of the compiler, and in fact structure<br /> assignment and passing were fully functional in Ritchie's<br /> compiler even as K&R1 was being published. A few ancient C<br /> compilers may have lacked these operations, but all modern<br /> compilers support them, and they are part of the ANSI C<br /> standard, so there should be no reluctance to use them.<br /><br /> (Note that when a structure is assigned, passed, or returned,<br /> the copying is done monolithically; the data pointed to by any<br /> pointer fields is *not* copied.)<br /><br /> References: K&R1 Sec. 6.2 p. 121; K&R2 Sec. 6.2 p. 129; ISO<br /> Sec. 6.1.2.5, Sec. 6.2.2.1, Sec. 6.3.16; H&S Sec. 5.6.2 p. 133.<br /><br />2.8: Is there a way to compare structures automatically?<br /><br />A: No. There is no single, good way for a compiler to implement<br /> implicit structure comparison (i.e. to support the == operator<br /> for structures) which is consistent with C's low-level flavor.<br /> A simple byte-by-byte comparison could founder on random bits<br /> present in unused "holes" in the structure (such padding is used<br /> to keep the alignment of later fields correct; see question<br /> 2.12). A field-by-field comparison might require unacceptable<br /> amounts of repetitive code for large structures.<br /><br /> If you need to compare two structures, you'll have to write your<br /> own function to do so, field by field.<br /><br /> References: K&R2 Sec. 6.2 p. 129; Rationale Sec. 3.3.9; H&S<br /> Sec. 5.6.2 p. 133.<br /><br />2.10: How can I pass constant values to functions which accept<br /> structure arguments?<br /><br />A: As of this writing, C has no way of generating anonymous<br /> structure values. You will have to use a temporary structure<br /> variable or a little structure-building function.<br /><br /> The C9X Standard will introduce "compound literals"; one form of<br /> compound literal will allow structure constants. For example,<br /> to pass a constant coordinate pair to a plotpoint() function<br /> which expects a struct point, you will be able to call<br /><br /> plotpoint((struct point){1, 2});<br /><br /> Combined with "designated initializers" (another C9X feature),<br /> it will also be possible to specify member values by name:<br /><br /> plotpoint((struct point){.x=1, .y=2});<br /><br /> See also question 4.10.<br /><br /> References: C9X Sec. 6.3.2.5, Sec. 6.5.8.<br /><br />2.11: How can I read/write structures from/to data files?<br /><br />A: It is relatively straightforward to write a structure out using<br /> fwrite():<br /><br /> fwrite(&somestruct, sizeof somestruct, 1, fp);<br /><br /> and a corresponding fread invocation can read it back in.<br /> However, data files so written will *not* be portable (see<br /> questions 2.12 and 20.5). Note also that if the structure<br /> contains any pointers, only the pointer values will be written,<br /> and they are most unlikely to be valid when read back in.<br /> Finally, note that for widespread portability you must use the<br /> "b" flag when fopening the files; see question 12.38.<br /><br /> A more portable solution, though it's a bit more work initially,<br /> is to write a pair of functions for writing and reading a<br /> structure, field-by-field, in a portable (perhaps even human-<br /> readable) way.<br /><br /> References: H&S Sec. 15.13 p. 381.<br /><br />2.12: My compiler is leaving holes in structures, which is wasting<br /> space and preventing "binary" I/O to external data files. Can I<br /> turn off the padding, or otherwise control the alignment of<br /> structure fields?<br /><br />A: Your compiler may provide an extension to give you this control<br /> (perhaps a #pragma; see question 11.20), but there is no<br /> standard method.<br /><br /> See also question 20.5.<br /><br /> References: K&R2 Sec. 6.4 p. 138; H&S Sec. 5.6.4 p. 135.<br /><br />2.13: Why does sizeof report a larger size than I expect for a<br /> structure type, as if there were padding at the end?<br /><br />A: Structures may have this padding (as well as internal padding),<br /> if necessary, to ensure that alignment properties will be<br /> preserved when an array of contiguous structures is allocated.<br /> Even when the structure is not part of an array, the end padding<br /> remains, so that sizeof can always return a consistent size.<br /> See also question 2.12 above.<br /><br /> References: H&S Sec. 5.6.7 pp. 139-40.<br /><br />2.14: How can I determine the byte offset of a field within a<br /> structure?<br /><br />A: ANSI C defines the offsetof() macro, which should be used if<br /> available; see <stddef.h>. If you don't have it, one possible<br /> implementation is<br /><br /> #define offsetof(type, mem) ((size_t) \<br /> ((char *)&((type *)0)->mem - (char *)(type *)0))<br /><br /> This implementation is not 100% portable; some compilers may<br /> legitimately refuse to accept it.<br /><br /> See question 2.15 below for a usage hint.<br /><br /> References: ISO Sec. 7.1.6; Rationale Sec. 3.5.4.2; H&S<br /> Sec. 11.1 pp. 292-3.<br /><br />2.15: How can I access structure fields by name at run time?<br /><br />A: Build a table of names and offsets, using the offsetof() macro.<br /> The offset of field b in struct a is<br /><br /> offsetb = offsetof(struct a, b)<br /><br /> If structp is a pointer to an instance of this structure, and<br /> field b is an int (with offset as computed above), b's value can<br /> be set indirectly with<br /><br /> *(int *)((char *)structp + offsetb) = value;<br /><br />2.18: This program works correctly, but it dumps core after it<br /> finishes. Why?<br /><br /> struct list {<br /> char *item;<br /> struct list *next;<br /> }<br /><br /> /* Here is the main program. */<br /><br /> main(argc, argv)<br /> { ... }<br /><br />A: A missing semicolon causes main() to be declared as returning a<br /> structure. (The connection is hard to see because of the<br /> intervening comment.) Since structure-valued functions are<br /> usually implemented by adding a hidden return pointer, the<br /> generated code for main() tries to accept three arguments,<br /> although only two are passed (in this case, by the C start-up<br /> code). See also questions 10.9 and 16.4.<br /><br /> References: CT&P Sec. 2.3 pp. 21-2.<br /><br />2.20: Can I initialize unions?<br /><br />A: The current C Standard allows an initializer for the first-named<br /> member of a union. C9X will introduce "designated initializers"<br /> which can be used to initialize any member.<br /><br /> References: K&R2 Sec. 6.8 pp. 148-9; ISO Sec. 6.5.7; C9X<br /> Sec. 6.5.8; H&S Sec. 4.6.7 p. 100.<br /><br />2.22: What is the difference between an enumeration and a set of<br /> preprocessor #defines?<br /><br />A: At the present time, there is little difference. The C Standard<br /> says that enumerations may be freely intermixed with other<br /> integral types, without errors. (If, on the other hand, such<br /> intermixing were disallowed without explicit casts, judicious<br /> use of enumerations could catch certain programming errors.)<br /><br /> Some advantages of enumerations are that the numeric values are<br /> automatically assigned, that a debugger may be able to display<br /> the symbolic values when enumeration variables are examined, and<br /> that they obey block scope. (A compiler may also generate<br /> nonfatal warnings when enumerations and integers are<br /> indiscriminately mixed, since doing so can still be considered<br /> bad style even though it is not strictly illegal.) A<br /> disadvantage is that the programmer has little control over<br /> those nonfatal warnings; some programmers also resent not having<br /> control over the sizes of enumeration variables.<br /><br /> References: K&R2 Sec. 2.3 p. 39, Sec. A4.2 p. 196; ISO<br /> Sec. 6.1.2.5, Sec. 6.5.2, Sec. 6.5.2.2, Annex F; H&S Sec. 5.5<br /> pp. 127-9, Sec. 5.11.2 p. 153.<br /><br />2.24: Is there an easy way to print enumeration values symbolically?<br /><br />A: No. You can write a little function to map an enumeration<br /> constant to a string. (For debugging purposes, a good debugger<br /> should automatically print enumeration constants symbolically.)<br /><br /><br />Section 3. Expressions<br /><br />3.1: Why doesn't this code:<br /><br /> a[i] = i++;<br /><br /> work?<br /><br />A: The subexpression i++ causes a side effect -- it modifies i's<br /> value -- which leads to undefined behavior since i is also<br /> referenced elsewhere in the same expression, and there's no way<br /> to determine whether the reference (in a[i] on the left-hand<br /> side) should be to the old or the new value. (Note that<br /> although the language in K&R suggests that the behavior of this<br /> expression is unspecified, the C Standard makes the stronger<br /> statement that it is undefined -- see question 11.33.)<br /><br /> References: K&R1 Sec. 2.12; K&R2 Sec. 2.12; ISO Sec. 6.3; H&S<br /> Sec. 7.12 pp. 227-9.<br /><br />3.2: Under my compiler, the code<br /><br /> int i = 7;<br /> printf("%d\n", i++ * i++);<br /><br /> prints 49. Regardless of the order of evaluation, shouldn't it<br /> print 56?<br /><br />A: Although the postincrement and postdecrement operators ++ and --<br /> perform their operations after yielding the former value, the<br /> implication of "after" is often misunderstood. It is *not*<br /> guaranteed that an increment or decrement is performed<br /> immediately after giving up the previous value and before any<br /> other part of the expression is evaluated. It is merely<br /> guaranteed that the update will be performed sometime before the<br /> expression is considered "finished" (before the next "sequence<br /> point," in ANSI C's terminology; see question 3.8). In the<br /> example, the compiler chose to multiply the previous value by<br /> itself and to perform both increments afterwards.<br /><br /> The behavior of code which contains multiple, ambiguous side<br /> effects has always been undefined. (Loosely speaking, by<br /> "multiple, ambiguous side effects" we mean any combination of<br /> ++, --, =, +=, -=, etc. in a single expression which causes the<br /> same object either to be modified twice or modified and then<br /> inspected. This is a rough definition; see question 3.8 for a<br /> precise one, and question 11.33 for the meaning of "undefined.")<br /> Don't even try to find out how your compiler implements such<br /> things (contrary to the ill-advised exercises in many C<br /> textbooks); as K&R wisely point out, "if you don't know *how*<br /> they are done on various machines, that innocence may help to<br /> protect you."<br /><br /> References: K&R1 Sec. 2.12 p. 50; K&R2 Sec. 2.12 p. 54; ISO<br /> Sec. 6.3; H&S Sec. 7.12 pp. 227-9; CT&P Sec. 3.7 p. 47; PCS<br /> Sec. 9.5 pp. 120-1.<br /><br />3.3: I've experimented with the code<br /><br /> int i = 3;<br /> i = i++;<br /><br /> on several compilers. Some gave i the value 3, and some gave 4.<br /> Which compiler is correct?<br /><br />A: There is no correct answer; the expression is undefined. See<br /> questions 3.1, 3.8, 3.9, and 11.33. (Also, note that neither<br /> i++ nor ++i is the same as i+1. If you want to increment i,<br /> use i=i+1, i+=1, i++, or ++i, not some combination. See also<br /> question 3.12.)<br /><br />3.3b: Here's a slick expression:<br /><br /> a ^= b ^= a ^= b<br /><br /> It swaps a and b without using a temporary.<br /><br />A: Not portably, it doesn't. It attempts to modify the variable a<br /> twice between sequence points, so its behavior is undefined.<br /><br /> For example, it has been reported that when given the code<br /><br /> int a = 123, b = 7654;<br /> a ^= b ^= a ^= b;<br /><br /> the SCO Optimizing C compiler (icc) sets b to 123 and a to 0.<br /><br /> See also questions 3.1, 3.8, 10.3, and 20.15c.<br /><br />3.4: Can I use explicit parentheses to force the order of evaluation<br /> I want? Even if I don't, doesn't precedence dictate it?<br /><br />A: Not in general.<br /><br /> Operator precedence and explicit parentheses impose only a<br /> partial ordering on the evaluation of an expression. In the<br /> expression<br /><br /> f() + g() * h()<br /><br /> although we know that the multiplication will happen before the<br /> addition, there is no telling which of the three functions will<br /> be called first.<br /><br /> When you need to ensure the order of subexpression evaluation,<br /> you may need to use explicit temporary variables and separate<br /> statements.<br /><br /> References: K&R1 Sec. 2.12 p. 49, Sec. A.7 p. 185; K&R2<br /> Sec. 2.12 pp. 52-3, Sec. A.7 p. 200.<br /><br />3.5: But what about the && and || operators?<br /> I see code like "while((c = getchar()) != EOF && c != '\n')" ...<br /><br />A: There is a special "short-circuiting" exception for those<br /> operators. The right-hand side is not evaluated if the left-<br /> hand side determines the outcome (i.e. is true for || or false<br /> for &&). Therefore, left-to-right evaluation is guaranteed, as<br /> it also is for the comma operator. Furthermore, all of these<br /> operators (along with ?:) introduce an extra internal sequence<br /> point (see question 3.8).<br /><br /> References: K&R1 Sec. 2.6 p. 38, Secs. A7.11-12 pp. 190-1; K&R2<br /> Sec. 2.6 p. 41, Secs. A7.14-15 pp. 207-8; ISO Sec. 6.3.13,<br /> Sec. 6.3.14, Sec. 6.3.15; H&S Sec. 7.7 pp. 217-8, Sec. 7.8 pp.<br /> 218-20, Sec. 7.12.1 p. 229; CT&P Sec. 3.7 pp. 46-7.<br /><br />3.8: How can I understand these complex expressions? What's a<br /> "sequence point"?<br /><br />A: A sequence point is a point in time (at the end of the<br /> evaluation of a full expression, or at the ||, &&, ?:, or comma<br /> operators, or just before a function call) at which the dust<br /> has settled and all side effects are guaranteed to be complete.<br /> The ANSI/ISO C Standard states that<br /><br /> Between the previous and next sequence point an<br /> object shall have its stored value modified at<br /> most once by the evaluation of an expression.<br /> Furthermore, the prior value shall be accessed<br /> only to determine the value to be stored.<br /><br /> The second sentence can be difficult to understand. It says<br /> that if an object is written to within a full expression, any<br /> and all accesses to it within the same expression must be for<br /> the purposes of computing the value to be written. This rule<br /> effectively constrains legal expressions to those in which the<br /> accesses demonstrably precede the modification.<br /><br /> See also question 3.9 below.<br /><br /> References: ISO Sec. 5.1.2.3, Sec. 6.3, Sec. 6.6, Annex C;<br /> Rationale Sec. 2.1.2.3; H&S Sec. 7.12.1 pp. 228-9.<br /><br />3.9: So given<br /><br /> a[i] = i++;<br /><br /> we don't know which cell of a[] gets written to, but i does get<br /> incremented by one, right?<br /><br />A: *No*. Once an expression or program becomes undefined, *all*<br /> aspects of it become undefined. See questions 3.2, 3.3, 11.33,<br /> and 11.35.<br /><br />3.12: If I'm not using the value of the expression, should I use i++<br /> or ++i to increment a variable?<br /><br />A: Since the two forms differ only in the value yielded, they are<br /> entirely equivalent when only their side effect is needed.<br /> (However, the prefix form is preferred in C++.) See also<br /> question 3.3.<br /><br /> References: K&R1 Sec. 2.8 p. 43; K&R2 Sec. 2.8 p. 47; ISO<br /> Sec. 6.3.2.4, Sec. 6.3.3.1; H&S Sec. 7.4.4 pp. 192-3, Sec. 7.5.8<br /> pp. 199-200.<br /><br />3.14: Why doesn't the code<br /><br /> int a = 1000, b = 1000;<br /> long int c = a * b;<br /><br /> work?<br /><br />A: Under C's integral promotion rules, the multiplication is<br /> carried out using int arithmetic, and the result may overflow or<br /> be truncated before being promoted and assigned to the long int<br /> left-hand side. Use an explicit cast to force long arithmetic:<br /><br /> long int c = (long int)a * b;<br /><br /> Note that (long int)(a * b) would *not* have the desired effect.<br /><br /> A similar problem can arise when two integers are divided, with<br /> the result assigned to a floating-point variable; the solution<br /> is similar, too.<br /><br /> References: K&R1 Sec. 2.7 p. 41; K&R2 Sec. 2.7 p. 44; ISO<br /> Sec. 6.2.1.5; H&S Sec. 6.3.4 p. 176; CT&P Sec. 3.9 pp. 49-50.<br /><br />3.16: I have a complicated expression which I have to assign to one of<br /> two variables, depending on a condition. Can I use code like<br /> this?<br /><br /> ((condition) ? a : b) = complicated_expression;<br /><br />A: No. The ?: operator, like most operators, yields a value, and<br /> you can't assign to a value. (In other words, ?: does not yield<br /> an "lvalue".) If you really want to, you can try something like<br /><br /> *((condition) ? &a : &b) = complicated_expression;<br /><br /> although this is admittedly not as pretty.<br /><br /> References: ISO Sec. 6.3.15; H&S Sec. 7.1 pp. 179-180.<br /><br /><br />Section 4. Pointers<br /><br />4.2: I'm trying to declare a pointer and allocate some space for it,<br /> but it's not working. What's wrong with this code?<br /><br /> char *p;<br /> *p = malloc(10);<br /><br />A: The pointer you declared is p, not *p. To make a pointer point<br /> somewhere, you just use the name of the pointer:<br /><br /> p = malloc(10);<br /><br /> It's when you're manipulating the pointed-to memory that you use<br /> * as an indirection operator:<br /><br /> *p = 'H';<br /><br /> See also questions 1.21, 7.1, 7.3c, and 8.3.<br /><br /> References: CT&P Sec. 3.1 p. 28.<br /><br />4.3: Does *p++ increment p, or what it points to?<br /><br />A: Postfix ++ essentially has higher precedence than the prefix<br /> unary operators. Therefore, *p++ is equivalent to *(p++); it<br /> increments p, and returns the value which p pointed to before p<br /> was incremented. To increment the value pointed to by p, use<br /> (*p)++ (or perhaps ++*p, if the order of the side effect doesn't<br /> matter).<br /><br /> References: K&R1 Sec. 5.1 p. 91; K&R2 Sec. 5.1 p. 95; ISO<br /> Sec. 6.3.2, Sec. 6.3.3; H&S Sec. 7.4.4 pp. 192-3, Sec. 7.5 p.<br /> 193, Secs. 7.5.7,7.5.8 pp. 199-200.<br /><br />4.5: I have a char * pointer that happens to point to some ints, and<br /> I want to step it over them. Why doesn't<br /><br /> ((int *)p)++;<br /><br /> work?<br /><br />A: In C, a cast operator does not mean "pretend these bits have a<br /> different type, and treat them accordingly"; it is a conversion<br /> operator, and by definition it yields an rvalue, which cannot be<br /> assigned to, or incremented with ++. (It is either an accident<br /> or a delibrate but nonstandard extension if a particular<br /> compiler accepts expressions such as the above.) Say what you<br /> mean: use<br /><br /> p = (char *)((int *)p + 1);<br /><br /> or (since p is a char *) simply<br /><br /> p += sizeof(int);<br /><br /> Whenever possible, you should choose appropriate pointer types<br /> in the first place, instead of trying to treat one type as<br /> another.<br /><br /> References: K&R2 Sec. A7.5 p. 205; ISO Sec. 6.3.4; Rationale<br /> Sec. 3.3.2.4; H&S Sec. 7.1 pp. 179-80.<br /><br />4.8: I have a function which accepts, and is supposed to initialize,<br /> a pointer:<br /><br /> void f(int *ip)<br /> {<br /> static int dummy = 5;<br /> ip = &dummy;<br /> }<br /><br /> But when I call it like this:<br /><br /> int *ip;<br /> f(ip);<br /><br /> the pointer in the caller remains unchanged.<br /><br />A: Are you sure the function initialized what you thought it did?<br /> Remember that arguments in C are passed by value. The called<br /> function altered only the passed copy of the pointer. You'll<br /> either want to pass the address of the pointer (the function<br /> will end up accepting a pointer-to-a-pointer), or have the<br /> function return the pointer.<br /><br /> See also questions 4.9 and 4.11.<br /><br />4.9: Can I use a void ** pointer as a parameter so that a function<br /> can accept a generic pointer by reference?<br /><br />A: Not portably. There is no generic pointer-to-pointer type in C.<br /> void * acts as a generic pointer only because conversions are<br /> applied automatically when other pointer types are assigned to<br /> and from void *'s; these conversions cannot be performed (the<br /> correct underlying pointer type is not known) if an attempt is<br /> made to indirect upon a void ** value which points at a pointer<br /> type other than void *.<br /><br />4.10: I have a function<br /><br /> extern int f(int *);<br /><br /> which accepts a pointer to an int. How can I pass a constant by<br /> reference? A call like<br /><br /> f(&5);<br /><br /> doesn't seem to work.<br /><br />A: You can't do this directly. You will have to declare a<br /> temporary variable, and then pass its address to the function:<br /><br /> int five = 5;<br /> f(&five);<br /><br /> See also questions 2.10, 4.8, and 20.1.<br /><br />4.11: Does C even have "pass by reference"?<br /><br />A: Not really. Strictly speaking, C always uses pass by value.<br /> You can simulate pass by reference yourself, by defining<br /> functions which accept pointers and then using the & operator<br /> when calling, and the compiler will essentially simulate it for<br /> you when you pass an array to a function (by passing a pointer<br /> instead, see question 6.4 et al.). However, C has nothing truly<br /> equivalent to formal pass by reference or C++ reference<br /> parameters. (On the other hand, function-like preprocessor<br /> macros can provide a form of "pass by name".)<br /><br /> See also questions 4.8 and 20.1.<br /><br /> References: K&R1 Sec. 1.8 pp. 24-5, Sec. 5.2 pp. 91-3; K&R2<br /> Sec. 1.8 pp. 27-8, Sec. 5.2 pp. 95-7; ISO Sec. 6.3.2.2; H&S<br /> Sec. 9.5 pp. 273-4.<br /><br />4.12: I've seen different methods used for calling functions via<br /> pointers. What's the story?<br /><br />A: Originally, a pointer to a function had to be "turned into" a<br /> "real" function, with the * operator (and an extra pair of<br /> parentheses, to keep the precedence straight), before calling:<br /><br /> int r, func(), (*fp)() = func;<br /> r = (*fp)();<br /><br /> It can also be argued that functions are always called via<br /> pointers, and that "real" function names always decay implicitly<br /> into pointers (in expressions, as they do in initializations;<br /> see question 1.34). This reasoning (which is in fact used in<br /> the ANSI standard) means that<br /><br /> r = fp();<br /><br /> is legal and works correctly, whether fp is the name of a<br /> function or a pointer to one. (The usage has always been<br /> unambiguous; there is nothing you ever could have done with a<br /> function pointer followed by an argument list except call the<br /> function pointed to.) An explicit * is still allowed.<br /><br /> See also question 1.34.<br /><br /> References: K&R1 Sec. 5.12 p. 116; K&R2 Sec. 5.11 p. 120; ISO<br /> Sec. 6.3.2.2; Rationale Sec. 3.3.2.2; H&S Sec. 5.8 p. 147,<br /> Sec. 7.4.3 p. 190.<br /><br /><br />Section 5. Null Pointers<br /><br />5.1: What is this infamous null pointer, anyway?<br /><br />A: The language definition states that for each pointer type, there<br /> is a special value -- the "null pointer" -- which is<br /> distinguishable from all other pointer values and which is<br /> "guaranteed to compare unequal to a pointer to any object or<br /> function." That is, the address-of operator & will never yield<br /> a null pointer, nor will a successful call to malloc().<br /> (malloc() does return a null pointer when it fails, and this is<br /> a typical use of null pointers: as a "special" pointer value<br /> with some other meaning, usually "not allocated" or "not<br /> pointing anywhere yet.")<br /><br /> A null pointer is conceptually different from an uninitialized<br /> pointer. A null pointer is known not to point to any object or<br /> function; an uninitialized pointer might point anywhere. See<br /> also questions 1.30, 7.1, and 7.31.<br /><br /> As mentioned above, there is a null pointer for each pointer<br /> type, and the internal values of null pointers for different<br /> types may be different. Although programmers need not know the<br /> internal values, the compiler must always be informed which type<br /> of null pointer is required, so that it can make the distinction<br /> if necessary (see questions 5.2, 5.5, and 5.6 below).<br /><br /> References: K&R1 Sec. 5.4 pp. 97-8; K&R2 Sec. 5.4 p. 102; ISO<br /> Sec. 6.2.2.3; Rationale Sec. 3.2.2.3; H&S Sec. 5.3.2 pp. 121-3.<br /><br />5.2: How do I get a null pointer in my programs?<br /><br />A: According to the language definition, a constant 0 in a pointer<br /> context is converted into a null pointer at compile time. That<br /> is, in an initialization, assignment, or comparison when one<br /> side is a variable or expression of pointer type, the compiler<br /> can tell that a constant 0 on the other side requests a null<br /> pointer, and generate the correctly-typed null pointer value.<br /> Therefore, the following fragments are perfectly legal:<br /><br /> char *p = 0;<br /> if(p != 0)<br /><br /> (See also question 5.3.)<br /><br /> However, an argument being passed to a function is not<br /> necessarily recognizable as a pointer context, and the compiler<br /> may not be able to tell that an unadorned 0 "means" a null<br /> pointer. To generate a null pointer in a function call context,<br /> an explicit cast may be required, to force the 0 to be<br /> recognized as a pointer. For example, the Unix system call<br /> execl takes a variable-length, null-pointer-terminated list of<br /> character pointer arguments, and is correctly called like this:<br /><br /> execl("/bin/sh", "sh", "-c", "date", (char *)0);<br /><br /> If the (char *) cast on the last argument were omitted, the<br /> compiler would not know to pass a null pointer, and would pass<br /> an integer 0 instead. (Note that many Unix manuals get this<br /> example wrong.)<br /><br /> When function prototypes are in scope, argument passing becomes<br /> an "assignment context," and most casts may safely be omitted,<br /> since the prototype tells the compiler that a pointer is<br /> required, and of which type, enabling it to correctly convert an<br /> unadorned 0. Function prototypes cannot provide the types for<br /> variable arguments in variable-length argument lists however, so<br /> explicit casts are still required for those arguments. (See<br /> also question 15.3.) It is probably safest to properly cast<br /> all null pointer constants in function calls, to guard against<br /> varargs functions or those without prototypes.<br /><br /> Summary:<br /><br /> Unadorned 0 okay: Explicit cast required:<br /><br /> initialization function call,<br /> no prototype in scope<br /> assignment<br /> variable argument in<br /> comparison varargs function call<br /><br /> function call,<br /> prototype in scope,<br /> fixed argument<br /><br /> References: K&R1 Sec. A7.7 p. 190, Sec. A7.14 p. 192; K&R2<br /> Sec. A7.10 p. 207, Sec. A7.17 p. 209; ISO Sec. 6.2.2.3; H&S<br /> Sec. 4.6.3 p. 95, Sec. 6.2.7 p. 171.<br /><br />5.3: Is the abbreviated pointer comparison "if(p)" to test for non-<br /> null pointers valid? What if the internal representation for<br /> null pointers is nonzero?<br /><br />A: When C requires the Boolean value of an expression, a false<br /> value is inferred when the expression compares equal to zero,<br /> and a true value otherwise. That is, whenever one writes<br /><br /> if(expr)<br /><br /> where "expr" is any expression at all, the compiler essentially<br /> acts as if it had been written as<br /><br /> if((expr) != 0)<br /><br /> Substituting the trivial pointer expression "p" for "expr", we<br /> have<br /><br /> if(p) is equivalent to if(p != 0)<br /><br /> and this is a comparison context, so the compiler can tell that<br /> the (implicit) 0 is actually a null pointer constant, and use<br /> the correct null pointer value. There is no trickery involved<br /> here; compilers do work this way, and generate identical code<br /> for both constructs. The internal representation of a null<br /> pointer does *not* matter.<br /><br /> The boolean negation operator, !, can be described as follows:<br /><br /> !expr is essentially equivalent to (expr)?0:1<br /> or to ((expr) == 0)<br /><br /> which leads to the conclusion that<br /><br /> if(!p) is equivalent to if(p == 0)<br /><br /> "Abbreviations" such as if(p), though perfectly legal, are<br /> considered by some to be bad style (and by others to be good<br /> style; see question 17.10).<br /><br /> See also question 9.2.<br /><br /> References: K&R2 Sec. A7.4.7 p. 204; ISO Sec. 6.3.3.3,<br /> Sec. 6.3.9, Sec. 6.3.13, Sec. 6.3.14, Sec. 6.3.15, Sec. 6.6.4.1,<br /> Sec. 6.6.5; H&S Sec. 5.3.2 p. 122.<br /><br />5.4: What is NULL and how is it #defined?<br /><br />A: As a matter of style, many programmers prefer not to have<br /> unadorned 0's scattered through their programs. Therefore, the<br /> preprocessor macro NULL is #defined (by <stdio.h> and several<br /> other headers) with the value 0, possibly cast to (void *) (see<br /> also question 5.6). A programmer who wishes to make explicit<br /> the distinction between 0 the integer and 0 the null pointer<br /> constant can then use NULL whenever a null pointer is required.<br /><br /> Using NULL is a stylistic convention only; the preprocessor<br /> turns NULL back into 0 which is then recognized by the compiler,<br /> in pointer contexts, as before. In particular, a cast may still<br /> be necessary before NULL (as before 0) in a function call<br /> argument. The table under question 5.2 above applies for NULL<br /> as well as 0 (an unadorned NULL is equivalent to an unadorned<br /> 0).<br /><br /> NULL should *only* be used for pointers; see question 5.9.<br /><br /> References: K&R1 Sec. 5.4 pp. 97-8; K&R2 Sec. 5.4 p. 102; ISO<br /> Sec. 7.1.6, Sec. 6.2.2.3; Rationale Sec. 4.1.5; H&S Sec. 5.3.2<br /> p. 122, Sec. 11.1 p. 292.<br /><br />5.5: How should NULL be defined on a machine which uses a nonzero bit<br /> pattern as the internal representation of a null pointer?<br /><br />A: The same as on any other machine: as 0 (or some version of 0;<br /> see question 5.4).<br /><br /> Whenever a programmer requests a null pointer, either by writing<br /> "0" or "NULL", it is the compiler's responsibility to generate<br /> whatever bit pattern the machine uses for that null pointer.<br /> Therefore, #defining NULL as 0 on a machine for which internal<br /> null pointers are nonzero is as valid as on any other: the<br /> compiler must always be able to generate the machine's correct<br /> null pointers in response to unadorned 0's seen in pointer<br /> contexts. See also questions 5.2, 5.10, and 5.17.<br /><br /> References: ISO Sec. 7.1.6; Rationale Sec. 4.1.5.<br /><br />5.6: If NULL were defined as follows:<br /><br /> #define NULL ((char *)0)<br /><br /> wouldn't that make function calls which pass an uncast NULL<br /> work?<br /><br />A: Not in general. The complication is that there are machines<br /> which use different internal representations for pointers to<br /> different types of data. The suggested definition would make<br /> uncast NULL arguments to functions expecting pointers to<br /> characters work correctly, but pointer arguments of other types<br /> would still be problematical, and legal constructions such as<br /><br /> FILE *fp = NULL;<br /><br /> could fail.<br /><br /> Nevertheless, ANSI C allows the alternate definition<br /><br /> #define NULL ((void *)0)<br /><br /> for NULL. Besides potentially helping incorrect programs to<br /> work (but only on machines with homogeneous pointers, thus<br /> questionably valid assistance), this definition may catch<br /> programs which use NULL incorrectly (e.g. when the ASCII NUL<br /> character was really intended; see question 5.9).<br /><br /> References: Rationale Sec. 4.1.5.<br /><br />5.9: If NULL and 0 are equivalent as null pointer constants, which<br /> should I use?<br /><br />A: Many programmers believe that NULL should be used in all pointer<br /> contexts, as a reminder that the value is to be thought of as a<br /> pointer. Others feel that the confusion surrounding NULL and 0<br /> is only compounded by hiding 0 behind a macro, and prefer to use<br /> unadorned 0 instead. There is no one right answer. (See also<br /> questions 9.2 and 17.10.) C programmers must understand that<br /> NULL and 0 are interchangeable in pointer contexts, and that an<br /> uncast 0 is perfectly acceptable. Any usage of NULL (as opposed<br /> to 0) should be considered a gentle reminder that a pointer is<br /> involved; programmers should not depend on it (either for their<br /> own understanding or the compiler's) for distinguishing pointer<br /> 0's from integer 0's.<br /><br /> NULL should *not* be used when another kind of 0 is required,<br /> even though it might work, because doing so sends the wrong<br /> stylistic message. (Furthermore, ANSI allows the definition of<br /> NULL to be ((void *)0), which will not work at all in non-<br /> pointer contexts.) In particular, do not use NULL when the<br /> ASCII null character (NUL) is desired. Provide your own<br /> definition<br /><br /> #define NUL '\0'<br /><br /> if you must.<br /><br /> References: K&R1 Sec. 5.4 pp. 97-8; K&R2 Sec. 5.4 p. 102.<br /><br />5.10: But wouldn't it be better to use NULL (rather than 0), in case<br /> the value of NULL changes, perhaps on a machine with nonzero<br /> internal null pointers?<br /><br />A: No. (Using NULL may be preferable, but not for this reason.)<br /> Although symbolic constants are often used in place of numbers<br /> because the numbers might change, this is *not* the reason that<br /> NULL is used in place of 0. Once again, the language guarantees<br /> that source-code 0's (in pointer contexts) generate null<br /> pointers. NULL is used only as a stylistic convention. See<br /> questions 5.5 and 9.2.<br /><br />5.12: I use the preprocessor macro<br /><br /> #define Nullptr(type) (type *)0<br /><br /> to help me build null pointers of the correct type.<br /><br />A: This trick, though popular and superficially attractive, does<br /> not buy much. It is not needed in assignments or comparisons;<br /> see question 5.2. (It does not even save keystrokes.) See also<br /> questions 9.1 and 10.2.<br /><br />5.13: This is strange. NULL is guaranteed to be 0, but the null<br /> pointer is not?<br /><br />A: When the term "null" or "NULL" is casually used, one of several<br /> things may be meant:<br /><br /> 1. The conceptual null pointer, the abstract language concept<br /> defined in question 5.1. It is implemented with...<br /><br /> 2. The internal (or run-time) representation of a null<br /> pointer, which may or may not be all-bits-0 and which may<br /> be different for different pointer types. The actual<br /> values should be of concern only to compiler writers.<br /> Authors of C programs never see them, since they use...<br /><br /> 3. The null pointer constant, which is a constant integer 0<br /> (see question 5.2). It is often hidden behind...<br /><br /> 4. The NULL macro, which is #defined to be 0 (see question<br /> 5.4). Finally, as red herrings, we have...<br /><br /> 5. The ASCII null character (NUL), which does have all bits<br /> zero, but has no necessary relation to the null pointer<br /> except in name; and...<br /><br /> 6. The "null string," which is another name for the empty<br /> string (""). Using the term "null string" can be<br /> confusing in C, because an empty string involves a null<br /> ('\0') character, but *not* a null pointer, which brings<br /> us full circle...<br /><br /> This article uses the phrase "null pointer" (in lower case) for<br /> sense 1, the character "0" or the phrase "null pointer constant"<br /> for sense 3, and the capitalized word "NULL" for sense 4.<br /><br />5.14: Why is there so much confusion surrounding null pointers? Why<br /> do these questions come up so often?<br /><br />A: C programmers traditionally like to know more than they might<br /> need to about the underlying machine implementation. The fact<br /> that null pointers are represented both in source code, and<br /> internally to most machines, as zero invites unwarranted<br /> assumptions. The use of a preprocessor macro (NULL) may seem<br /> to suggest that the value could change some day, or on some<br /> weird machine. The construct "if(p == 0)" is easily misread<br /> as calling for conversion of p to an integral type, rather<br /> than 0 to a pointer type, before the comparison. Finally,<br /> the distinction between the several uses of the term "null"<br /> (listed in question 5.13 above) is often overlooked.<br /><br /> One good way to wade out of the confusion is to imagine that C<br /> used a keyword (perhaps "nil", like Pascal) as a null pointer<br /> constant. The compiler could either turn "nil" into the<br /> appropriate type of null pointer when it could unambiguously<br /> determine that type from the source code, or complain when it<br /> could not. Now in fact, in C the keyword for a null pointer<br /> constant is not "nil" but "0", which works almost as well,<br /> except that an uncast "0" in a non-pointer context generates an<br /> integer zero instead of an error message, and if that uncast 0<br /> was supposed to be a null pointer constant, the code may not<br /> work.<br /><br />5.15: I'm confused. I just can't understand all this null pointer<br /> stuff.<br /><br />A: Here are two simple rules you can follow:<br /><br /> 1. When you want a null pointer constant in source code,<br /> use "0" or "NULL".<br /><br /> 2. If the usage of "0" or "NULL" is an argument in a<br /> function call, cast it to the pointer type expected by<br /> the function being called.<br /><br /> The rest of the discussion has to do with other people's<br /> misunderstandings, with the internal representation of null<br /> pointers (which you shouldn't need to know), and with the<br /> complexities of function prototypes. (Taking those complexities<br /> into account, we find that rule 2 is conservative, of course;<br /> but it doesn't hurt.) Understand questions 5.1, 5.2, and 5.4,<br /> and consider 5.3, 5.9, 5.13, and 5.14, and you'll do fine.<br /><br />5.16: Given all the confusion surrounding null pointers, wouldn't it<br /> be easier simply to require them to be represented internally by<br /> zeroes?<br /><br />A: If for no other reason, doing so would be ill-advised because it<br /> would unnecessarily constrain implementations which would<br /> otherwise naturally represent null pointers by special, nonzero<br /> bit patterns, particularly when those values would trigger<br /> automatic hardware traps for invalid accesses.<br /><br /> Besides, what would such a requirement really accomplish?<br /> Proper understanding of null pointers does not require knowledge<br /> of the internal representation, whether zero or nonzero.<br /> Assuming that null pointers are internally zero does not make<br /> any code easier to write (except for a certain ill-advised usage<br /> of calloc(); see question 7.31). Known-zero internal pointers<br /> would not obviate casts in function calls, because the *size* of<br /> the pointer might still be different from that of an int. (If<br /> "nil" were used to request null pointers, as mentioned in<br /> question 5.14 above, the urge to assume an internal zero<br /> representation would not even arise.)<br /><br />5.17: Seriously, have any actual machines really used nonzero null<br /> pointers, or different representations for pointers to different<br /> types?<br /><br />A: The Prime 50 series used segment 07777, offset 0 for the null<br /> pointer, at least for PL/I. Later models used segment 0, offset<br /> 0 for null pointers in C, necessitating new instructions such as<br /> TCNP (Test C Null Pointer), evidently as a sop to all the extant<br /> poorly-written C code which made incorrect assumptions. Older,<br /> word-addressed Prime machines were also notorious for requiring<br /> larger byte pointers (char *'s) than word pointers (int *'s).<br /><br /> The Eclipse MV series from Data General has three<br /> architecturally supported pointer formats (word, byte, and bit<br /> pointers), two of which are used by C compilers: byte pointers<br /> for char * and void *, and word pointers for everything else.<br /><br /> Some Honeywell-Bull mainframes use the bit pattern 06000 for<br /> (internal) null pointers.<br /><br /> The CDC Cyber 180 Series has 48-bit pointers consisting of a<br /> ring, segment, and offset. Most users (in ring 11) have null<br /> pointers of 0xB00000000000. It was common on old CDC ones-<br /> complement machines to use an all-one-bits word as a special<br /> flag for all kinds of data, including invalid addresses.<br /><br /> The old HP 3000 series uses a different addressing scheme for<br /> byte addresses than for word addresses; like several of the<br /> machines above it therefore uses different representations for<br /> char * and void * pointers than for other pointers.<br /><br /> The Symbolics Lisp Machine, a tagged architecture, does not even<br /> have conventional numeric pointers; it uses the pair <nil,><br /> (basically a nonexistent <object,> handle) as a C null<br /> pointer.<br /><br /> Depending on the "memory model" in use, 8086-family processors<br /> (PC compatibles) may use 16-bit data pointers and 32-bit<br /> function pointers, or vice versa.<br /><br /> Some 64-bit Cray machines represent int * in the lower 48 bits<br /> of a word; char * additionally uses the upper 16 bits to<br /> indicate a byte address within a word.<br /><br /> References: K&R1 Sec. A14.4 p. 211.<br /><br />5.20: What does a run-time "null pointer assignment" error mean?<br /> How can I track it down?<br /><br />A: This message, which typically occurs with MS-DOS compilers, means<br /> that you've written, via a null (perhaps because uninitialized)<br /> pointer, to an invalid location (probably offset 0 in the<br /> default data segment).<br /><br /> A debugger may let you set a data watchpoint on location 0.<br /> Alternatively, you could write a bit of code to stash away a<br /> copy of 20 or so bytes from location 0, and periodically check<br /> that the memory at location 0 hasn't changed. See also question<br /> 16.8.<br /><br /><br />Section 6. Arrays and Pointers<br /><br />6.1: I had the definition char a[6] in one source file, and in<br /> another I declared extern char *a. Why didn't it work?<br /><br />A: In one source file you defind an array of characters and in the<br /> other you declared a pointer to characters. The declaration<br /> extern char *a simply does not match the actual definition.<br /> The type pointer-to-type-T is not the same as array-of-type-T.<br /> Use extern char a[].<br /><br /> References: ISO Sec. 6.5.4.2; CT&P Sec. 3.3 pp. 33-4, Sec. 4.5<br /> pp. 64-5.<br /><br />6.2: But I heard that char a[] was identical to char *a.<br /><br />A: Not at all. (What you heard has to do with formal parameters to<br /> functions; see question 6.4.) Arrays are not pointers. The<br /> array declaration char a[6] requests that space for six<br /> characters be set aside, to be known by the name "a". That is,<br /> there is a location named "a" at which six characters can sit.<br /> The pointer declaration char *p, on the other hand, requests a<br /> place which holds a pointer, to be known by the name "p". This<br /> pointer can point almost anywhere: to any char, or to any<br /> contiguous array of chars, or nowhere (see also questions 5.1<br /> and 1.30).<br /><br /> As usual, a picture is worth a thousand words. The declarations<br /><br /> char a[] = "hello";<br /> char *p = "world";<br /><br /> would initialize data structures which could be represented like<br /> this:<br /> +---+---+---+---+---+---+<br /> a: | h | e | l | l | o |\0 |<br /> +---+---+---+---+---+---+<br /> +-----+ +---+---+---+---+---+---+<br /> p: | *======> | w | o | r | l | d |\0 |<br /> +-----+ +---+---+---+---+---+---+<br /><br /> It is important to realize that a reference like x[3] generates<br /> different code depending on whether x is an array or a pointer.<br /> Given the declarations above, when the compiler sees the<br /> expression a[3], it emits code to start at the location "a",<br /> move three past it, and fetch the character there. When it sees<br /> the expression p[3], it emits code to start at the location "p",<br /> fetch the pointer value there, add three to the pointer, and<br /> finally fetch the character pointed to. In other words, a[3] is<br /> three places past (the start of) the object *named* a, while<br /> p[3] is three places past the object *pointed to* by p. In the<br /> example above, both a[3] and p[3] happen to be the character<br /> 'l', but the compiler gets there differently. (The essential<br /> difference is that the values of an array like a and a pointer<br /> like p are computed differently *whenever* they appear in<br /> expressions, whether or not they are being subscripted, as<br /> explained further in the next question.)<br /><br /> References: K&R2 Sec. 5.5 p. 104; CT&P Sec. 4.5 pp. 64-5.<br /><br />6.3: So what is meant by the "equivalence of pointers and arrays" in<br /> C?<br /><br />A: Much of the confusion surrounding arrays and pointers in C can<br /> be traced to a misunderstanding of this statement. Saying that<br /> arrays and pointers are "equivalent" means neither that they are<br /> identical nor even interchangeable. What it means is that array<br /> and pointer arithmetic is defined such that a pointer can be<br /> conveniently used to access an array or to simulate an array.<br /><br /> Specifically, the cornerstone of the equivalence is this key<br /> definition:<br /><br /> An lvalue of type array-of-T which appears in an<br /> expression decays (with three exceptions) into a<br /> pointer to its first element; the type of the<br /> resultant pointer is pointer-to-T.<br /><br /> That is, whenever an array appears in an expression,<br /> the compiler implicitly generates a pointer to the array's<br /> first element, just as if the programmer had written &a[0].<br /> (The exceptions are when the array is the operand of a sizeof or<br /> & operator, or is a string literal initializer for a character<br /> array.)<br /><br /> As a consequence of this definition, the compiler doesn't apply<br /> the array subscripting operator [] that differently to arrays<br /> and pointers, after all. In an expression of the form a[i], the<br /> array decays into a pointer, following the rule above, and is<br /> then subscripted just as would be a pointer variable in the<br /> expression p[i] (although the eventual memory accesses will be<br /> different, as explained in question 6.2). If you were to assign<br /> the array's address to the pointer:<br /><br /> p = a;<br /><br /> then p[3] and a[3] would access the same element.<br /><br /> See also questions 6.8 and 6.14.<br /><br /> References: K&R1 Sec. 5.3 pp. 93-6; K&R2 Sec. 5.3 p. 99; ISO<br /> Sec. 6.2.2.1, Sec. 6.3.2.1, Sec. 6.3.6; H&S Sec. 5.4.1 p. 124.<br /><br />6.4: Then why are array and pointer declarations interchangeable as<br /> function formal parameters?<br /><br />A: It's supposed to be a convenience.<br /><br /> Since arrays decay immediately into pointers, an array is never<br /> actually passed to a function. Allowing pointer parameters to<br /> be declared as arrays is a simply a way of making it look as<br /> though an array was being passed, perhaps because the parameter<br /> will be used within the function as if it were an array.<br /> Specifically, any parameter declarations which "look like"<br /> arrays, e.g.<br /><br /> void f(char a[])<br /> { ... }<br /><br /> are treated by the compiler as if they were pointers, since that<br /> is what the function will receive if an array is passed:<br /><br /> void f(char *a)<br /> { ... }<br /><br /> This conversion holds only within function formal parameter<br /> declarations, nowhere else. If the conversion bothers you,<br /> avoid it; many programmers have concluded that the confusion it<br /> causes outweighs the small advantage of having the declaration<br /> "look like" the call or the uses within the function.<br /><br /> See also question 6.21.<br /><br /> References: K&R1 Sec. 5.3 p. 95, Sec. A10.1 p. 205; K&R2<br /> Sec. 5.3 p. 100, Sec. A8.6.3 p. 218, Sec. A10.1 p. 226; ISO<br /> Sec. 6.5.4.3, Sec. 6.7.1, Sec. 6.9.6; H&S Sec. 9.3 p. 271; CT&P<br /> Sec. 3.3 pp. 33-4.<br /><br />6.7: How can an array be an lvalue, if you can't assign to it?<br /><br />A: The ANSI C Standard defines a "modifiable lvalue," which an<br /> array is not.<br /><br /> References: ISO Sec. 6.2.2.1; Rationale Sec. 3.2.2.1; H&S<br /> Sec. 7.1 p. 179.<br /><br />6.8: Practically speaking, what is the difference between arrays and<br /> pointers?<br /><br />A: Arrays automatically allocate space, but can't be relocated or<br /> resized. Pointers must be explicitly assigned to point to<br /> allocated space (perhaps using malloc), but can be reassigned<br /> (i.e. pointed at different objects) at will, and have many other<br /> uses besides serving as the base of blocks of memory.<br /><br /> Due to the so-called equivalence of arrays and pointers (see<br /> question 6.3), arrays and pointers often seem interchangeable,<br /> and in particular a pointer to a block of memory assigned by<br /> malloc is frequently treated (and can be referenced using [])<br /> exactly as if it were a true array. See questions 6.14 and<br /> 6.16. (Be careful with sizeof, though.)<br /><br /> See also questions 1.32 and 20.14.<br /><br />6.9: Someone explained to me that arrays were really just constant<br /> pointers.<br /><br />A: This is a bit of an oversimplification. An array name is<br /> "constant" in that it cannot be assigned to, but an array is<br /> *not* a pointer, as the discussion and pictures in question 6.2<br /> should make clear. See also questions 6.3 and 6.8.<br /><br />6.11: I came across some "joke" code containing the "expression"<br /> 5["abcdef"] . How can this be legal C?<br /><br />A: Yes, Virginia, array subscripting is commutative in C. This<br /> curious fact follows from the pointer definition of array<br /> subscripting, namely that a[e] is identical to *((a)+(e)), for<br /> *any* two expressions a and e, as long as one of them is a<br /> pointer expression and one is integral. This unsuspected<br /> commutativity is often mentioned in C texts as if it were<br /> something to be proud of, but it finds no useful application<br /> outside of the Obfuscated C Contest (see question 20.36).<br /><br /> References: Rationale Sec. 3.3.2.1; H&S Sec. 5.4.1 p. 124,<br /> Sec. 7.4.1 pp. 186-7.<br /><br />6.12: Since array references decay into pointers, if arr is an array,<br /> what's the difference between arr and &arr?<br /><br />A: The type.<br /><br /> In Standard C, &arr yields a pointer, of type pointer-to-array-<br /> of-T, to the entire array. (In pre-ANSI C, the & in &arr<br /> generally elicited a warning, and was generally ignored.) Under<br /> all C compilers, a simple reference (without an explicit &) to<br /> an array yields a pointer, of type pointer-to-T, to the array's<br /> first element. (See also questions 6.3, 6.13, and 6.18.)<br /><br /> References: ISO Sec. 6.2.2.1, Sec. 6.3.3.2; Rationale<br /> Sec. 3.3.3.2; H&S Sec. 7.5.6 p. 198.<br /><br />6.13: How do I declare a pointer to an array?<br /><br />A: Usually, you don't want to. When people speak casually of a<br /> pointer to an array, they usually mean a pointer to its first<br /> element.<br /><br /> Instead of a pointer to an array, consider using a pointer to<br /> one of the array's elements. Arrays of type T decay into<br /> pointers to type T (see question 6.3), which is convenient;<br /> subscripting or incrementing the resultant pointer will access<br /> the individual members of the array. True pointers to arrays,<br /> when subscripted or incremented, step over entire arrays, and<br /> are generally useful only when operating on arrays of arrays, if<br /> at all. (See question 6.18.)<br /><br /> If you really need to declare a pointer to an entire array, use<br /> something like "int (*ap)[N];" where N is the size of the array.<br /> (See also question 1.21.) If the size of the array is unknown,<br /> N can in principle be omitted, but the resulting type, "pointer<br /> to array of unknown size," is useless.<br /><br /> See also question 6.12 above.<br /><br /> References: ISO Sec. 6.2.2.1.<br /><br />6.14: How can I set an array's size at run time?<br /> How can I avoid fixed-sized arrays?<br /><br />A: The equivalence between arrays and pointers (see question 6.3)<br /> allows a pointer to malloc'ed memory to simulate an array<br /> quite effectively. After executing<br /><br /> #include <stdlib.h><br /> int *dynarray;<br /> dynarray = malloc(10 * sizeof(int));<br /><br /> (and if the call to malloc succeeds), you can reference<br /> dynarray[i] (for i from 0 to 9) almost as if dynarray were a<br /> conventional, statically-allocated array (int a[10]). The only<br /> difference is that sizeof will not give the size of the "array".<br /> See also questions 1.31b, 6.16, and 7.7.<br /><br />6.15: How can I declare local arrays of a size matching a passed-in<br /> array?<br /><br />A: Until recently, you couldn't. Array dimensions in C<br /> traditionally had to be compile-time constants. C9X will<br /> introduce variable-length arrays (VLA's) which will solve this<br /> problem; local arrays may have sizes set by variables or other<br /> expressions, perhaps involving function parameters. (gcc has<br /> provided parameterized arrays as an extension for some time.)<br /> If you can't use C9X or gcc, you'll have to use malloc(), and<br /> remember to call free() before the function returns. See also<br /> questions 6.14, 6.16, 6.19, 7.22, and maybe 7.32.<br /><br /> References: ISO Sec. 6.4, Sec. 6.5.4.2; C9X Sec. 6.5.5.2.<br /><br />6.16: How can I dynamically allocate a multidimensional array?<br /><br />A: The traditional solution is to allocate an array of pointers,<br /> and then initialize each pointer to a dynamically-allocated<br /> "row." Here is a two-dimensional example:<br /><br /> #include <stdlib.h><br /><br /> int **array1 = malloc(nrows * sizeof(int *));<br /> for(i = 0; i < nrows; i++)<br /> array1[i] = malloc(ncolumns * sizeof(int));<br /><br /> (In real code, of course, all of malloc's return values would<br /> be checked.)<br /><br /> You can keep the array's contents contiguous, at the cost of<br /> making later reallocation of individual rows more difficult,<br /> with a bit of explicit pointer arithmetic:<br /><br /> int **array2 = malloc(nrows * sizeof(int *));<br /> array2[0] = malloc(nrows * ncolumns * sizeof(int));<br /> for(i = 1; i < nrows; i++)<br /> array2[i] = array2[0] + i * ncolumns;<br /><br /> In either case, the elements of the dynamic array can be<br /> accessed with normal-looking array subscripts: arrayx[i][j]<br /> (for 0 <= i < nrows and 0 <= j < ncolumns).<br /><br /> If the double indirection implied by the above schemes is for<br /> some reason unacceptable, you can simulate a two-dimensional<br /> array with a single, dynamically-allocated one-dimensional<br /> array:<br /><br /> int *array3 = malloc(nrows * ncolumns * sizeof(int));<br /><br /> However, you must now perform subscript calculations manually,<br /> accessing the i,jth element with array3[i * ncolumns + j]. (A<br /> macro could hide the explicit calculation, but invoking it would<br /> require parentheses and commas which wouldn't look exactly like<br /> multidimensional array syntax, and the macro would need access<br /> to at least one of the dimensions, as well. See also question<br /> 6.19.)<br /><br /> Yet another option is to use pointers to arrays:<br /><br /> int (*array4)[NCOLUMNS] = malloc(nrows * sizeof(*array4));<br /><br /> but the syntax starts getting horrific and at most one dimension<br /> may be specified at run time.<br /><br /> With all of these techniques, you may of course need to remember<br /> to free the arrays (which may take several steps; see question<br /> 7.23) when they are no longer needed, and you cannot necessarily<br /> intermix dynamically-allocated arrays with conventional,<br /> statically-allocated ones (see question 6.20, and also question<br /> 6.18).<br /><br /> Finally, in C9X you can use a variable-length array.<br /><br /> All of these techniques can also be extended to three or more<br /> dimensions.<br /><br /> References: C9X Sec. 6.5.5.2.<br /><br />6.17: Here's a neat trick: if I write<br /><br /> int realarray[10];<br /> int *array = &realarray[-1];<br /><br /> I can treat "array" as if it were a 1-based array.<br /><br />A: Although this technique is attractive (and was used in old<br /> editions of the book _Numerical Recipes in C_), it is not<br /> strictly conforming to the C Standard. Pointer arithmetic<br /> is defined only as long as the pointer points within the same<br /> allocated block of memory, or to the imaginary "terminating"<br /> element one past it; otherwise, the behavior is undefined,<br /> *even if the pointer is not dereferenced*. The code above<br /> could fail if, while subtracting the offset, an illegal<br /> address were generated (perhaps because the address tried<br /> to "wrap around" past the beginning of some memory segment).<br /><br /> References: K&R2 Sec. 5.3 p. 100, Sec. 5.4 pp. 102-3, Sec. A7.7<br /> pp. 205-6; ISO Sec. 6.3.6; Rationale Sec. 3.2.2.3.<br /><br />6.18: My compiler complained when I passed a two-dimensional array to<br /> a function expecting a pointer to a pointer.<br /><br />A: The rule (see question 6.3) by which arrays decay into pointers<br /> is not applied recursively. An array of arrays (i.e. a two-<br /> dimensional array in C) decays into a pointer to an array, not a<br /> pointer to a pointer. Pointers to arrays can be confusing, and<br /> must be treated carefully; see also question 6.13.<br /><br /> If you are passing a two-dimensional array to a function:<br /><br /> int array[NROWS][NCOLUMNS];<br /> f(array);<br /><br /> the function's declaration must match:<br /><br /> void f(int a[][NCOLUMNS])<br /> { ... }<br /><br /> or<br /><br /> void f(int (*ap)[NCOLUMNS]) /* ap is a pointer to an array */<br /> { ... }<br /><br /> In the first declaration, the compiler performs the usual<br /> implicit parameter rewriting of "array of array" to "pointer to<br /> array" (see questions 6.3 and 6.4); in the second form the<br /> pointer declaration is explicit. Since the called function does<br /> not allocate space for the array, it does not need to know the<br /> overall size, so the number of rows, NROWS, can be omitted. The<br /> width of the array is still important, so the column dimension<br /> NCOLUMNS (and, for three- or more dimensional arrays, the<br /> intervening ones) must be retained.<br /><br /> If a function is already declared as accepting a pointer to a<br /> pointer, it is almost certainly meaningless to pass a two-<br /> dimensional array directly to it.<br /><br /> See also questions 6.12 and 6.15.<br /><br /> References: K&R1 Sec. 5.10 p. 110; K&R2 Sec. 5.9 p. 113; H&S<br /> Sec. 5.4.3 p. 126.<br /><br />6.19: How do I write functions which accept two-dimensional arrays<br /> when the width is not known at compile time?<br /><br />A: It's not always easy. One way is to pass in a pointer to the<br /> [0][0] element, along with the two dimensions, and simulate<br /> array subscripting "by hand":<br /><br /> void f2(int *aryp, int nrows, int ncolumns)<br /> { ... array[i][j] is accessed as aryp[i * ncolumns + j] ... }<br /><br /> This function could be called with the array from question 6.18<br /> as<br /><br /> f2(&array[0][0], NROWS, NCOLUMNS);<br /><br /> It must be noted, however, that a program which performs<br /> multidimensional array subscripting "by hand" in this way is not<br /> in strict conformance with the ANSI C Standard; according to an<br /> official interpretation, the behavior of accessing<br /> (&array[0][0])[x] is not defined for x >= NCOLUMNS.<br /><br /> C9X will allow variable-length arrays, and once compilers which<br /> accept C9X's extensions become widespread, this will probably<br /> become the preferred solution. (gcc has supported variable-<br /> sized arrays for some time.)<br /><br /> When you want to be able to use a function on multidimensional<br /> arrays of various sizes, one solution is to simulate all the<br /> arrays dynamically, as in question 6.16.<br /><br /> See also questions 6.18, 6.20, and 6.15.<br /><br /> References: ISO Sec. 6.3.6; C9X Sec. 6.5.5.2.<br /><br />6.20: How can I use statically- and dynamically-allocated<br /> multidimensional arrays interchangeably when passing them to<br /> functions?<br /><br />A: There is no single perfect method. Given the declarations<br /><br /> int array[NROWS][NCOLUMNS];<br /> int **array1; /* ragged */<br /> int **array2; /* contiguous */<br /> int *array3; /* "flattened" */<br /> int (*array4)[NCOLUMNS];<br /><br /> with the pointers initialized as in the code fragments in<br /> question 6.16, and functions declared as<br /><br /> void f1a(int a[][NCOLUMNS], int nrows, int ncolumns);<br /> void f1b(int (*a)[NCOLUMNS], int nrows, int ncolumns);<br /> void f2(int *aryp, int nrows, int ncolumns);<br /> void f3(int **pp, int nrows, int ncolumns);<br /><br /> where f1a() and f1b() accept conventional two-dimensional<br /> arrays, f2() accepts a "flattened" two-dimensional array, and<br /> f3() accepts a pointer-to-pointer, simulated array (see also<br /> questions 6.18 and 6.19), the following calls should work as<br /> expected:<br /><br /> f1a(array, NROWS, NCOLUMNS);<br /> f1b(array, NROWS, NCOLUMNS);<br /> f1a(array4, nrows, NCOLUMNS);<br /> f1b(array4, nrows, NCOLUMNS);<br /> f2(&array[0][0], NROWS, NCOLUMNS);<br /> f2(*array, NROWS, NCOLUMNS);<br /> f2(*array2, nrows, ncolumns);<br /> f2(array3, nrows, ncolumns);<br /> f2(*array4, nrows, NCOLUMNS);<br /> f3(array1, nrows, ncolumns);<br /> f3(array2, nrows, ncolumns);<br /><br /> The following calls would probably work on most systems, but<br /> involve questionable casts, and work only if the dynamic<br /> ncolumns matches the static NCOLUMNS:<br /><br /> f1a((int (*)[NCOLUMNS])(*array2), nrows, ncolumns);<br /> f1a((int (*)[NCOLUMNS])(*array2), nrows, ncolumns);<br /> f1b((int (*)[NCOLUMNS])array3, nrows, ncolumns);<br /> f1b((int (*)[NCOLUMNS])array3, nrows, ncolumns);<br /><br /> It must again be noted that passing &array[0][0] (or,<br /> equivalently, *array) to f2() is not strictly conforming; see<br /> question 6.19.<br /><br /> If you can understand why all of the above calls work and are<br /> written as they are, and if you understand why the combinations<br /> that are not listed would not work, then you have a *very* good<br /> understanding of arrays and pointers in C.<br /><br /> Rather than worrying about all of this, one approach to using<br /> multidimensional arrays of various sizes is to make them *all*<br /> dynamic, as in question 6.16. If there are no static<br /> multidimensional arrays -- if all arrays are allocated like<br /> array1 or array2 in question 6.16 -- then all functions can be<br /> written like f3().<br /><br />6.21: Why doesn't sizeof properly report the size of an array when the<br /> array is a parameter to a function?<br /><br />A: The compiler pretends that the array parameter was declared as a<br /> pointer (see question 6.4), and sizeof reports the size of the<br /> pointer.<br /><br /> References: H&S Sec. 7.5.2 p. 195.<br /><br /><br />Section 7. Memory Allocation<br /><br />7.1: Why doesn't this fragment work?<br /><br /> char *answer;<br /> printf("Type something:\n");<br /> gets(answer);<br /> printf("You typed \"%s\"\n", answer);<br /><br />A: The pointer variable answer, which is handed to gets() as the<br /> location into which the response should be stored, has not been<br /> set to point to any valid storage. That is, we cannot say where<br /> the pointer answer points. (Since local variables are not<br /> initialized, and typically contain garbage, it is not even<br /> guaranteed that answer starts out as a null pointer.<br /> See questions 1.30 and 5.1.)<br /><br /> The simplest way to correct the question-asking program is to<br /> use a local array, instead of a pointer, and let the compiler<br /> worry about allocation:<br /><br /> #include <stdio.h><br /> #include <string.h><br /><br /> char answer[100], *p;<br /> printf("Type something:\n");<br /> fgets(answer, sizeof answer, stdin);<br /> if((p = strchr(answer, '\n')) != NULL)<br /> *p = '\0';<br /> printf("You typed \"%s\"\n", answer);<br /><br /> This example also uses fgets() instead of gets(), so that the<br /> end of the array cannot be overwritten. (See question 12.23.<br /> Unfortunately for this example, fgets() does not automatically<br /> delete the trailing \n, as gets() would.) It would also be<br /> possible to use malloc() to allocate the answer buffer.<br /><br />7.2: I can't get strcat() to work. I tried<br /><br /> char *s1 = "Hello, ";<br /> char *s2 = "world!";<br /> char *s3 = strcat(s1, s2);<br /><br /> but I got strange results.<br /><br />A: As in question 7.1 above, the main problem here is that space<br /> for the concatenated result is not properly allocated. C does<br /> not provide an automatically-managed string type. C compilers<br /> only allocate memory for objects explicitly mentioned in the<br /> source code (in the case of strings, this includes character<br /> arrays and string literals). The programmer must arrange for<br /> sufficient space for the results of run-time operations such as<br /> string concatenation, typically by declaring arrays, or by<br /> calling malloc().<br /><br /> strcat() performs no allocation; the second string is appended<br /> to the first one, in place. Therefore, one fix would be to<br /> declare the first string as an array:<br /><br /> char s1[20] = "Hello, ";<br /><br /> Since strcat() returns the value of its first argument (s1, in<br /> this case), the variable s3 is superfluous; after the call to<br /> strcat(), s1 contains the result.<br /><br /> The original call to strcat() in the question actually has two<br /> problems: the string literal pointed to by s1, besides not being<br /> big enough for any concatenated text, is not necessarily<br /> writable at all. See question 1.32.<br /><br /> References: CT&P Sec. 3.2 p. 32.<br /><br />7.3: But the man page for strcat() says that it takes two char *'s as<br /> arguments. How am I supposed to know to allocate things?<br /><br />A: In general, when using pointers you *always* have to consider<br /> memory allocation, if only to make sure that the compiler is<br /> doing it for you. If a library function's documentation does<br /> not explicitly mention allocation, it is usually the caller's<br /> problem.<br /><br /> The Synopsis section at the top of a Unix-style man page or in<br /> the ANSI C standard can be misleading. The code fragments<br /> presented there are closer to the function definitions used by<br /> an implementor than the invocations used by the caller. In<br /> particular, many functions which accept pointers (e.g. to<br /> structures or strings) are usually called with a pointer to some<br /> object (a structure, or an array -- see questions 6.3 and 6.4)<br /> which the caller has allocated. Other common examples are<br /> time() (see question 13.12) and stat().<br /><br />7.3b: I just tried the code<br /><br /> char *p;<br /> strcpy(p, "abc");<br /><br /> and it worked. How? Why didn't it crash?<br /><br />A: You got lucky, I guess. The memory pointed to by the<br /> unitialized pointer p happened to be writable by you,<br /> and apparently was not already in use for anything vital.<br /><br />7.3c: How much memory does a pointer variable allocate?<br /><br />A: That's a pretty misleading question. When you declare<br /> a pointer variable, as in<br /><br /> char *p;<br /><br /> you (or, more properly, the compiler) have allocated only enough<br /> memory to hold the pointer itself; that is, in this case you<br /> have allocated sizeof(char *) bytes of memory. But you have<br /> not yet allocated *any* memory for the pointer to point to.<br /> See also questions 7.1 and 7.2.<br /><br />7.5a: I have a function that is supposed to return a string, but when<br /> it returns to its caller, the returned string is garbage.<br /><br />A: Make sure that the pointed-to memory is properly allocated.<br /> For example, make sure you have *not* done something like<br /><br /> char *itoa(int n)<br /> {<br /> char retbuf[20]; /* WRONG */<br /> sprintf(retbuf, "%d", n);<br /> return retbuf; /* WRONG */<br /> }<br /><br /> One fix (which is imperfect, especially if the function in<br /> question is called recursively, or if several of its return<br /> values are needed simultaneously) would be to declare the return<br /> buffer as<br /><br /> static char retbuf[20];<br /><br /> See also questions 7.5b, 12.21, and 20.1.<br /><br /> References: ISO Sec. 6.1.2.4.<br /><br />7.5b: So what's the right way to return a string or other aggregate?<br /><br />A: The returned pointer should be to a statically-allocated buffer,<br /> or to a buffer passed in by the caller, or to memory obtained<br /> with malloc(), but *not* to a local (automatic) array.<br /><br /> See also question 20.1.<br /><br />7.6: Why am I getting "warning: assignment of pointer from integer<br /> lacks a cast" for calls to malloc()?<br /><br />A: Have you #included <stdlib.h>, or otherwise arranged for<br /> malloc() to be declared properly? See also question 1.25.<br /><br /> References: H&S Sec. 4.7 p. 101.<br /><br />7.7: Why does some code carefully cast the values returned by malloc<br /> to the pointer type being allocated?<br /><br />A: Before ANSI/ISO Standard C introduced the void * generic pointer<br /> type, these casts were typically required to silence warnings<br /> (and perhaps induce conversions) when assigning between<br /> incompatible pointer types.<br /><br /> Under ANSI/ISO Standard C, these casts are no longer necessary,<br /> and in fact modern practice discourages them, since they can<br /> camouflage important warnings which would otherwise be generated<br /> if malloc() happened not to be declared correctly; see question<br /> 7.6 above. (However, the casts are typically seen in C code<br /> which for one reason or another is intended to be compatible<br /> with C++, where explicit casts from void * are required.)<br /><br /> References: H&S Sec. 16.1 pp. 386-7.<br /><br />7.8: I see code like<br /><br /> char *p = malloc(strlen(s) + 1);<br /> strcpy(p, s);<br /><br /> Shouldn't that be malloc((strlen(s) + 1) * sizeof(char))?<br /><br />A: It's never necessary to multiply by sizeof(char), since<br /> sizeof(char) is, by definition, exactly 1. (On the other<br /> hand, multiplying by sizeof(char) doesn't hurt, and in some<br /> circumstances may help by introducing a size_t into the<br /> expression.) See also question 8.9.<br /><br /> References: ISO Sec. 6.3.3.4; H&S Sec. 7.5.2 p. 195.<br /><br />7.14: I've heard that some operating systems don't actually allocate<br /> malloc'ed memory until the program tries to use it. Is this<br /> legal?<br /><br />A: It's hard to say. The Standard doesn't say that systems can act<br /> this way, but it doesn't explicitly say that they can't, either.<br /><br /> References: ISO Sec. 7.10.3.<br /><br />7.16: I'm allocating a large array for some numeric work, using the<br /> line<br /><br /> double *array = malloc(300 * 300 * sizeof(double));<br /><br /> malloc() isn't returning null, but the program is acting<br /> strangely, as if it's overwriting memory, or malloc() isn't<br /> allocating as much as I asked for, or something.<br /><br />A: Notice that 300 x 300 is 90,000, which will not fit in a 16-bit<br /> int, even before you multiply it by sizeof(double). If you<br /> need to allocate this much memory, you'll have to be careful.<br /> If size_t (the type accepted by malloc()) is a 32-bit type on<br /> your machine, but int is 16 bits, you might be able to get away<br /> with writing 300 * (300 * sizeof(double)) (see question 3.14).<br /> Otherwise, you'll have to break your data structure up into<br /> smaller chunks, or use a 32-bit machine or compiler, or use<br /> some nonstandard memory allocation functions. See also<br /> question 19.23.<br /><br />7.17: I've got 8 meg of memory in my PC. Why can I only seem to<br /> malloc 640K or so?<br /><br />A: Under the segmented architecture of PC compatibles, it can be<br /> difficult to use more than 640K with any degree of transparency,<br /> especially under MS-DOS. See also question 19.23.<br /><br />7.19: My program is crashing, apparently somewhere down inside malloc,<br /> but I can't see anything wrong with it. Is there a bug in<br /> malloc()?<br /><br />A: It is unfortunately very easy to corrupt malloc's internal data<br /> structures, and the resulting problems can be stubborn. The<br /> most common source of problems is writing more to a malloc'ed<br /> region than it was allocated to hold; a particularly common bug<br /> is to malloc(strlen(s)) instead of strlen(s) + 1. Other<br /> problems may involve using pointers to memory that has been<br /> freed, freeing pointers twice, freeing pointers not obtained<br /> from malloc, or trying to realloc a null pointer (see question<br /> 7.30).<br /><br /> See also questions 7.26, 16.8, and 18.2.<br /><br />7.20: You can't use dynamically-allocated memory after you free it,<br /> can you?<br /><br />A: No. Some early documentation for malloc() stated that the<br /> contents of freed memory were "left undisturbed," but this ill-<br /> advised guarantee was never universal and is not required by the<br /> C Standard.<br /><br /> Few programmers would use the contents of freed memory<br /> deliberately, but it is easy to do so accidentally. Consider<br /> the following (correct) code for freeing a singly-linked list:<br /><br /> struct list *listp, *nextp;<br /> for(listp = base; listp != NULL; listp = nextp) {<br /> nextp = listp->next;<br /> free(listp);<br /> }<br /><br /> and notice what would happen if the more-obvious loop iteration<br /> expression listp = listp->next were used, without the temporary<br /> nextp pointer.<br /><br /> References: K&R2 Sec. 7.8.5 p. 167; ISO Sec. 7.10.3; Rationale<br /> Sec. 4.10.3.2; H&S Sec. 16.2 p. 387; CT&P Sec. 7.10 p. 95.<br /><br />7.21: Why isn't a pointer null after calling free()?<br /> How unsafe is it to use (assign, compare) a pointer value after<br /> it's been freed?<br /><br />A: When you call free(), the memory pointed to by the passed<br /> pointer is freed, but the value of the pointer in the caller<br /> probably remains unchanged, because C's pass-by-value semantics<br /> mean that called functions never permanently change the values<br /> of their arguments. (See also question 4.8.)<br /><br /> A pointer value which has been freed is, strictly speaking,<br /> invalid, and *any* use of it, even if is not dereferenced, can<br /> theoretically lead to trouble, though as a quality of<br /> implementation issue, most implementations will probably not go<br /> out of their way to generate exceptions for innocuous uses of<br /> invalid pointers.<br /><br /> References: ISO Sec. 7.10.3; Rationale Sec. 3.2.2.3.<br /><br />7.22: When I call malloc() to allocate memory for a pointer which is<br /> local to a function, do I have to explicitly free() it?<br /><br />A: Yes. Remember that a pointer is different from what it points<br /> to. Local variables are deallocated when the function returns,<br /> but in the case of a pointer variable, this means that the<br /> pointer is deallocated, *not* what it points to. Memory<br /> allocated with malloc() always persists until you explicitly<br /> free it. In general, for every call to malloc(), there should<br /> be a corresponding call to free().<br /><br />7.23: I'm allocating structures which contain pointers to other<br /> dynamically-allocated objects. When I free a structure, do I<br /> also have to free each subsidiary pointer?<br /><br />A: Yes. In general, you must arrange that each pointer returned<br /> from malloc() be individually passed to free(), exactly once (if<br /> it is freed at all). A good rule of thumb is that for each call<br /> to malloc() in a program, you should be able to point at the<br /> call to free() which frees the memory allocated by that malloc()<br /> call.<br /><br /> See also question 7.24.<br /><br />7.24: Must I free allocated memory before the program exits?<br /><br />A: You shouldn't have to. A real operating system definitively<br /> reclaims all memory and other resources when a program exits.<br /> Nevertheless, some personal computers are said not to reliably<br /> recover memory, and all that can be inferred from the ANSI/ISO C<br /> Standard is that this is a "quality of implementation issue."<br /><br /> References: ISO Sec. 7.10.3.2.<br /><br />7.25: I have a program which mallocs and later frees a lot of memory,<br /> but I can see from the operating system that memory usage<br /> doesn't actually go back down.<br /><br />A: Most implementations of malloc/free do not return freed memory<br /> to the operating system, but merely make it available for future<br /> malloc() calls within the same program.<br /><br />7.26: How does free() know how many bytes to free?<br /><br />A: The malloc/free implementation remembers the size of each block<br /> as it is allocated, so it is not necessary to remind it of the<br /> size when freeing.<br /><br />7.27: So can I query the malloc package to find out how big an<br /> allocated block is?<br /><br />A: Unfortunately, there is no standard or portable way.<br /><br />7.30: Is it legal to pass a null pointer as the first argument to<br /> realloc()? Why would you want to?<br /><br />A: ANSI C sanctions this usage (and the related realloc(..., 0),<br /> which frees), although several earlier implementations do not<br /> support it, so it may not be fully portable. Passing an<br /> initially-null pointer to realloc() can make it easier to write<br /> a self-starting incremental allocation algorithm.<br /><br /> References: ISO Sec. 7.10.3.4; H&S Sec. 16.3 p. 388.<br /><br />7.31: What's the difference between calloc() and malloc()? Is it safe<br /> to take advantage of calloc's zero-filling? Does free() work<br /> on memory allocated with calloc(), or do you need a cfree()?<br /><br />A: calloc(m, n) is essentially equivalent to<br /><br /> p = malloc(m * n);<br /> memset(p, 0, m * n);<br /><br /> The zero fill is all-bits-zero, and does *not* therefore<br /> guarantee useful null pointer values (see section 5 of this<br /> list) or floating-point zero values. free() is properly used to<br /> free the memory allocated by calloc().<br /><br /> References: ISO Sec. 7.10.3 to 7.10.3.2; H&S Sec. 16.1 p. 386,<br /> Sec. 16.2 p. 386; PCS Sec. 11 pp. 141,142.<br /><br />7.32: What is alloca() and why is its use discouraged?<br /><br />A: alloca() allocates memory which is automatically freed when the<br /> function which called alloca() returns. That is, memory<br /> allocated with alloca is local to a particular function's "stack<br /> frame" or context.<br /><br /> alloca() cannot be written portably, and is difficult to<br /> implement on machines without a conventional stack. Its use is<br /> problematical (and the obvious implementation on a stack-based<br /> machine fails) when its return value is passed directly to<br /> another function, as in fgets(alloca(100), 100, stdin).<br /><br /> For these reasons, alloca() is not Standard and cannot be used<br /> in programs which must be widely portable, no matter how useful<br /> it might be.<br /><br /> See also question 7.22.<br /><br /> References: Rationale Sec. 4.10.3.<br /><br /><br />Section 8. Characters and Strings<br /><br />8.1: Why doesn't<br /><br /> strcat(string, '!');<br /><br /> work?<br /><br />A: There is a very real difference between characters and strings,<br /> and strcat() concatenates *strings*.<br /><br /> Characters in C are represented by small integers corresponding<br /> to their character set values (see also question 8.6 below).<br /> Strings are represented by arrays of characters; you usually<br /> manipulate a pointer to the first character of the array. It is<br /> never correct to use one when the other is expected. To append<br /> a ! to a string, use<br /><br /> strcat(string, "!");<br /><br /> See also questions 1.32, 7.2, and 16.6.<br /><br /> References: CT&P Sec. 1.5 pp. 9-10.<br /><br />8.2: I'm checking a string to see if it matches a particular value.<br /> Why isn't this code working?<br /><br /> char *string;<br /> ...<br /> if(string == "value") {<br /> /* string matches "value" */<br /> ...<br /> }<br /><br />A: Strings in C are represented as arrays of characters, and C<br /> never manipulates (assigns, compares, etc.) arrays as a whole.<br /> The == operator in the code fragment above compares two pointers<br /> -- the value of the pointer variable string and a pointer to the<br /> string literal "value" -- to see if they are equal, that is, if<br /> they point to the same place. They probably don't, so the<br /> comparison never succeeds.<br /><br /> To compare two strings, you generally use the library function<br /> strcmp():<br /><br /> if(strcmp(string, "value") == 0) {<br /> /* string matches "value" */<br /> ...<br /> }<br /><br />8.3: If I can say<br /><br /> char a[] = "Hello, world!";<br /><br /> why can't I say<br /><br /> char a[14];<br /> a = "Hello, world!";<br /><br />A: Strings are arrays, and you can't assign arrays directly. Use<br /> strcpy() instead:<br /><br /> strcpy(a, "Hello, world!");<br /><br /> See also questions 1.32, 4.2, and 7.2.<br /><br />8.6: How can I get the numeric (character set) value corresponding to<br /> a character, or vice versa?<br /><br />A: In C, characters are represented by small integers corresponding<br /> to their values (in the machine's character set), so you don't<br /> need a conversion function: if you have the character, you have<br /> its value.<br /><br />8.9: I think something's wrong with my compiler: I just noticed that<br /> sizeof('a') is 2, not 1 (i.e. not sizeof(char)).<br /><br />A: Perhaps surprisingly, character constants in C are of type int,<br /> so sizeof('a') is sizeof(int) (though this is another area<br /> where C++ differs). See also question 7.8.<br /><br /> References: ISO Sec. 6.1.3.4; H&S Sec. 2.7.3 p. 29.<br /><br /><br />Section 9. Boolean Expressions and Variables<br /><br />9.1: What is the right type to use for Boolean values in C? Why<br /> isn't it a standard type? Should I use #defines or enums for<br /> the true and false values?<br /><br />A: C does not provide a standard Boolean type, in part because<br /> picking one involves a space/time tradeoff which can best be<br /> decided by the programmer. (Using an int may be faster, while<br /> using char may save data space. Smaller types may make the<br /> generated code bigger or slower, though, if they require lots of<br /> conversions to and from int.)<br /><br /> The choice between #defines and enumeration constants for the<br /> true/false values is arbitrary and not terribly interesting (see<br /> also questions 2.22 and 17.10). Use any of<br /><br /> #define TRUE 1 #define YES 1<br /> #define FALSE 0 #define NO 0<br /><br /> enum bool {false, true}; enum bool {no, yes};<br /><br /> or use raw 1 and 0, as long as you are consistent within one<br /> program or project. (An enumeration may be preferable if your<br /> debugger shows the names of enumeration constants when examining<br /> variables.)<br /><br /> Some people prefer variants like<br /><br /> #define TRUE (1==1)<br /> #define FALSE (!TRUE)<br /><br /> or define "helper" macros such as<br /><br /> #define Istrue(e) ((e) != 0)<br /><br /> These don't buy anything (see question 9.2 below; see also<br /> questions 5.12 and 10.2).<br /><br />9.2: Isn't #defining TRUE to be 1 dangerous, since any nonzero value<br /> is considered "true" in C? What if a built-in logical or<br /> relational operator "returns" something other than 1?<br /><br />A: It is true (sic) that any nonzero value is considered true in C,<br /> but this applies only "on input", i.e. where a Boolean value is<br /> expected. When a Boolean value is generated by a built-in<br /> operator, it is guaranteed to be 1 or 0. Therefore, the test<br /><br /> if((a == b) == TRUE)<br /><br /> would work as expected (as long as TRUE is 1), but it is<br /> obviously silly. In fact, explicit tests against TRUE and<br /> FALSE are generally inappropriate, because some library<br /> functions (notably isupper(), isalpha(), etc.) return,<br /> on success, a nonzero value which is not necessarily 1.<br /> (Besides, if you believe that "if((a == b) == TRUE)" is<br /> an improvement over "if(a == b)", why stop there? Why not<br /> use "if(((a == b) == TRUE) == TRUE)"?) A good rule of thumb<br /> is to use TRUE and FALSE (or the like) only for assignment<br /> to a Boolean variable or function parameter, or as the return<br /> value from a Boolean function, but never in a comparison.<br /><br /> The preprocessor macros TRUE and FALSE (and, of course, NULL)<br /> are used for code readability, not because the underlying values<br /> might ever change. (See also questions 5.3 and 5.10.)<br /><br /> Although the use of macros like TRUE and FALSE (or YES<br /> and NO) seems clearer, Boolean values and definitions can<br /> be sufficiently confusing in C that some programmers feel<br /> that TRUE and FALSE macros only compound the confusion, and<br /> prefer to use raw 1 and 0 instead. (See also question 5.9.)<br /><br /> References: K&R1 Sec. 2.6 p. 39, Sec. 2.7 p. 41; K&R2 Sec. 2.6<br /> p. 42, Sec. 2.7 p. 44, Sec. A7.4.7 p. 204, Sec. A7.9 p. 206; ISO<br /> Sec. 6.3.3.3, Sec. 6.3.8, Sec. 6.3.9, Sec. 6.3.13, Sec. 6.3.14,<br /> Sec. 6.3.15, Sec. 6.6.4.1, Sec. 6.6.5; H&S Sec. 7.5.4 pp. 196-7,<br /> Sec. 7.6.4 pp. 207-8, Sec. 7.6.5 pp. 208-9, Sec. 7.7 pp. 217-8,<br /> Sec. 7.8 pp. 218-9, Sec. 8.5 pp. 238-9, Sec. 8.6 pp. 241-4;<br /> "What the Tortoise Said to Achilles".<br /><br />9.3: Is if(p), where p is a pointer, a valid conditional?<br /><br />A: Yes. See question 5.3.<br /><br /><br />Section 10. C Preprocessor<br /><br />10.2: Here are some cute preprocessor macros:<br /><br /> #define begin {<br /> #define end }<br /><br /> What do y'all think?<br /><br />A: Bleah. See also section 17.<br /><br />10.3: How can I write a generic macro to swap two values?<br /><br />A: There is no good answer to this question. If the values are<br /> integers, a well-known trick using exclusive-OR could perhaps<br /> be used, but it will not work for floating-point values or<br /> pointers, or if the two values are the same variable. (See<br /> questions 3.3b and 20.15c.) If the macro is intended to be<br /> used on values of arbitrary type (the usual goal), it cannot<br /> use a temporary, since it does not know what type of temporary<br /> it needs (and would have a hard time picking a name for it if<br /> it did), and standard C does not provide a typeof operator.<br /><br /> The best all-around solution is probably to forget about using a<br /> macro, unless you're willing to pass in the type as a third<br /> argument.<br /><br />10.4: What's the best way to write a multi-statement macro?<br /><br />A: The usual goal is to write a macro that can be invoked as if it<br /> were a statement consisting of a single function call. This<br /> means that the "caller" will be supplying the final semicolon,<br /> so the macro body should not. The macro body cannot therefore<br /> be a simple brace-enclosed compound statement, because syntax<br /> errors would result if it were invoked (apparently as a single<br /> statement, but with a resultant extra semicolon) as the if<br /> branch of an if/else statement with an explicit else clause.<br /><br /> The traditional solution, therefore, is to use<br /><br /> #define MACRO(arg1, arg2) do { \<br /> /* declarations */ \<br /> stmt1; \<br /> stmt2; \<br /> /* ... */ \<br /> } while(0) /* (no trailing ; ) */<br /><br /> When the caller appends a semicolon, this expansion becomes a<br /> single statement regardless of context. (An optimizing compiler<br /> will remove any "dead" tests or branches on the constant<br /> condition 0, although lint may complain.)<br /><br /> If all of the statements in the intended macro are simple<br /> expressions, with no declarations or loops, another technique is<br /> to write a single, parenthesized expression using one or more<br /> comma operators. (For an example, see the first DEBUG() macro<br /> in question 10.26.) This technique also allows a value to be<br /> "returned."<br /><br /> References: H&S Sec. 3.3.2 p. 45; CT&P Sec. 6.3 pp. 82-3.<br /><br />10.6: I'm splitting up a program into multiple source files for the<br /> first time, and I'm wondering what to put in .c files and what<br /> to put in .h files. (What does ".h" mean, anyway?)<br /><br />A: As a general rule, you should put these things in header (.h)<br /> files:<br /><br /> macro definitions (preprocessor #defines)<br /> structure, union, and enumeration declarations<br /> typedef declarations<br /> external function declarations (see also question 1.11)<br /> global variable declarations<br /><br /> It's especially important to put a declaration or definition in<br /> a header file when it will be shared between several other<br /> files. (In particular, never put external function prototypes<br /> in .c files. See also question 1.7.)<br /><br /> On the other hand, when a definition or declaration should<br /> remain private to one .c file, it's fine to leave it there.<br /><br /> See also questions 1.7 and 10.7.<br /><br /> References: K&R2 Sec. 4.5 pp. 81-2; H&S Sec. 9.2.3 p. 267; CT&P<br /> Sec. 4.6 pp. 66-7.<br /><br />10.7: Is it acceptable for one header file to #include another?<br /><br />A: It's a question of style, and thus receives considerable debate.<br /> Many people believe that "nested #include files" are to be<br /> avoided: the prestigious Indian Hill Style Guide (see question<br /> 17.9) disparages them; they can make it harder to find relevant<br /> definitions; they can lead to multiple-definition errors if a<br /> file is #included twice; and they make manual Makefile<br /> maintenance very difficult. On the other hand, they make it<br /> possible to use header files in a modular way (a header file can<br /> #include what it needs itself, rather than requiring each<br /> #includer to do so); a tool like grep (or a tags file) makes it<br /> easy to find definitions no matter where they are; a popular<br /> trick along the lines of:<br /><br /> #ifndef HFILENAME_USED<br /> #define HFILENAME_USED<br /> ...header file contents...<br /> #endif<br /><br /> (where a different bracketing macro name is used for each header<br /> file) makes a header file "idempotent" so that it can safely be<br /> #included multiple times; and automated Makefile maintenance<br /> tools (which are a virtual necessity in large projects anyway;<br /> see question 18.1) handle dependency generation in the face of<br /> nested #include files easily. See also question 17.10.<br /><br /> References: Rationale Sec. 4.1.2.<br /><br />10.8a: What's the difference between #include <> and #include "" ?<br /><br />A: The <> syntax is typically used with Standard or system-supplied<br /> headers, while "" is typically used for a program's own header<br /> files.<br /><br />10.8b: What are the complete rules for header file searching?<br /><br />A: The exact behavior is implementation-defined (which means that<br /> it is supposed to be documented; see question 11.33).<br /> Typically, headers named with <> syntax are searched for in one<br /> or more standard places. Header files named with "" syntax are<br /> first searched for in the "current directory," then (if not<br /> found) in the same standard places.<br /><br /> Traditionally (especially under Unix compilers), the current<br /> directory is taken to be the directory containing the file<br /> containing the #include directive. Under other compilers,<br /> however, the current directory (if any) is the directory in<br /> which the compiler was initially invoked. Check your compiler<br /> documentation.<br /><br /> References: K&R2 Sec. A12.4 p. 231; ISO Sec. 6.8.2; H&S Sec. 3.4<br /> p. 55.<br /><br />10.9: I'm getting strange syntax errors on the very first declaration<br /> in a file, but it looks fine.<br /><br />A: Perhaps there's a missing semicolon at the end of the last<br /> declaration in the last header file you're #including. See also<br /> questions 2.18, 11.29, and 16.1b.<br /><br />10.10b: I'm #including the right header file for the library function<br /> I'm using, but the linker keeps saying it's undefined.<br /><br />A: See question 13.25.<br /><br />10.11: I seem to be missing the system header file <sgtty.h>.<br /> Can someone send me a copy?<br /><br />A: Standard headers exist in part so that definitions appropriate<br /> to your compiler, operating system, and processor can be<br /> supplied. You cannot just pick up a copy of someone else's<br /> header file and expect it to work, unless that person is using<br /> exactly the same environment. Ask your compiler vendor why the<br /> file was not provided (or to send a replacement copy).<br /><br />10.12: How can I construct preprocessor #if expressions which compare<br /> strings?<br /><br />A: You can't do it directly; preprocessor #if arithmetic uses only<br /> integers. An alternative is to #define several macros with<br /> symbolic names and distinct integer values, and implement<br /> conditionals on those.<br /><br /> See also question 20.17.<br /><br /> References: K&R2 Sec. 4.11.3 p. 91; ISO Sec. 6.8.1; H&S<br /> Sec. 7.11.1 p. 225.<br /><br />10.13: Does the sizeof operator work in preprocessor #if directives?<br /><br />A: No. Preprocessing happens during an earlier phase of<br /> compilation, before type names have been parsed. Instead of<br /> sizeof, consider using the predefined constants in ANSI's<br /> <limits.h>, if applicable, or perhaps a "configure" script.<br /> (Better yet, try to write code which is inherently insensitive<br /> to type sizes; see also question 1.1.)<br /><br /> References: ISO Sec. 5.1.1.2, Sec. 6.8.1; H&S Sec. 7.11.1 p.<br /> 225.<br /><br />10.14: Can I use an #ifdef in a #define line, to define something two<br /> different ways?<br /><br />A: No. You can't "run the preprocessor on itself," so to speak.<br /> What you can do is use one of two completely separate #define<br /> lines, depending on the #ifdef setting.<br /><br /> References: ISO Sec. 6.8.3, Sec. 6.8.3.4; H&S Sec. 3.2 pp. 40-1.<br /><br />10.15: Is there anything like an #ifdef for typedefs?<br /><br />A: Unfortunately, no. You may have to keep sets of preprocessor<br /> macros (e.g. MY_TYPE_DEFINED) recording whether certain typedefs<br /> have been declared. (See also question 10.13.)<br /><br /> References: ISO Sec. 5.1.1.2, Sec. 6.8.1; H&S Sec. 7.11.1 p.<br /> 225.<br /><br />10.16: How can I use a preprocessor #if expression to tell if a machine<br /> is big-endian or little-endian?<br /><br />A: You probably can't. (Preprocessor arithmetic uses only long<br /> integers, and there is no concept of addressing.) Are you<br /> sure you need to know the machine's endianness explicitly?<br /> Usually it's better to write code which doesn't care.<br /> See also question 20.9.<br /><br /> References: ISO Sec. 6.8.1; H&S Sec. 7.11.1 p. 225.<br /><br />10.18: I inherited some code which contains far too many #ifdef's for<br /> my taste. How can I preprocess the code to leave only one<br /> conditional compilation set, without running it through the<br /> preprocessor and expanding all of the #include's and #define's<br /> as well?<br /><br />A: There are programs floating around called unifdef, rmifdef,<br /> and scpp ("selective C preprocessor") which do exactly this.<br /> See question 18.16.<br /><br />10.19: How can I list all of the predefined identifiers?<br /><br />A: There's no standard way, although it is a common need. gcc<br /> provides a -dM option which works with -E, and other compilers<br /> may provide something similar. If the compiler documentation<br /> is unhelpful, the most expedient way is probably to extract<br /> printable strings from the compiler or preprocessor executable<br /> with something like the Unix strings utility. Beware that many<br /> traditional system-specific predefined identifiers (e.g. "unix")<br /> are non-Standard (because they clash with the user's namespace)<br /> and are being removed or renamed.<br /><br />10.20: I have some old code that tries to construct identifiers with a<br /> macro like<br /><br /> #define Paste(a, b) a/**/b<br /><br /> but it doesn't work any more.<br /><br />A: It was an undocumented feature of some early preprocessor<br /> implementations (notably John Reiser's) that comments<br /> disappeared entirely and could therefore be used for token<br /> pasting. ANSI affirms (as did K&R1) that comments are replaced<br /> with white space. However, since the need for pasting tokens<br /> was demonstrated and real, ANSI introduced a well-defined token-<br /> pasting operator, ##, which can be used like this:<br /><br /> #define Paste(a, b) a##b<br /><br /> See also question 11.17.<br /><br /> References: ISO Sec. 6.8.3.3; Rationale Sec. 3.8.3.3; H&S<br /> Sec. 3.3.9 p. 52.<br /><br />10.22: Why is the macro<br /><br /> #define TRACE(n) printf("TRACE: %d\n", n)<br /><br /> giving me the warning "macro replacement within a string<br /> literal"? It seems to be expanding<br /><br /> TRACE(count);<br /> as<br /> printf("TRACE: %d\count", count);<br /><br />A: See question 11.18.<br /><br />10.23-4: I'm having trouble using macro arguments inside string<br /> literals, using the `#' operator.<br /><br />A: See questions 11.17 and 11.18.<br /><br />10.25: I've got this tricky preprocessing I want to do and I can't<br /> figure out a way to do it.<br /><br />A: C's preprocessor is not intended as a general-purpose tool.<br /> (Note also that it is not guaranteed to be available as a<br /> separate program.) Rather than forcing it to do something<br /> inappropriate, consider writing your own little special-purpose<br /> preprocessing tool, instead. You can easily get a utility like<br /> make(1) to run it for you automatically.<br /><br /> If you are trying to preprocess something other than C, consider<br /> using a general-purpose preprocessor. (One older one available<br /> on most Unix systems is m4.)<br /><br />10.26: How can I write a macro which takes a variable number of<br /> arguments?<br /><br />A: One popular trick is to define and invoke the macro with a<br /> single, parenthesized "argument" which in the macro expansion<br /> becomes the entire argument list, parentheses and all, for a<br /> function such as printf():<br /><br /> #define DEBUG(args) (printf("DEBUG: "), printf args)<br /><br /> if(n != 0) DEBUG(("n is %d\n", n));<br /><br /> The obvious disadvantage is that the caller must always remember<br /> to use the extra parentheses.<br /><br /> gcc has an extension which allows a function-like macro to<br /> accept a variable number of arguments, but it's not standard.<br /> Other possible solutions are to use different macros (DEBUG1,<br /> DEBUG2, etc.) depending on the number of arguments, or to play<br /> tricky games with commas:<br /><br /> #define DEBUG(args) (printf("DEBUG: "), printf(args))<br /> #define _ ,<br /><br /> DEBUG("i = %d" _ i)<br /><br /> C9X will introduce formal support for function-like macros with<br /> variable-length argument lists. The notation ... will appear at<br /> the end of the macro "prototype" (just as it does for varargs<br /> functions), and the pseudomacro __VA_ARGS__ in the macro<br /> definition will be replaced by the variable arguments during<br /> invocation.<br /><br /> Finally, you can always use a bona-fide function, which can<br /> take a variable number of arguments in a well-defined way.<br /> See questions 15.4 and 15.5. (If you needed a macro<br /> replacement, try using a function plus a non-function-like<br /> macro, e.g. #define printf myprintf .)<br /><br /> References: C9X Sec. 6.8.3, Sec. 6.8.3.1.<br /><br /><br />Section 11. ANSI/ISO Standard C<br /><br />11.1: What is the "ANSI C Standard?"<br /><br />A: In 1983, the American National Standards Institute (ANSI)<br /> commissioned a committee, X3J11, to standardize the C language.<br /> After a long, arduous process, including several widespread<br /> public reviews, the committee's work was finally ratified as ANS<br /> X3.159-1989 on December 14, 1989, and published in the spring of<br /> 1990. For the most part, ANSI C standardizes existing practice,<br /> with a few additions from C++ (most notably function prototypes)<br /> and support for multinational character sets (including the<br /> controversial trigraph sequences). The ANSI C standard also<br /> formalizes the C run-time library support routines.<br /><br /> More recently, the Standard has been adopted as an international<br /> standard, ISO/IEC 9899:1990, and this ISO Standard replaces the<br /> earlier X3.159 even within the United States (where it is known<br /> as ANSI/ISO 9899-1990 [1992]). As an ISO Standard, it is<br /> subject to ongoing revision through the release of Technical<br /> Corrigenda and Normative Addenda.<br /><br /> In 1994, Technical Corrigendum 1 (TC1) amended the Standard<br /> in about 40 places, most of them minor corrections or<br /> clarifications, and Normative Addendum 1 (NA1) added about 50<br /> pages of new material, mostly specifying new library functions<br /> for internationalization. In 1995, TC2 added a few more minor<br /> corrections.<br /><br /> As of this writing, a complete revision of the Standard is in<br /> its final stages. The new Standard is nicknamed "C9X" on the<br /> assumption that it will be finished by the end of 1999. (Many<br /> of this article's answers have been updated to reflect new C9X<br /> features.)<br /><br /> The original ANSI Standard included a "Rationale," explaining<br /> many of its decisions, and discussing a number of subtle points,<br /> including several of those covered here. (The Rationale was<br /> "not part of ANSI Standard X3.159-1989, but... included for<br /> information only," and is not included with the ISO Standard.<br /> A new one is being prepared for C9X.)<br /><br />11.2: How can I get a copy of the Standard?<br /><br />A: Copies are available in the United States from<br /><br /> American National Standards Institute<br /> 11 W. 42nd St., 13th floor<br /> New York, NY 10036 USA<br /> (+1) 212 642 4900<br /><br /> and<br /><br /> Global Engineering Documents<br /> 15 Inverness Way E<br /> Englewood, CO 80112 USA<br /> (+1) 303 397 2715<br /> (800) 854 7179 (U.S. & Canada)<br /><br /> In other countries, contact the appropriate national standards<br /> body, or ISO in Geneva at:<br /><br /> ISO Sales<br /> Case Postale 56<br /> CH-1211 Geneve 20<br /> Switzerland<br /><br /> (or see URL http://www.iso.ch or check the comp.std.internat FAQ<br /> list, Standards.Faq).<br /><br /> The last time I checked, the cost was $130.00 from ANSI or<br /> $400.50 from Global. Copies of the original X3.159 (including<br /> the Rationale) may still be available at $205.00 from ANSI or<br /> $162.50 from Global. Note that ANSI derives revenues to support<br /> its operations from the sale of printed standards, so electronic<br /> copies are *not* available.<br /><br /> In the U.S., it may be possible to get a copy of the original<br /> ANSI X3.159 (including the Rationale) as "FIPS PUB 160" from<br /><br /> National Technical Information Service (NTIS)<br /> U.S. Department of Commerce<br /> Springfield, VA 22161<br /> 703 487 4650<br /><br /> The mistitled _Annotated ANSI C Standard_, with annotations by<br /> Herbert Schildt, contains most of the text of ISO 9899; it is<br /> published by Osborne/McGraw-Hill, ISBN 0-07-881952-0, and sells<br /> in the U.S. for approximately $40. It has been suggested that<br /> the price differential between this work and the official<br /> standard reflects the value of the annotations: they are plagued<br /> by numerous errors and omissions, and a few pages of the<br /> Standard itself are missing. Many people on the net recommend<br /> ignoring the annotations entirely. A review of the annotations<br /> ("annotated annotations") by Clive Feather can be found on the<br /> web at http://www.lysator.liu.se/c/schildt.html .<br /><br /> The text of the Rationale (not the full Standard) can be<br /> obtained by anonymous ftp from ftp.uu.net (see question 18.16)<br /> in directory doc/standards/ansi/X3.159-1989, and is also<br /> available on the web at http://www.lysator.liu.se/c/rat/title.html .<br /> The Rationale has also been printed by Silicon Press,<br /> ISBN 0-929306-07-4.<br /><br /> Public review drafts of C9X are available from ISO/IEC<br /> JTC1/SC22/WG14's web site, http://www.dkuug.dk/JTC1/SC22/WG14/ .<br /><br /> See also question 11.2b below.<br /><br />11.2b: Where can I get information about updates to the Standard?<br /><br />A: You can find information (including C9X drafts) at<br /> the web sites http://www.lysator.liu.se/c/index.html,<br /> http://www.dkuug.dk/JTC1/SC22/WG14/, and http://www.dmk.com/ .<br /><br />11.3: My ANSI compiler complains about a mismatch when it sees<br /><br /> extern int func(float);<br /><br /> int func(x)<br /> float x;<br /> { ...<br /><br />A: You have mixed the new-style prototype declaration<br /> "extern int func(float);" with the old-style definition<br /> "int func(x) float x;". It is usually possible to mix the two<br /> styles (see question 11.4), but not in this case.<br /><br /> Old C (and ANSI C, in the absence of prototypes, and in variable-<br /> length argument lists; see question 15.2) "widens" certain<br /> arguments when they are passed to functions. floats are<br /> promoted to double, and characters and short integers are<br /> promoted to int. (For old-style function definitions, the<br /> values are automatically converted back to the corresponding<br /> narrower types within the body of the called function, if they<br /> are declared that way there.)<br /><br /> This problem can be fixed either by using new-style syntax<br /> consistently in the definition:<br /><br /> int func(float x) { ... }<br /><br /> or by changing the new-style prototype declaration to match the<br /> old-style definition:<br /><br /> extern int func(double);<br /><br /> (In this case, it would be clearest to change the old-style<br /> definition to use double as well, if possible.)<br /><br /> It is arguably much safer to avoid "narrow" (char, short int,<br /> and float) function arguments and return types altogether.<br /><br /> See also question 1.25.<br /><br /> References: K&R1 Sec. A7.1 p. 186; K&R2 Sec. A7.3.2 p. 202; ISO<br /> Sec. 6.3.2.2, Sec. 6.5.4.3; Rationale Sec. 3.3.2.2,<br /> Sec. 3.5.4.3; H&S Sec. 9.2 pp. 265-7, Sec. 9.4 pp. 272-3.<br /><br />11.4: Can you mix old-style and new-style function syntax?<br /><br />A: Doing so is legal, but requires a certain amount of care (see<br /> especially question 11.3). Modern practice, however, is to<br /> use the prototyped form in both declarations and definitions.<br /> (The old-style syntax is marked as obsolescent, so official<br /> support for it may be removed some day.)<br /><br /> References: ISO Sec. 6.7.1, Sec. 6.9.5; H&S Sec. 9.2.2 pp. 265-<br /> 7, Sec. 9.2.5 pp. 269-70.<br /><br />11.5: Why does the declaration<br /><br /> extern int f(struct x *p);<br /><br /> give me an obscure warning message about "struct x introduced in<br /> prototype scope"?<br /><br />A: In a quirk of C's normal block scoping rules, a structure<br /> declared (or even mentioned) for the first time within a<br /> prototype cannot be compatible with other structures declared in<br /> the same source file (it goes out of scope at the end of the<br /> prototype).<br /><br /> To resolve the problem, precede the prototype with the vacuous-<br /> looking declaration<br /><br /> struct x;<br /><br /> which places an (incomplete) declaration of struct x at file<br /> scope, so that all following declarations involving struct x can<br /> at least be sure they're referring to the same struct x.<br /><br /> References: ISO Sec. 6.1.2.1, Sec. 6.1.2.6, Sec. 6.5.2.3.<br /><br />11.8: I don't understand why I can't use const values in initializers<br /> and array dimensions, as in<br /><br /> const int n = 5;<br /> int a[n];<br /><br />A: The const qualifier really means "read-only"; an object so<br /> qualified is a run-time object which cannot (normally) be<br /> assigned to. The value of a const-qualified object is therefore<br /> *not* a constant expression in the full sense of the term. (C<br /> is unlike C++ in this regard.) When you need a true compile-<br /> time constant, use a preprocessor #define (or perhaps an enum).<br /><br /> References: ISO Sec. 6.4; H&S Secs. 7.11.2,7.11.3 pp. 226-7.<br /><br />11.9: What's the difference between "const char *p" and<br /> "char * const p"?<br /><br />A: "const char *p" (which can also be written "char const *p")<br /> declares a pointer to a constant character (you can't change<br /> the character); "char * const p" declares a constant pointer<br /> to a (variable) character (i.e. you can't change the pointer).<br /><br /> Read these "inside out" to understand them; see also question<br /> 1.21.<br /><br /> References: ISO Sec. 6.5.4.1; Rationale Sec. 3.5.4.1; H&S<br /> Sec. 4.4.4 p. 81.<br /><br />11.10: Why can't I pass a char ** to a function which expects a<br /> const char **?<br /><br />A: You can use a pointer-to-T (for any type T) where a pointer-to-<br /> const-T is expected. However, the rule (an explicit exception)<br /> which permits slight mismatches in qualified pointer types is<br /> not applied recursively, but only at the top level.<br /><br /> You must use explicit casts (e.g. (const char **) in this case)<br /> when assigning (or passing) pointers which have qualifier<br /> mismatches at other than the first level of indirection.<br /><br /> References: ISO Sec. 6.1.2.6, Sec. 6.3.16.1, Sec. 6.5.3; H&S<br /> Sec. 7.9.1 pp. 221-2.<br /><br />11.12a: What's the correct declaration of main()?<br /><br />A: Either int main(), int main(void), or int main(int argc,<br /> char *argv[]) (with alternate spellings of argc and *argv[]<br /> obviously allowed). See also questions 11.12b to 11.15 below.<br /><br /> References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p.<br /> 416; CT&P Sec. 3.10 pp. 50-51.<br /><br />11.12b: Can I declare main() as void, to shut off these annoying<br /> "main returns no value" messages?<br /><br />A: No. main() must be declared as returning an int, and as<br /> taking either zero or two arguments, of the appropriate types.<br /> If you're calling exit() but still getting warnings, you may<br /> have to insert a redundant return statement (or use some kind<br /> of "not reached" directive, if available).<br /><br /> Declaring a function as void does not merely shut off or<br /> rearrange warnings: it may also result in a different function<br /> call/return sequence, incompatible with what the caller (in<br /> main's case, the C run-time startup code) expects.<br /><br /> (Note that this discussion of main() pertains only to "hosted"<br /> implementations; none of it applies to "freestanding"<br /> implementations, which may not even have main(). However,<br /> freestanding implementations are comparatively rare, and if<br /> you're using one, you probably know it. If you've never heard<br /> of the distinction, you're probably using a hosted<br /> implementation, and the above rules apply.)<br /><br /> References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p.<br /> 416; CT&P Sec. 3.10 pp. 50-51.<br /><br />11.13: But what about main's third argument, envp?<br /><br />A: It's a non-standard (though common) extension. If you really<br /> need to access the environment in ways beyond what the standard<br /> getenv() function provides, though, the global variable environ<br /> is probably a better avenue (though it's equally non-standard).<br /><br /> References: ISO Sec. G.5.1; H&S Sec. 20.1 pp. 416-7.<br /><br />11.14: I believe that declaring void main() can't fail, since I'm<br /> calling exit() instead of returning, and anyway my operating<br /> system ignores a program's exit/return status.<br /><br />A: It doesn't matter whether main() returns or not, or whether<br /> anyone looks at the status; the problem is that when main() is<br /> misdeclared, its caller (the runtime startup code) may not even<br /> be able to *call* it correctly (due to the potential clash of<br /> calling conventions; see question 11.12b).<br /><br /> It has been reported that programs using void main() and<br /> compiled using BC++ 4.5 can crash. Some compilers (including<br /> DEC C V4.1 and gcc with certain warnings enabled) will complain<br /> about void main().<br /><br /> Your operating system may ignore the exit status, and<br /> void main() may work for you, but it is not portable and not<br /> correct.<br /><br />11.15: The book I've been using, _C Programing for the Compleat Idiot_,<br /> always uses void main().<br /><br />A: Perhaps its author counts himself among the target audience.<br /> Many books unaccountably use void main() in examples, and assert<br /> that it's correct. They're wrong.<br /><br />11.16: Is exit(status) truly equivalent to returning the same status<br /> from main()?<br /><br />A: Yes and no. The Standard says that they are equivalent.<br /> However, a return from main() cannot be expected to work if<br /> data local to main() might be needed during cleanup; see also<br /> question 16.4. A few very old, nonconforming systems may once<br /> have had problems with one or the other form. (Finally, the<br /> two forms are obviously not equivalent in a recursive call to<br /> main().)<br /><br /> References: K&R2 Sec. 7.6 pp. 163-4; ISO Sec. 5.1.2.2.3.<br /><br />11.17: I'm trying to use the ANSI "stringizing" preprocessing operator<br /> `#' to insert the value of a symbolic constant into a message,<br /> but it keeps stringizing the macro's name rather than its value.<br /><br />A: You can use something like the following two-step procedure to<br /> force a macro to be expanded as well as stringized:<br /><br /> #define Str(x) #x<br /> #define Xstr(x) Str(x)<br /> #define OP plus<br /> char *opname = Xstr(OP);<br /><br /> This code sets opname to "plus" rather than "OP".<br /><br /> An equivalent circumlocution is necessary with the token-pasting<br /> operator ## when the values (rather than the names) of two<br /> macros are to be concatenated.<br /><br /> References: ISO Sec. 6.8.3.2, Sec. 6.8.3.5.<br /><br />11.18: What does the message "warning: macro replacement within a<br /> string literal" mean?<br /><br />A: Some pre-ANSI compilers/preprocessors interpreted macro<br /> definitions like<br /><br /> #define TRACE(var, fmt) printf("TRACE: var = fmt\n", var)<br /><br /> such that invocations like<br /><br /> TRACE(i, %d);<br /><br /> were expanded as<br /><br /> printf("TRACE: i = %d\n", i);<br /><br /> In other words, macro parameters were expanded even inside<br /> string literals and character constants.<br /><br /> Macro expansion is *not* defined in this way by K&R or by<br /> Standard C. When you do want to turn macro arguments into<br /> strings, you can use the new # preprocessing operator, along<br /> with string literal concatenation (another new ANSI feature):<br /><br /> #define TRACE(var, fmt) \<br /> printf("TRACE: " #var " = " #fmt "\n", var)<br /><br /> See also question 11.17 above.<br /><br /> References: H&S Sec. 3.3.8 p. 51.<br /><br />11.19: I'm getting strange syntax errors inside lines I've #ifdeffed<br /> out.<br /><br />A: Under ANSI C, the text inside a "turned off" #if, #ifdef, or<br /> #ifndef must still consist of "valid preprocessing tokens."<br /> This means that the characters " and ' must each be paired just<br /> as in real C code, and the pairs mustn't cross line boundaries.<br /> (Note particularly that an apostrophe within a contracted word<br /> looks like the beginning of a character constant.) Therefore,<br /> natural-language comments and pseudocode should always be<br /> written between the "official" comment delimiters /* and */.<br /> (But see question 20.20, and also 10.25.)<br /><br /> References: ISO Sec. 5.1.1.2, Sec. 6.1; H&S Sec. 3.2 p. 40.<br /><br />11.20: What are #pragmas and what are they good for?<br /><br />A: The #pragma directive provides a single, well-defined "escape<br /> hatch" which can be used for all sorts of (nonportable)<br /> implementation-specific controls and extensions: source listing<br /> control, structure packing, warning suppression (like lint's old<br /> /* NOTREACHED */ comments), etc.<br /><br /> References: ISO Sec. 6.8.6; H&S Sec. 3.7 p. 61.<br /><br />11.21: What does "#pragma once" mean? I found it in some header files.<br /><br />A: It is an extension implemented by some preprocessors to help<br /> make header files idempotent; it is equivalent to the #ifndef<br /> trick mentioned in question 10.7, though less portable.<br /><br />11.22: Is char a[3] = "abc"; legal? What does it mean?<br /><br />A: It is legal in ANSI C (and perhaps in a few pre-ANSI systems),<br /> though useful only in rare circumstances. It declares an array<br /> of size three, initialized with the three characters 'a', 'b',<br /> and 'c', *without* the usual terminating '\0' character. The<br /> array is therefore not a true C string and cannot be used with<br /> strcpy, printf %s, etc.<br /><br /> Most of the time, you should let the compiler count the<br /> initializers when initializing arrays (in the case of the<br /> initializer "abc", of course, the computed size will be 4).<br /><br /> References: ISO Sec. 6.5.7; H&S Sec. 4.6.4 p. 98.<br /><br />11.24: Why can't I perform arithmetic on a void * pointer?<br /><br />A: The compiler doesn't know the size of the pointed-to objects.<br /> Before performing arithmetic, convert the pointer either to<br /> char * or to the pointer type you're trying to manipulate (but<br /> see also question 4.5).<br /><br /> References: ISO Sec. 6.1.2.5, Sec. 6.3.6; H&S Sec. 7.6.2 p. 204.<br /><br />11.25: What's the difference between memcpy() and memmove()?<br /><br />A: memmove() offers guaranteed behavior if the source and<br /> destination arguments overlap. memcpy() makes no such<br /> guarantee, and may therefore be more efficiently implementable.<br /> When in doubt, it's safer to use memmove().<br /><br /> References: K&R2 Sec. B3 p. 250; ISO Sec. 7.11.2.1,<br /> Sec. 7.11.2.2; Rationale Sec. 4.11.2; H&S Sec. 14.3 pp. 341-2;<br /> PCS Sec. 11 pp. 165-6.<br /><br />11.26: What should malloc(0) do? Return a null pointer or a pointer to<br /> 0 bytes?<br /><br />A: The ANSI/ISO Standard says that it may do either; the behavior<br /> is implementation-defined (see question 11.33).<br /><br /> References: ISO Sec. 7.10.3; PCS Sec. 16.1 p. 386.<br /><br />11.27: Why does the ANSI Standard not guarantee more than six case-<br /> insensitive characters of external identifier significance?<br /><br />A: The problem is older linkers which are under the control of<br /> neither the ANSI/ISO Standard nor the C compiler developers on<br /> the systems which have them. The limitation is only that<br /> identifiers be *significant* in the first six characters, not<br /> that they be restricted to six characters in length. This<br /> limitation is marked in the Standard as "obsolescent", and will<br /> be removed in C9X.<br /><br /> References: ISO Sec. 6.1.2, Sec. 6.9.1; Rationale Sec. 3.1.2;<br /> C9X Sec. 6.1.2; H&S Sec. 2.5 pp. 22-3.<br /><br />11.29: My compiler is rejecting the simplest possible test programs,<br /> with all kinds of syntax errors.<br /><br />A: Perhaps it is a pre-ANSI compiler, unable to accept function<br /> prototypes and the like.<br /><br /> See also questions 1.31, 10.9, 11.30, and 16.1b.<br /><br />11.30: Why are some ANSI/ISO Standard library functions showing up as<br /> undefined, even though I've got an ANSI compiler?<br /><br />A: It's possible to have a compiler available which accepts ANSI<br /> syntax, but not to have ANSI-compatible header files or run-time<br /> libraries installed. (In fact, this situation is rather common<br /> when using a non-vendor-supplied compiler such as gcc.) See<br /> also questions 11.29, 13.25, and 13.26.<br /><br />11.31: Does anyone have a tool for converting old-style C programs to<br /> ANSI C, or vice versa, or for automatically generating<br /> prototypes?<br /><br />A: Two programs, protoize and unprotoize, convert back and forth<br /> between prototyped and "old style" function definitions and<br /> declarations. (These programs do *not* handle full-blown<br /> translation between "Classic" C and ANSI C.) These programs are<br /> part of the FSF's GNU C compiler distribution; see question<br /> 18.3.<br /><br /> The unproto program (/pub/unix/unproto5.shar.Z on<br /> ftp.win.tue.nl) is a filter which sits between the preprocessor<br /> and the next compiler pass, converting most of ANSI C to<br /> traditional C on-the-fly.<br /><br /> The GNU GhostScript package comes with a little program called<br /> ansi2knr.<br /><br /> Before converting ANSI C back to old-style, beware that such a<br /> conversion cannot always be made both safely and automatically.<br /> ANSI C introduces new features and complexities not found in K&R<br /> C. You'll especially need to be careful of prototyped function<br /> calls; you'll probably need to insert explicit casts. See also<br /> questions 11.3 and 11.29.<br /><br /> Several prototype generators exist, many as modifications to<br /> lint. A program called CPROTO was posted to comp.sources.misc<br /> in March, 1992. There is another program called "cextract."<br /> Many vendors supply simple utilities like these with their<br /> compilers. See also question 18.16. (But be careful when<br /> generating prototypes for old functions with "narrow"<br /> parameters; see question 11.3.)<br /><br />11.32: Why won't the Frobozz Magic C Compiler, which claims to be ANSI<br /> compliant, accept this code? I know that the code is ANSI,<br /> because gcc accepts it.<br /><br />A: Many compilers support a few non-Standard extensions, gcc more<br /> so than most. Are you sure that the code being rejected doesn't<br /> rely on such an extension? It is usually a bad idea to perform<br /> experiments with a particular compiler to determine properties<br /> of a language; the applicable standard may permit variations, or<br /> the compiler may be wrong. See also question 11.35.<br /><br />11.33: People seem to make a point of distinguishing between<br /> implementation-defined, unspecified, and undefined behavior.<br /> What's the difference?<br /><br />A: Briefly: implementation-defined means that an implementation<br /> must choose some behavior and document it. Unspecified means<br /> that an implementation should choose some behavior, but need not<br /> document it. Undefined means that absolutely anything might<br /> happen. In no case does the Standard impose requirements; in<br /> the first two cases it occasionally suggests (and may require a<br /> choice from among) a small set of likely behaviors.<br /><br /> Note that since the Standard imposes *no* requirements on the<br /> behavior of a compiler faced with an instance of undefined<br /> behavior, the compiler can do absolutely anything. In<br /> particular, there is no guarantee that the rest of the program<br /> will perform normally. It's perilous to think that you can<br /> tolerate undefined behavior in a program; see question 3.2 for a<br /> relatively simple example.<br /><br /> If you're interested in writing portable code, you can ignore<br /> the distinctions, as you'll want to avoid code that depends on<br /> any of the three behaviors.<br /><br /> See also questions 3.9, and 11.34.<br /><br /> References: ISO Sec. 3.10, Sec. 3.16, Sec. 3.17; Rationale<br /> Sec. 1.6.<br /><br />11.34: I'm appalled that the ANSI Standard leaves so many issues<br /> undefined. Isn't a Standard's whole job to standardize these<br /> things?<br /><br />A: It has always been a characteristic of C that certain constructs<br /> behaved in whatever way a particular compiler or a particular<br /> piece of hardware chose to implement them. This deliberate<br /> imprecision often allows compilers to generate more efficient<br /> code for common cases, without having to burden all programs<br /> with extra code to assure well-defined behavior of cases deemed<br /> to be less reasonable. Therefore, the Standard is simply<br /> codifying existing practice.<br /><br /> A programming language standard can be thought of as a treaty<br /> between the language user and the compiler implementor. Parts<br /> of that treaty consist of features which the compiler<br /> implementor agrees to provide, and which the user may assume<br /> will be available. Other parts, however, consist of rules which<br /> the user agrees to follow and which the implementor may assume<br /> will be followed. As long as both sides uphold their<br /> guarantees, programs have a fighting chance of working<br /> correctly. If *either* side reneges on any of its commitments,<br /> nothing is guaranteed to work.<br /><br /> See also question 11.35.<br /><br /> References: Rationale Sec. 1.1.<br /><br />11.35: People keep saying that the behavior of i = i++ is undefined,<br /> but I just tried it on an ANSI-conforming compiler, and got the<br /> results I expected.<br /><br />A: A compiler may do anything it likes when faced with undefined<br /> behavior (and, within limits, with implementation-defined and<br /> unspecified behavior), including doing what you expect. It's<br /> unwise to depend on it, though. See also questions 11.32,<br /> 11.33, and 11.34.<br /><br /><br />Section 12. Stdio<br /><br />12.1: What's wrong with this code?<br /><br /> char c;<br /> while((c = getchar()) != EOF) ...<br /><br />A: For one thing, the variable to hold getchar's return value must<br /> be an int. getchar() can return all possible character values,<br /> as well as EOF. By squeezing getchar's return value into a<br /> char, either a normal character might be misinterpreted as EOF,<br /> or the EOF might be altered (particularly if type char is<br /> unsigned) and so never seen.<br /><br /> References: K&R1 Sec. 1.5 p. 14; K&R2 Sec. 1.5.1 p. 16; ISO<br /> Sec. 6.1.2.5, Sec. 7.9.1, Sec. 7.9.7.5; H&S Sec. 5.1.3 p. 116,<br /> Sec. 15.1, Sec. 15.6; CT&P Sec. 5.1 p. 70; PCS Sec. 11 p. 157.<br /><br />12.2: Why does the code<br /><br /> while(!feof(infp)) {<br /> fgets(buf, MAXLINE, infp);<br /> fputs(buf, outfp);<br /> }<br /><br /> copy the last line twice?<br /><br />A: In C, end-of-file is only indicated *after* an input routine has<br /> tried to read, and failed. (In other words, C's I/O is not like<br /> Pascal's.) Usually, you should just check the return value of<br /> the input routine (in this case, fgets() will return NULL on end-<br /> of-file); often, you don't need to use feof() at all.<br /><br /> References: K&R2 Sec. 7.6 p. 164; ISO Sec. 7.9.3, Sec. 7.9.7.1,<br /> Sec. 7.9.10.2; H&S Sec. 15.14 p. 382.<br /><br />12.4: My program's prompts and intermediate output don't always show<br /> up on the screen, especially when I pipe the output through<br /> another program.<br /><br />A: It's best to use an explicit fflush(stdout) whenever output<br /> should definitely be visible (and especially if the text does<br /> not end with \n). Several mechanisms attempt to perform the<br /> fflush() for you, at the "right time," but they tend to apply<br /> only when stdout is an interactive terminal. (See also question<br /> 12.24.)<br /><br /> References: ISO Sec. 7.9.5.2.<br /><br />12.5: How can I read one character at a time, without waiting for the<br /> RETURN key?<br /><br />A: See question 19.1.<br /><br />12.6: How can I print a '%' character in a printf format string? I<br /> tried \%, but it didn't work.<br /><br />A: Simply double the percent sign: %% .<br /><br /> \% can't work, because the backslash \ is the *compiler's*<br /> escape character, while here our problem is that the % is<br /> essentially printf's escape character.<br /><br /> See also question 19.17.<br /><br /> References: K&R1 Sec. 7.3 p. 147; K&R2 Sec. 7.2 p. 154; ISO<br /> Sec. 7.9.6.1.<br /><br />12.9: Someone told me it was wrong to use %lf with printf(). How can<br /> printf() use %f for type double, if scanf() requires %lf?<br /><br />A: It's true that printf's %f specifier works with both float and<br /> double arguments. Due to the "default argument promotions"<br /> (which apply in variable-length argument lists such as<br /> printf's, whether or not prototypes are in scope), values of<br /> type float are promoted to double, and printf() therefore sees<br /> only doubles. (printf() does accept %Lf, for long double.)<br /> See also questions 12.13 and 15.2.<br /><br /> References: K&R1 Sec. 7.3 pp. 145-47, Sec. 7.4 pp. 147-50; K&R2<br /> Sec. 7.2 pp. 153-44, Sec. 7.4 pp. 157-59; ISO Sec. 7.9.6.1,<br /> Sec. 7.9.6.2; H&S Sec. 15.8 pp. 357-64, Sec. 15.11 pp. 366-78;<br /> CT&P Sec. A.1 pp. 121-33.<br /><br />12.9b: What printf format should I use for a typedef like size_t<br /> when I don't know whether it's long or some other type?<br /><br />A: Use a cast to convert the value to a known, conservatively-<br /> sized type, then use the printf format matching that type.<br /> For example, to print the size of a type, you might use<br /><br /> printf("%lu", (unsigned long)sizeof(thetype));<br /><br />12.10: How can I implement a variable field width with printf?<br /> That is, instead of %8d, I want the width to be specified<br /> at run time.<br /><br />A: printf("%*d", width, x) will do just what you want.<br /> See also question 12.15.<br /><br /> References: K&R1 Sec. 7.3; K&R2 Sec. 7.2; ISO Sec. 7.9.6.1; H&S<br /> Sec. 15.11.6; CT&P Sec. A.1.<br /><br />12.11: How can I print numbers with commas separating the thousands?<br /> What about currency formatted numbers?<br /><br />A: The functions in <locale.h> begin to provide some support for<br /> these operations, but there is no standard routine for doing<br /> either task. (The only thing printf() does in response to a<br /> custom locale setting is to change its decimal-point character.)<br /><br /> References: ISO Sec. 7.4; H&S Sec. 11.6 pp. 301-4.<br /><br />12.12: Why doesn't the call scanf("%d", i) work?<br /><br />A: The arguments you pass to scanf() must always be pointers.<br /> To fix the fragment above, change it to scanf("%d", &i) .<br /><br />12.13: Why doesn't this code:<br /><br /> double d;<br /> scanf("%f", &d);<br /><br /> work?<br /><br />A: Unlike printf(), scanf() uses %lf for values of type double, and<br /> %f for float. See also question 12.9.<br /><br />12.15: How can I specify a variable width in a scanf() format string?<br /><br />A: You can't; an asterisk in a scanf() format string means to<br /> suppress assignment. You may be able to use ANSI stringizing<br /> and string concatenation to accomplish about the same thing, or<br /> you can construct the scanf format string at run time.<br /><br />12.17: When I read numbers from the keyboard with scanf "%d\n", it<br /> seems to hang until I type one extra line of input.<br /><br />A: Perhaps surprisingly, \n in a scanf format string does *not*<br /> mean to expect a newline, but rather to read and discard<br /> characters as long as each is a whitespace character.<br /> See also question 12.20.<br /><br /> References: K&R2 Sec. B1.3 pp. 245-6; ISO Sec. 7.9.6.2; H&S<br /> Sec. 15.8 pp. 357-64.<br /><br />12.18: I'm reading a number with scanf %d and then a string with<br /> gets(), but the compiler seems to be skipping the call to<br /> gets()!<br /><br />A: scanf %d won't consume a trailing newline. If the input number<br /> is immediately followed by a newline, that newline will<br /> immediately satisfy the gets().<br /><br /> As a general rule, you shouldn't try to interlace calls to<br /> scanf() with calls to gets() (or any other input routines);<br /> scanf's peculiar treatment of newlines almost always leads to<br /> trouble. Either use scanf() to read everything or nothing.<br /><br /> See also questions 12.20 and 12.23.<br /><br /> References: ISO Sec. 7.9.6.2; H&S Sec. 15.8 pp. 357-64.<br /><br />12.19: I figured I could use scanf() more safely if I checked its<br /> return value to make sure that the user typed the numeric values<br /> I expect, but sometimes it seems to go into an infinite loop.<br /><br />A: When scanf() is attempting to convert numbers, any non-numeric<br /> characters it encounters terminate the conversion *and are left<br /> on the input stream*. Therefore, unless some other steps are<br /> taken, unexpected non-numeric input "jams" scanf() again and<br /> again: scanf() never gets past the bad character(s) to encounter<br /> later, valid data. If the user types a character like `x' in<br /> response to a numeric scanf format such as %d or %f, code that<br /> simply re-prompts and retries the same scanf() call will<br /> immediately reencounter the same `x'.<br /><br /> See also question 12.20.<br /><br /> References: ISO Sec. 7.9.6.2; H&S Sec. 15.8 pp. 357-64.<br /><br />12.20: Why does everyone say not to use scanf()? What should I use<br /> instead?<br /><br />A: scanf() has a number of problems -- see questions 12.17, 12.18,<br /> and 12.19. Also, its %s format has the same problem that gets()<br /> has (see question 12.23) -- it's hard to guarantee that the<br /> receiving buffer won't overflow.<br /><br /> More generally, scanf() is designed for relatively structured,<br /> formatted input (its name is in fact derived from "scan<br /> formatted"). If you pay attention, it will tell you whether it<br /> succeeded or failed, but it can tell you only approximately<br /> where it failed, and not at all how or why. It's nearly<br /> impossible to do decent error recovery with scanf(); usually<br /> it's far easier to read entire lines (with fgets() or the like),<br /> then interpret them, either using sscanf() or some other<br /> techniques. (Functions like strtol(), strtok(), and atoi() are<br /> often useful; see also question 13.6.) If you do use any scanf<br /> variant, be sure to check the return value to make sure that the<br /> expected number of items were found. Also, if you use %s, be<br /> sure to guard against buffer overflow.<br /><br /> References: K&R2 Sec. 7.4 p. 159.<br /><br />12.21: How can I tell how much destination buffer space I'll need for<br /> an arbitrary sprintf call? How can I avoid overflowing the<br /> destination buffer with sprintf()?<br /><br />A: When the format string being used with sprintf() is known and<br /> relatively simple, you can sometimes predict a buffer size in an<br /> ad-hoc way. If the format consists of one or two %s's, you can<br /> count the fixed characters in the format string yourself (or let<br /> sizeof count them for you) and add in the result of calling<br /> strlen() on the string(s) to be inserted. For integers, the<br /> number of characters produced by %d is no more than<br /><br /> ((sizeof(int) * CHAR_BIT + 2) / 3 + 1) /* +1 for '-' */<br /><br /> (CHAR_BIT is in <limits.h>), though this computation may be over-<br /> conservative. (It computes the number of characters required<br /> for a base-8 representation of a number; a base-10 expansion is<br /> guaranteed to take as much room or less.)<br /><br /> When the format string is more complicated, or is not even known<br /> until run time, predicting the buffer size becomes as difficult<br /> as reimplementing sprintf(), and correspondingly error-prone<br /> (and inadvisable). A last-ditch technique which is sometimes<br /> suggested is to use fprintf() to print the same text to a bit<br /> bucket or temporary file, and then to look at fprintf's return<br /> value or the size of the file (but see question 19.12, and worry<br /> about write errors).<br /><br /> If there's any chance that the buffer might not be big enough,<br /> you won't want to call sprintf() without some guarantee that the<br /> buffer will not overflow and overwrite some other part of<br /> memory. If the format string is known, you can limit %s<br /> expansion by using %.Ns for some N, or %.*s (see also question<br /> 12.10).<br /><br /> The "obvious" solution to the overflow problem is a length-<br /> limited version of sprintf(), namely snprintf(). It would be<br /> used like this:<br /><br /> snprintf(buf, bufsize, "You typed \"%s\"", answer);<br /><br /> snprintf() has been available in several stdio libraries<br /> (including GNU and 4.4bsd) for several years. It will be<br /> standardized in C9X.<br /><br /> When the C9X snprintf() arrives, it will also be possible to use<br /> it to predict the size required for an arbitrary sprintf() call.<br /> C9X snprintf() will return the number of characters it would<br /> have placed in the buffer, not just how many it did place.<br /> Furthermore, it may be called with a buffer size of 0 and a<br /> null pointer as the destination buffer. Therefore, the call<br /><br /> nch = snprintf(NULL, 0, fmtstring, /* other arguments */ );<br /><br /> will compute the number of characters required for the fully-<br /> formatted string.<br /><br /> References: C9X Sec. 7.13.6.6.<br /><br />12.23: Why does everyone say not to use gets()?<br /><br />A: Unlike fgets(), gets() cannot be told the size of the buffer<br /> it's to read into, so it cannot be prevented from overflowing<br /> that buffer. As a general rule, always use fgets(). See<br /> question 7.1 for a code fragment illustrating the replacement of<br /> gets() with fgets().<br /><br /> References: Rationale Sec. 4.9.7.2; H&S Sec. 15.7 p. 356.<br /><br />12.24: Why does errno contain ENOTTY after a call to printf()?<br /><br />A: Many implementations of the stdio package adjust their behavior<br /> slightly if stdout is a terminal. To make the determination,<br /> these implementations perform some operation which happens to<br /> fail (with ENOTTY) if stdout is not a terminal. Although the<br /> output operation goes on to complete successfully, errno still<br /> contains ENOTTY. (Note that it is only meaningful for a program<br /> to inspect the contents of errno after an error has been<br /> reported; errno is not guaranteed to be 0 otherwise.)<br /><br /> References: ISO Sec. 7.1.4, Sec. 7.9.10.3; CT&P Sec. 5.4 p. 73;<br /> PCS Sec. 14 p. 254.<br /><br />12.25: What's the difference between fgetpos/fsetpos and ftell/fseek?<br /> What are fgetpos() and fsetpos() good for?<br /><br />A: ftell() and fseek() use type long int to represent offsets<br /> (positions) in a file, and may therefore be limited to offsets<br /> of about 2 billion (2**31-1). The newer fgetpos() and fsetpos()<br /> functions, on the other hand, use a special typedef, fpos_t, to<br /> represent the offsets. The type behind this typedef, if chosen<br /> appropriately, can represent arbitrarily large offsets, so<br /> fgetpos() and fsetpos() can be used with arbitrarily huge files.<br /> fgetpos() and fsetpos() also record the state associated with<br /> multibyte streams. See also question 1.4.<br /><br /> References: K&R2 Sec. B1.6 p. 248; ISO Sec. 7.9.1,<br /> Secs. 7.9.9.1,7.9.9.3; H&S Sec. 15.5 p. 252.<br /><br />12.26: How can I flush pending input so that a user's typeahead isn't<br /> read at the next prompt? Will fflush(stdin) work?<br /><br />A: fflush() is defined only for output streams. Since its<br /> definition of "flush" is to complete the writing of buffered<br /> characters (not to discard them), discarding unread input would<br /> not be an analogous meaning for fflush on input streams.<br /><br /> There is no standard way to discard unread characters from a<br /> stdio input stream, nor would such a way necessarily be<br /> sufficient, since unread characters can also accumulate in<br /> other, OS-level input buffers. You may be able to read and<br /> discard characters until \n, or use the curses flushinp()<br /> function, or use some system-specific technique. See also<br /> questions 19.1 and 19.2.<br /><br /> References: ISO Sec. 7.9.5.2; H&S Sec. 15.2.<br /><br />12.30: I'm trying to update a file in place, by using fopen mode "r+",<br /> reading a certain string, and writing back a modified string,<br /> but it's not working.<br /><br />A: Be sure to call fseek before you write, both to seek back to the<br /> beginning of the string you're trying to overwrite, and because<br /> an fseek or fflush is always required between reading and<br /> writing in the read/write "+" modes. Also, remember that you<br /> can only overwrite characters with the same number of<br /> replacement characters, and that overwriting in text mode may<br /> truncate the file at that point. See also question 19.14.<br /><br /> References: ISO Sec. 7.9.5.3.<br /><br />12.33: How can I redirect stdin or stdout to a file from within a<br /> program?<br /><br />A: Use freopen() (but see question 12.34 below).<br /><br /> References: ISO Sec. 7.9.5.4; H&S Sec. 15.2.<br /><br />12.34: Once I've used freopen(), how can I get the original stdout (or<br /> stdin) back?<br /><br />A: There isn't a good way. If you need to switch back, the best<br /> solution is not to have used freopen() in the first place. Try<br /> using your own explicit output (or input) stream variable, which<br /> you can reassign at will, while leaving the original stdout (or<br /> stdin) undisturbed.<br /><br /> It is barely possible to save away information about a stream<br /> before calling freopen(), such that the original stream can<br /> later be restored, but the methods involve system-specific calls<br /> such as dup(), or copying or inspecting the contents of a FILE<br /> structure, which is exceedingly nonportable and unreliable.<br /><br />12.36b: How can I arrange to have output go two places at once,<br /> e.g. to the screen and to a file?<br /><br />A: You can't do this directly, but you could write your<br /> own printf variant which printed everything twice.<br /> See question 15.5.<br /><br />12.38: How can I read a binary data file properly? I'm occasionally<br /> seeing 0x0a and 0x0d values getting garbled, and I seem to hit<br /> EOF prematurely if the data contains the value 0x1a.<br /><br />A: When you're reading a binary data file, you should specify "rb"<br /> mode when calling fopen(), to make sure that text file<br /> translations do not occur. Similarly, when writing binary data<br /> files, use "wb".<br /><br /> Note that the text/binary distinction is made when you open the<br /> file: once a file is open, it doesn't matter which I/O calls you<br /> use on it. See also question 20.5.<br /><br /> References: ISO Sec. 7.9.5.3; H&S Sec. 15.2.1 p. 348.<br /><br /><br />Section 13. Library Functions<br /><br />13.1: How can I convert numbers to strings (the opposite of atoi)?<br /> Is there an itoa() function?<br /><br />A: Just use sprintf(). (Don't worry that sprintf() may be<br /> overkill, potentially wasting run time or code space; it works<br /> well in practice.) See the examples in the answer to question<br /> 7.5a; see also question 12.21.<br /><br /> You can obviously use sprintf() to convert long or floating-<br /> point numbers to strings as well (using %ld or %f).<br /><br /> References: K&R1 Sec. 3.6 p. 60; K&R2 Sec. 3.6 p. 64.<br /><br />13.2: Why does strncpy() not always place a '\0' terminator in the<br /> destination string?<br /><br />A: strncpy() was first designed to handle a now-obsolete data<br /> structure, the fixed-length, not-necessarily-\0-terminated<br /> "string." (A related quirk of strncpy's is that it pads short<br /> strings with multiple \0's, out to the specified length.)<br /> strncpy() is admittedly a bit cumbersome to use in other<br /> contexts, since you must often append a '\0' to the destination<br /> string by hand. You can get around the problem by using<br /> strncat() instead of strncpy(): if the destination string starts<br /> out empty, strncat() does what you probably wanted strncpy() to<br /> do. Another possibility is sprintf(dest, "%.*s", n, source) .<br /><br /> When arbitrary bytes (as opposed to strings) are being copied,<br /> memcpy() is usually a more appropriate function to use than<br /> strncpy().<br /><br />13.5: Why do some versions of toupper() act strangely if given an<br /> upper-case letter?<br /> Why does some code call islower() before toupper()?<br /><br />A: Older versions of toupper() and tolower() did not always work<br /> correctly on arguments which did not need converting (i.e. on<br /> digits or punctuation or letters already of the desired case).<br /> In ANSI/ISO Standard C, these functions are guaranteed to work<br /> appropriately on all character arguments.<br /><br /> References: ISO Sec. 7.3.2; H&S Sec. 12.9 pp. 320-1; PCS p. 182.<br /><br />13.6: How can I split up a string into whitespace-separated fields?<br /> How can I duplicate the process by which main() is handed argc<br /> and argv?<br /><br />A: The only Standard function available for this kind of<br /> "tokenizing" is strtok(), although it can be tricky to use and<br /> it may not do everything you want it to. (For instance, it does<br /> not handle quoting.)<br /><br /> References: K&R2 Sec. B3 p. 250; ISO Sec. 7.11.5.8; H&S<br /> Sec. 13.7 pp. 333-4; PCS p. 178.<br /><br />13.7: I need some code to do regular expression and wildcard matching.<br /><br />A: Make sure you recognize the difference between classic regular<br /> expressions (variants of which are used in such Unix utilities<br /> as ed and grep), and filename wildcards (variants of which are<br /> used by most operating systems).<br /><br /> There are a number of packages available for matching regular<br /> expressions. Most packages use a pair of functions, one for<br /> "compiling" the regular expression, and one for "executing" it<br /> (i.e. matching strings against it). Look for header files named<br /> <regex.h> or <regexp.h>, and functions called regcmp/regex,<br /> regcomp/regexec, or re_comp/re_exec. (These functions may<br /> exist in a separate regexp library.) A popular, freely-<br /> redistributable regexp package by Henry Spencer is available<br /> from ftp.cs.toronto.edu in pub/regexp.shar.Z or in several other<br /> archives. The GNU project has a package called rx. See also<br /> question 18.16.<br /><br /> Filename wildcard matching (sometimes called "globbing") is done<br /> in a variety of ways on different systems. On Unix, wildcards<br /> are automatically expanded by the shell before a process is<br /> invoked, so programs rarely have to worry about them explicitly.<br /> Under MS-DOS compilers, there is often a special object file<br /> which can be linked in to a program to expand wildcards while<br /> argv is being built. Several systems (including MS-DOS and VMS)<br /> provide system services for listing or opening files specified<br /> by wildcards. Check your compiler/library documentation. See<br /> also questions 19.20 and 20.3.<br /><br />13.8: I'm trying to sort an array of strings with qsort(), using<br /> strcmp() as the comparison function, but it's not working.<br /><br />A: By "array of strings" you probably mean "array of pointers to<br /> char." The arguments to qsort's comparison function are<br /> pointers to the objects being sorted, in this case, pointers to<br /> pointers to char. strcmp(), however, accepts simple pointers to<br /> char. Therefore, strcmp() can't be used directly. Write an<br /> intermediate comparison function like this:<br /><br /> /* compare strings via pointers */<br /> int pstrcmp(const void *p1, const void *p2)<br /> {<br /> return strcmp(*(char * const *)p1, *(char * const *)p2);<br /> }<br /><br /> The comparison function's arguments are expressed as "generic<br /> pointers," const void *. They are converted back to what they<br /> "really are" (pointers to pointers to char) and dereferenced,<br /> yielding char *'s which can be passed to strcmp().<br /><br /> (Don't be misled by the discussion in K&R2 Sec. 5.11 pp. 119-20,<br /> which is not discussing the Standard library's qsort).<br /><br /> References: ISO Sec. 7.10.5.2; H&S Sec. 20.5 p. 419.<br /><br />13.9: Now I'm trying to sort an array of structures with qsort(). My<br /> comparison function takes pointers to structures, but the<br /> compiler complains that the function is of the wrong type for<br /> qsort(). How can I cast the function pointer to shut off the<br /> warning?<br /><br />A: The conversions must be in the comparison function, which must<br /> be declared as accepting "generic pointers" (const void *) as<br /> discussed in question 13.8 above. The comparison function might<br /> look like<br /><br /> int mystructcmp(const void *p1, const void *p2)<br /> {<br /> const struct mystruct *sp1 = p1;<br /> const struct mystruct *sp2 = p2;<br /> /* now compare sp1->whatever and sp2-> ... */<br /><br /> (The conversions from generic pointers to struct mystruct<br /> pointers happen in the initializations sp1 = p1 and sp2 = p2;<br /> the compiler performs the conversions implicitly since p1 and p2<br /> are void pointers.)<br /><br /> If, on the other hand, you're sorting pointers to structures,<br /> you'll need indirection, as in question 13.8:<br /> sp1 = *(struct mystruct * const *)p1 .<br /><br /> In general, it is a bad idea to insert casts just to "shut the<br /> compiler up." Compiler warnings are usually trying to tell you<br /> something, and unless you really know what you're doing, you<br /> ignore or muzzle them at your peril. See also question 4.9.<br /><br /> References: ISO Sec. 7.10.5.2; H&S Sec. 20.5 p. 419.<br /><br />13.10: How can I sort a linked list?<br /><br />A: Sometimes it's easier to keep the list in order as you build it<br /> (or perhaps to use a tree instead). Algorithms like insertion<br /> sort and merge sort lend themselves ideally to use with linked<br /> lists. If you want to use a standard library function, you can<br /> allocate a temporary array of pointers, fill it in with pointers<br /> to all your list nodes, call qsort(), and finally rebuild the<br /> list pointers based on the sorted array.<br /><br /> References: Knuth Sec. 5.2.1 pp. 80-102, Sec. 5.2.4 pp. 159-168;<br /> Sedgewick Sec. 8 pp. 98-100, Sec. 12 pp. 163-175.<br /><br />13.11: How can I sort more data than will fit in memory?<br /><br />A: You want an "external sort," which you can read about in Knuth,<br /> Volume 3. The basic idea is to sort the data in chunks (as much<br /> as will fit in memory at one time), write each sorted chunk to a<br /> temporary file, and then merge the files. Your operating system<br /> may provide a general-purpose sort utility, and if so, you can<br /> try invoking it from within your program: see questions 19.27<br /> and 19.30.<br /><br /> References: Knuth Sec. 5.4 pp. 247-378; Sedgewick Sec. 13 pp.<br /> 177-187.<br /><br />13.12: How can I get the current date or time of day in a C program?<br /><br />A: Just use the time(), ctime(), localtime() and/or strftime()<br /> functions. Here is a simple example:<br /><br /> #include <stdio.h><br /> #include <time.h><br /><br /> int main()<br /> {<br /> time_t now;<br /> time(&now);<br /> printf("It's %.24s.\n", ctime(&now));<br /> return 0;<br /> }<br /><br /> References: K&R2 Sec. B10 pp. 255-7; ISO Sec. 7.12; H&S Sec. 18.<br /><br />13.13: I know that the library function localtime() will convert a<br /> time_t into a broken-down struct tm, and that ctime() will<br /> convert a time_t to a printable string. How can I perform the<br /> inverse operations of converting a struct tm or a string into a<br /> time_t?<br /><br />A: ANSI C specifies a library function, mktime(), which converts a<br /> struct tm to a time_t.<br /><br /> Converting a string to a time_t is harder, because of the wide<br /> variety of date and time formats which might be encountered.<br /> Some systems provide a strptime() function, which is basically<br /> the inverse of strftime(). Other popular functions are partime()<br /> (widely distributed with the RCS package) and getdate() (and a<br /> few others, from the C news distribution). See question 18.16.<br /><br /> References: K&R2 Sec. B10 p. 256; ISO Sec. 7.12.2.3; H&S<br /> Sec. 18.4 pp. 401-2.<br /><br />13.14: How can I add N days to a date? How can I find the difference<br /> between two dates?<br /><br />A: The ANSI/ISO Standard C mktime() and difftime() functions<br /> provide some support for both problems. mktime() accepts non-<br /> normalized dates, so it is straightforward to take a filled-in<br /> struct tm, add or subtract from the tm_mday field, and call<br /> mktime() to normalize the year, month, and day fields (and<br /> incidentally convert to a time_t value). difftime() computes<br /> the difference, in seconds, between two time_t values; mktime()<br /> can be used to compute time_t values for two dates to be<br /> subtracted.<br /><br /> These solutions are only guaranteed to work correctly for dates<br /> in the range which can be represented as time_t's. The tm_mday<br /> field is an int, so day offsets of more than 32,736 or so may<br /> cause overflow. Note also that at daylight saving time<br /> changeovers, local days are not 24 hours long (so don't assume<br /> that division by 86400 will be exact).<br /><br /> Another approach to both problems is to use "Julian day<br /> numbers". Code for handling Julian day numbers can be found<br /> in the Snippets collection (see question 18.15c), the<br /> Simtel/Oakland archives (file JULCAL10.ZIP, see question 18.16),<br /> and the "Date conversions" article mentioned in the References.<br /><br /> See also questions 13.13, 20.31, and 20.32.<br /><br /> References: K&R2 Sec. B10 p. 256; ISO Secs. 7.12.2.2,7.12.2.3;<br /> H&S Secs. 18.4,18.5 pp. 401-2; David Burki, "Date Conversions".<br /><br />13.14b: Does C have any Year 2000 problems?<br /><br />A: No, although poorly-written C programs do.<br /><br /> The tm_year field of struct tm holds the value of the year minus<br /> 1900; this field will therefore contain the value 100 for the<br /> year 2000. Code that uses tm_year correctly (by adding or<br /> subtracting 1900 when converting to or from human-readable<br /> 4-digit year representations) will have no problems at the turn<br /> of the millennium. Any code that uses tm_year incorrectly,<br /> however, such as by using it directly as a human-readable<br /> 2-digit year, or setting it from a 4-digit year with code like<br /><br /> tm.tm_year = yyyy % 100; /* WRONG */<br /><br /> or printing it as an allegedly human-readable 4-digit year with<br /> code like<br /><br /> printf("19%d", tm.tm_year); /* WRONG */<br /><br /> will have grave y2k problems indeed. See also question 20.32.<br /><br /> References: K&R2 Sec. B10 p. 255; ISO Sec. 7.12.1; H&S Sec. 18.4<br /> p. 401.<br /><br />13.15: I need a random number generator.<br /><br />A: The Standard C library has one: rand(). The implementation on<br /> your system may not be perfect, but writing a better one isn't<br /> necessarily easy, either.<br /><br /> If you do find yourself needing to implement your own random<br /> number generator, there is plenty of literature out there; see<br /> the References. There are also any number of packages on the<br /> net: look for r250, RANLIB, and FSULTRA (see question 18.16).<br /><br /> References: K&R2 Sec. 2.7 p. 46, Sec. 7.8.7 p. 168; ISO<br /> Sec. 7.10.2.1; H&S Sec. 17.7 p. 393; PCS Sec. 11 p. 172; Knuth<br /> Vol. 2 Chap. 3 pp. 1-177; Park and Miller, "Random Number<br /> Generators: Good Ones are Hard to Find".<br /><br />13.16: How can I get random integers in a certain range?<br /><br />A: The obvious way,<br /><br /> rand() % N /* POOR */<br /><br /> (which tries to return numbers from 0 to N-1) is poor, because<br /> the low-order bits of many random number generators are<br /> distressingly *non*-random. (See question 13.18.) A better<br /> method is something like<br /><br /> (int)((double)rand() / ((double)RAND_MAX + 1) * N)<br /><br /> If you're worried about using floating point, you could use<br /><br /> rand() / (RAND_MAX / N + 1)<br /><br /> Both methods obviously require knowing RAND_MAX (which ANSI<br /> #defines in <stdlib.h>), and assume that N is much less than<br /> RAND_MAX.<br /><br /> (Note, by the way, that RAND_MAX is a *constant* telling you<br /> what the fixed range of the C library rand() function is. You<br /> cannot set RAND_MAX to some other value, and there is no way of<br /> requesting that rand() return numbers in some other range.)<br /><br /> If you're starting with a random number generator which returns<br /> floating-point values between 0 and 1, all you have to do to get<br /> integers from 0 to N-1 is multiply the output of that generator<br /> by N.<br /><br /> References: K&R2 Sec. 7.8.7 p. 168; PCS Sec. 11 p. 172.<br /><br />13.17: Each time I run my program, I get the same sequence of numbers<br /> back from rand().<br /><br />A: You can call srand() to seed the pseudo-random number generator<br /> with a truly random initial value. Popular seed values are the<br /> time of day, or the elapsed time before the user presses a key<br /> (although keypress times are hard to determine portably; see<br /> question 19.37). (Note also that it's rarely useful to call<br /> srand() more than once during a run of a program; in particular,<br /> don't try calling srand() before each call to rand(), in an<br /> attempt to get "really random" numbers.)<br /><br /> References: K&R2 Sec. 7.8.7 p. 168; ISO Sec. 7.10.2.2; H&S<br /> Sec. 17.7 p. 393.<br /><br />13.18: I need a random true/false value, so I'm just taking rand() % 2,<br /> but it's alternating 0, 1, 0, 1, 0...<br /><br />A: Poor pseudorandom number generators (such as the ones<br /> unfortunately supplied with some systems) are not very random in<br /> the low-order bits. Try using the higher-order bits: see<br /> question 13.16.<br /><br /> References: Knuth Sec. 3.2.1.1 pp. 12-14.<br /><br />13.20: How can I generate random numbers with a normal or Gaussian<br /> distribution?<br /><br />A: Here is one method, recommended by Knuth and due originally to<br /> Marsaglia:<br /><br /> #include <stdlib.h><br /> #include <math.h><br /><br /> double gaussrand()<br /> {<br /> static double V1, V2, S;<br /> static int phase = 0;<br /> double X;<br /><br /> if(phase == 0) {<br /> do {<br /> double U1 = (double)rand() / RAND_MAX;<br /> double U2 = (double)rand() / RAND_MAX;<br /><br /> V1 = 2 * U1 - 1;<br /> V2 = 2 * U2 - 1;<br /> S = V1 * V1 + V2 * V2;<br /> } while(S >= 1 || S == 0);<br /><br /> X = V1 * sqrt(-2 * log(S) / S);<br /> } else<br /> X = V2 * sqrt(-2 * log(S) / S);<br /><br /> phase = 1 - phase;<br /><br /> return X;<br /> }<br /><br /> See the extended versions of this list (see question 20.40) for<br /> other ideas.<br /><br /> References: Knuth Sec. 3.4.1 p. 117; Marsaglia and Bray,<br /> "A Convenient Method for Generating Normal Variables";<br /> Press et al., _Numerical Recipes in C_ Sec. 7.2 pp. 288-290.<br /><br />13.24: I'm trying to port this A: Those functions are variously<br /> old program. Why do I obsolete; you should<br /> get "undefined external" instead:<br /> errors for:<br /><br /> index? use strchr.<br /> rindex? use strrchr.<br /> bcopy? use memmove, after<br /> interchanging the first and<br /> second arguments (see also<br /> question 11.25).<br /> bcmp? use memcmp.<br /> bzero? use memset, with a second<br /> argument of 0.<br /><br /> References: PCS Sec. 11.<br /><br />13.25: I keep getting errors due to library functions being undefined,<br /> but I'm #including all the right header files.<br /><br />A: In general, a header file contains only declarations. In some<br /> cases (especially if the functions are nonstandard) obtaining<br /> the actual *definitions* may require explicitly asking for the<br /> correct libraries to be searched when you link the program.<br /> (#including the header doesn't do that.) See also questions<br /> 11.30, 13.26, and 14.3.<br /><br />13.26: I'm still getting errors due to library functions being<br /> undefined, even though I'm explicitly requesting the right<br /> libraries while linking.<br /><br />A: Many linkers make one pass over the list of object files and<br /> libraries you specify, and extract from libraries only those<br /> modules which satisfy references which have so far come up as<br /> undefined. Therefore, the order in which libraries are listed<br /> with respect to object files (and each other) is significant;<br /> usually, you want to search the libraries last. (For example,<br /> under Unix, put any -l options towards the end of the command<br /> line.) See also question 13.28.<br /><br />13.28: What does it mean when the linker says that _end is undefined?<br /><br />A: That message is a quirk of the old Unix linkers. You get an<br /> error about _end being undefined only when other symbols are<br /> undefined, too -- fix the others, and the error about _end will<br /> disappear. (See also questions 13.25 and 13.26.)<br /><br /><br />Section 14. Floating Point<br /><br />14.1: When I set a float variable to, say, 3.1, why is printf printing<br /> it as 3.0999999?<br /><br />A: Most computers use base 2 for floating-point numbers as well as<br /> for integers. In base 2, one divided by ten is an infinitely-<br /> repeating fraction (0.0001100110011...), so fractions such as<br /> 3.1 (which look like they can be exactly represented in decimal)<br /> cannot be represented exactly in binary. Depending on how<br /> carefully your compiler's binary/decimal conversion routines<br /> (such as those used by printf) have been written, you may see<br /> discrepancies when numbers (especially low-precision floats) not<br /> exactly representable in base 2 are assigned or read in and then<br /> printed (i.e. converted from base 10 to base 2 and back again).<br /> See also question 14.6.<br /><br />14.2: I'm trying to take some square roots, but I'm getting crazy<br /> numbers.<br /><br />A: Make sure that you have #included <math.h>, and correctly<br /> declared other functions returning double. (Another library<br /> function to be careful with is atof(), which is declared in<br /> <stdlib.h>.) See also question 14.3 below.<br /><br /> References: CT&P Sec. 4.5 pp. 65-6.<br /><br />14.3: I'm trying to do some simple trig, and I am #including <math.h>,<br /> but I keep getting "undefined: sin" compilation errors.<br /><br />A: Make sure you're actually linking with the math library. For<br /> instance, under Unix, you usually need to use the -lm option, at<br /> the *end* of the command line, when compiling/linking. See also<br /> questions 13.25, 13.26, and 14.2.<br /><br />14.4: My floating-point calculations are acting strangely and giving<br /> me different answers on different machines.<br /><br />A: First, see question 14.2 above.<br /><br /> If the problem isn't that simple, recall that digital computers<br /> usually use floating-point formats which provide a close but by<br /> no means exact simulation of real number arithmetic. Underflow,<br /> cumulative precision loss, and other anomalies are often<br /> troublesome.<br /><br /> Don't assume that floating-point results will be exact, and<br /> especially don't assume that floating-point values can be<br /> compared for equality. (Don't throw haphazard "fuzz factors"<br /> in, either; see question 14.5.)<br /><br /> These problems are no worse for C than they are for any other<br /> computer language. Certain aspects of floating-point are<br /> usually defined as "however the processor does them" (see also<br /> question 11.34), otherwise a compiler for a machine without the<br /> "right" model would have to do prohibitively expensive<br /> emulations.<br /><br /> This article cannot begin to list the pitfalls associated with,<br /> and workarounds appropriate for, floating-point work. A good<br /> numerical programming text should cover the basics; see also the<br /> references below.<br /><br /> References: Kernighan and Plauger, _The Elements of Programming<br /> Style_ Sec. 6 pp. 115-8; Knuth, Volume 2 chapter 4; David<br /> Goldberg, "What Every Computer Scientist Should Know about<br /> Floating-Point Arithmetic".<br /><br />14.5: What's a good way to check for "close enough" floating-point<br /> equality?<br /><br />A: Since the absolute accuracy of floating point values varies, by<br /> definition, with their magnitude, the best way of comparing two<br /> floating point values is to use an accuracy threshold which is<br /> relative to the magnitude of the numbers being compared. Rather<br /> than<br /><br /> double a, b;<br /> ...<br /> if(a == b) /* WRONG */<br /><br /> use something like<br /><br /> #include <math.h><br /><br /> if(fabs(a - b) <= epsilon * fabs(a))<br /><br /> for some suitably-chosen degree of closeness epsilon (as long as<br /> a is nonzero!).<br /><br /> References: Knuth Sec. 4.2.2 pp. 217-8.<br /><br />14.6: How do I round numbers?<br /><br />A: The simplest and most straightforward way is with code like<br /><br /> (int)(x + 0.5)<br /><br /> This technique won't work properly for negative numbers,<br /> though (for which you could use something like<br /> (int)(x < 0 ? x - 0.5 : x + 0.5)).<br /><br />14.7: Why doesn't C have an exponentiation operator?<br /><br />A: Because few processors have an exponentiation instruction.<br /> C has a pow() function, declared in <math.h>, although explicit<br /> multiplication is usually better for small positive integral<br /> exponents.<br /><br /> References: ISO Sec. 7.5.5.1; H&S Sec. 17.6 p. 393.<br /><br />14.8: The predefined constant M_PI seems to be missing from my<br /> machine's copy of <math.h>.<br /><br />A: That constant (which is apparently supposed to be the value of<br /> pi, accurate to the machine's precision), is not standard. If<br /> you need pi, you'll have to define it yourself, or compute it<br /> with 4*atan(1.0).<br /><br /> References: PCS Sec. 13 p. 237.<br /><br />14.9: How do I test for IEEE NaN and other special values?<br /><br />A: Many systems with high-quality IEEE floating-point<br /> implementations provide facilities (e.g. predefined constants,<br /> and functions like isnan(), either as nonstandard extensions in<br /> <math.h> or perhaps in <ieee.h> or <nan.h>) to deal with these<br /> values cleanly, and work is being done to formally standardize<br /> such facilities. A crude but usually effective test for NaN is<br /> exemplified by<br /><br /> #define isnan(x) ((x) != (x))<br /><br /> although non-IEEE-aware compilers may optimize the test away.<br /><br /> C9X will provide isnan(), fpclassify(), and several other<br /> classification routines.<br /><br /> Another possibility is to to format the value in question using<br /> sprintf(): on many systems it generates strings like "NaN" and<br /> "Inf" which you could compare for in a pinch.<br /><br /> See also question 19.39.<br /><br /> References: C9X Sec. 7.7.3.<br /><br />14.11: What's a good way to implement complex numbers in C?<br /><br />A: It is straightforward to define a simple structure and some<br /> arithmetic functions to manipulate them. C9X will support<br /> complex as a standard type. See also questions 2.7, 2.10, and<br /> 14.12.<br /><br /> References: C9X Sec. 6.1.2.5, Sec. 7.8.<br /><br />14.12: I'm looking for some code to do:<br /> Fast Fourier Transforms (FFT's)<br /> matrix arithmetic (multiplication, inversion, etc.)<br /> complex arithmetic<br /><br />A: Ajay Shah has prepared a nice index of free numerical<br /> software which has been archived pretty widely; one URL<br /> is ftp://ftp.math.psu.edu/pub/FAQ/numcomp-free-c .<br /> See also questions 18.13, 18.15c, and 18.16.<br /><br />14.13: I'm having trouble with a Turbo C program which crashes and says<br /> something like "floating point formats not linked."<br /><br />A: Some compilers for small machines, including Borland's<br /> (and Ritchie's original PDP-11 compiler), leave out certain<br /> floating point support if it looks like it will not be needed.<br /> In particular, the non-floating-point versions of printf()<br /> and scanf() save space by not including code to handle %e, %f,<br /> and %g. It happens that Borland's heuristics for determining<br /> whether the program uses floating point are insufficient,<br /> and the programmer must sometimes insert a dummy call to a<br /> floating-point library function (such as sqrt(); any will<br /> do) to force loading of floating-point support. (See the<br /> comp.os.msdos.programmer FAQ list for more information.)<br /><br /><br />Section 15. Variable-Length Argument Lists<br /><br />15.1: I heard that you have to #include <stdio.h> before calling<br /> printf(). Why?<br /><br />A: So that a proper prototype for printf() will be in scope.<br /><br /> A compiler may use a different calling sequence for functions<br /> which accept variable-length argument lists. (It might do so if<br /> calls using variable-length argument lists were less efficient<br /> than those using fixed-length.) Therefore, a prototype<br /> (indicating, using the ellipsis notation "...", that the<br /> argument list is of variable length) must be in scope whenever a<br /> varargs function is called, so that the compiler knows to use<br /> the varargs calling mechanism.<br /><br /> References: ISO Sec. 6.3.2.2, Sec. 7.1.7; Rationale<br /> Sec. 3.3.2.2, Sec. 4.1.6; H&S Sec. 9.2.4 pp. 268-9, Sec. 9.6 pp.<br /> 275-6.<br /><br />15.2: How can %f be used for both float and double arguments in<br /> printf()? Aren't they different types?<br /><br />A: In the variable-length part of a variable-length argument list,<br /> the "default argument promotions" apply: types char and<br /> short int are promoted to int, and float is promoted to double.<br /> (These are the same promotions that apply to function calls<br /> without a prototype in scope, also known as "old style" function<br /> calls; see question 11.3.) Therefore, printf's %f format always<br /> sees a double. (Similarly, %c always sees an int, as does %hd.)<br /> See also questions 12.9 and 12.13.<br /><br /> References: ISO Sec. 6.3.2.2; H&S Sec. 6.3.5 p. 177, Sec. 9.4<br /> pp. 272-3.<br /><br />15.3: I had a frustrating problem which turned out to be caused by the<br /> line<br /><br /> printf("%d", n);<br /><br /> where n was actually a long int. I thought that ANSI function<br /> prototypes were supposed to guard against argument type<br /> mismatches like this.<br /><br />A: When a function accepts a variable number of arguments, its<br /> prototype does not (and cannot) provide any information about<br /> the number and types of those variable arguments. Therefore,<br /> the usual protections do *not* apply in the variable-length part<br /> of variable-length argument lists: the compiler cannot perform<br /> implicit conversions or (in general) warn about mismatches.<br /><br /> See also questions 5.2, 11.3, 12.9, and 15.2.<br /><br />15.4: How can I write a function that takes a variable number of<br /> arguments?<br /><br />A: Use the facilities of the <stdarg.h> header.<br /><br /> Here is a function which concatenates an arbitrary number of<br /> strings into malloc'ed memory:<br /><br /> #include <stdlib.h> /* for malloc, NULL, size_t */<br /> #include <stdarg.h> /* for va_ stuff */<br /> #include <string.h> /* for strcat et al. */<br /><br /> char *vstrcat(char *first, ...)<br /> {<br /> size_t len;<br /> char *retbuf;<br /> va_list argp;<br /> char *p;<br /><br /> if(first == NULL)<br /> return NULL;<br /><br /> len = strlen(first);<br /><br /> va_start(argp, first);<br /><br /> while((p = va_arg(argp, char *)) != NULL)<br /> len += strlen(p);<br /><br /> va_end(argp);<br /><br /> retbuf = malloc(len + 1); /* +1 for trailing \0 */<br /><br /> if(retbuf == NULL)<br /> return NULL; /* error */<br /><br /> (void)strcpy(retbuf, first);<br /><br /> va_start(argp, first); /* restart; 2nd scan */<br /><br /> while((p = va_arg(argp, char *)) != NULL)<br /> (void)strcat(retbuf, p);<br /><br /> va_end(argp);<br /><br /> return retbuf;<br /> }<br /><br /> Usage is something like<br /><br /> char *str = vstrcat("Hello, ", "world!", (char *)NULL);<br /><br /> Note the cast on the last argument; see questions 5.2 and 15.3.<br /> (Also note that the caller must free the returned, malloc'ed<br /> storage.)<br /><br /> See also question 15.7.<br /><br /> References: K&R2 Sec. 7.3 p. 155, Sec. B7 p. 254; ISO Sec. 7.8;<br /> Rationale Sec. 4.8; H&S Sec. 11.4 pp. 296-9; CT&P Sec. A.3 pp.<br /> 139-141; PCS Sec. 11 pp. 184-5, Sec. 13 p. 242.<br /><br />15.5: How can I write a function that takes a format string and a<br /> variable number of arguments, like printf(), and passes them to<br /> printf() to do most of the work?<br /><br />A: Use vprintf(), vfprintf(), or vsprintf().<br /><br /> Here is an error() function which prints an error message,<br /> preceded by the string "error: " and terminated with a newline:<br /><br /> #include <stdio.h><br /> #include <stdarg.h><br /><br /> void error(char *fmt, ...)<br /> {<br /> va_list argp;<br /> fprintf(stderr, "error: ");<br /> va_start(argp, fmt);<br /> vfprintf(stderr, fmt, argp);<br /> va_end(argp);<br /> fprintf(stderr, "\n");<br /> }<br /><br /> See also question 15.7.<br /><br /> References: K&R2 Sec. 8.3 p. 174, Sec. B1.2 p. 245; ISO<br /> Secs. 7.9.6.7,7.9.6.8,7.9.6.9; H&S Sec. 15.12 pp. 379-80; PCS<br /> Sec. 11 pp. 186-7.<br /><br />15.6: How can I write a function analogous to scanf(), that calls<br /> scanf() to do most of the work?<br /><br />A: C9X will support vscanf(), vfscanf(), and vsscanf().<br /> (Until then, you may be on your own.)<br /><br /> References: C9X Secs. 7.3.6.12-14.<br /><br />15.7: I have a pre-ANSI compiler, without <stdarg.h>. What can I do?<br /><br />A: There's an older header, <varargs.h>, which offers about the<br /> same functionality.<br /><br /> References: H&S Sec. 11.4 pp. 296-9; CT&P Sec. A.2 pp. 134-139;<br /> PCS Sec. 11 pp. 184-5, Sec. 13 p. 250.<br /><br />15.8: How can I discover how many arguments a function was actually<br /> called with?<br /><br />A: This information is not available to a portable program. Some<br /> old systems provided a nonstandard nargs() function, but its use<br /> was always questionable, since it typically returned the number<br /> of words passed, not the number of arguments. (Structures, long<br /> ints, and floating point values are usually passed as several<br /> words.)<br /><br /> Any function which takes a variable number of arguments must be<br /> able to determine *from the arguments themselves* how many of<br /> them there are. printf-like functions do this by looking for<br /> formatting specifiers (%d and the like) in the format string<br /> (which is why these functions fail badly if the format string<br /> does not match the argument list). Another common technique,<br /> applicable when the arguments are all of the same type, is to<br /> use a sentinel value (often 0, -1, or an appropriately-cast null<br /> pointer) at the end of the list (see the execl() and vstrcat()<br /> examples in questions 5.2 and 15.4). Finally, if their types<br /> are predictable, you can pass an explicit count of the number of<br /> variable arguments (although it's usually a nuisance for the<br /> caller to supply).<br /><br /> References: PCS Sec. 11 pp. 167-8.<br /><br />15.9: My compiler isn't letting me declare a function<br /><br /> int f(...)<br /> {<br /> }<br /><br /> i.e. with no fixed arguments.<br /><br />A: Standard C requires at least one fixed argument, in part so that<br /> you can hand it to va_start(). See also question 15.10.<br /><br /> References: ISO Sec. 6.5.4, Sec. 6.5.4.3, Sec. 7.8.1.1; H&S<br /> Sec. 9.2 p. 263.<br /><br />15.10: I have a varargs function which accepts a float parameter. Why<br /> isn't<br /><br /> va_arg(argp, float)<br /><br /> working?<br /><br />A: In the variable-length part of variable-length argument lists,<br /> the old "default argument promotions" apply: arguments of type<br /> float are always promoted (widened) to type double, and types<br /> char and short int are promoted to int. Therefore, it is never<br /> correct to invoke va_arg(argp, float); instead you should always<br /> use va_arg(argp, double). Similarly, use va_arg(argp, int) to<br /> retrieve arguments which were originally char, short, or int.<br /> (For analogous reasons, the last "fixed" argument, as handed to<br /> va_start(), should not be widenable, either.) See also<br /> questions 11.3 and 15.2.<br /><br /> References: ISO Sec. 6.3.2.2; Rationale Sec. 4.8.1.2; H&S<br /> Sec. 11.4 p. 297.<br /><br />15.11: I can't get va_arg() to pull in an argument of type pointer-to-<br /> function.<br /><br />A: The type-rewriting games which the va_arg() macro typically<br /> plays are stymied by overly-complicated types such as pointer-to-<br /> function. If you use a typedef for the function pointer type,<br /> however, all will be well. See also question 1.21.<br /><br /> References: ISO Sec. 7.8.1.2; Rationale Sec. 4.8.1.2.<br /><br />15.12: How can I write a function which takes a variable number of<br /> arguments and passes them to some other function (which takes a<br /> variable number of arguments)?<br /><br />A: In general, you cannot. Ideally, you should provide a version<br /> of that other function which accepts a va_list pointer<br /> (analogous to vfprintf(); see question 15.5 above). If the<br /> arguments must be passed directly as actual arguments, or if you<br /> do not have the option of rewriting the second function to<br /> accept a va_list (in other words, if the second, called function<br /> must accept a variable number of arguments, not a va_list), no<br /> portable solution is possible. (The problem could perhaps be<br /> solved by resorting to machine-specific assembly language; see<br /> also question 15.13 below.)<br /><br />15.13: How can I call a function with an argument list built up at run<br /> time?<br /><br />A: There is no guaranteed or portable way to do this. If you're<br /> curious, ask this list's editor, who has a few wacky ideas you<br /> could try...<br /><br /> Instead of an actual argument list, you might consider passing<br /> an array of generic (void *) pointers. The called function can<br /> then step through the array, much like main() might step through<br /> argv. (Obviously this works only if you have control over all<br /> the called functions.)<br /><br /> (See also question 19.36.)<br /><br /><br />Section 16. Strange Problems<br /><br />16.1b: I'm getting baffling syntax errors which make no sense at all,<br /> and it seems like large chunks of my program aren't being<br /> compiled.<br /><br />A: Check for unclosed comments or mismatched #if/#ifdef/#ifndef/<br /> #else/#endif directives; remember to check header files, too.<br /> (See also questions 2.18, 10.9, and 11.29.)<br /><br />16.1c: Why isn't my procedure call working? The compiler seems to skip<br /> right over it.<br /><br />A: Does the code look like this?<br /><br /> myprocedure;<br /><br /> C has only functions, and function calls always require<br /> parenthesized argument lists, even if empty. Use<br /><br /> myprocedure();<br /><br />16.3: This program crashes before it even runs! (When single-stepping<br /> with a debugger, it dies before the first statement in main().)<br /><br />A: You probably have one or more very large (kilobyte or more)<br /> local arrays. Many systems have fixed-size stacks, and those<br /> which perform dynamic stack allocation automatically (e.g. Unix)<br /> can be confused when the stack tries to grow by a huge chunk all<br /> at once. It is often better to declare large arrays with static<br /> duration (unless of course you need a fresh set with each<br /> recursive call, in which case you could dynamically allocate<br /> them with malloc(); see also question 1.31).<br /><br /> (See also questions 11.12b, 16.4, 16.5, and 18.4.)<br /><br />16.4: I have a program that seems to run correctly, but it crashes as<br /> it's exiting, *after* the last statement in main(). What could<br /> be causing this?<br /><br />A: Look for a misdeclared main() (see questions 2.18 and 10.9), or<br /> local buffers passed to setbuf() or setvbuf(), or problems in<br /> cleanup functions registered by atexit(). See also questions<br /> 7.5a and 11.16.<br /><br /> References: CT&P Sec. 5.3 pp. 72-3.<br /><br />16.5: This program runs perfectly on one machine, but I get weird<br /> results on another. Stranger still, adding or removing a<br /> debugging printout changes the symptoms...<br /><br />A: Lots of things could be going wrong; here are a few of the more<br /> common things to check:<br /><br /> uninitialized local variables (see also question 7.1)<br /><br /> integer overflow, especially on 16-bit machines,<br /> especially of an intermediate result when doing things<br /> like a * b / c (see also question 3.14)<br /><br /> undefined evaluation order (see questions 3.1 through 3.4)<br /><br /> omitted declaration of external functions, especially<br /> those which return something other than int, or have<br /> "narrow" or variable arguments (see questions 1.25, 11.3,<br /> 14.2, and 15.1)<br /><br /> dereferenced null pointers (see section 5)<br /><br /> improper malloc/free use: assuming malloc'ed memory<br /> contains 0, assuming freed storage persists, freeing<br /> something twice, corrupting the malloc arena (see also<br /> questions 7.19 and 7.20)<br /><br /> pointer problems in general (see also question 16.8)<br /><br /> mismatch between printf() format and arguments, especially<br /> trying to print long ints using %d (see question 12.9)<br /><br /> trying to allocate more memory than an unsigned int can<br /> count, especially on machines with limited memory (see<br /> also questions 7.16 and 19.23)<br /><br /> array bounds problems, especially of small, temporary<br /> buffers, perhaps used for constructing strings with<br /> sprintf() (see also questions 7.1 and 12.21)<br /><br /> invalid assumptions about the mapping of typedefs,<br /> especially size_t<br /><br /> floating point problems (see questions 14.1 and 14.4)<br /><br /> anything you thought was a clever exploitation of the way<br /> you believe code is generated for your specific system<br /><br /> Proper use of function prototypes can catch several of these<br /> problems; lint would catch several more. See also questions<br /> 16.3, 16.4, and 18.4.<br /><br />16.6: Why does this code:<br /><br /> char *p = "hello, world!";<br /> p[0] = 'H';<br /><br /> crash?<br /><br />A: String literals are not necessarily modifiable, except (in<br /> effect) when they are used as array initializers. Try<br /><br /> char a[] = "hello, world!";<br /><br /> See also question 1.32.<br /><br /> References: ISO Sec. 6.1.4; H&S Sec. 2.7.4 pp. 31-2.<br /><br />16.8: What do "Segmentation violation" and "Bus error" mean?<br /><br />A: These generally mean that your program tried to access memory it<br /> shouldn't have, invariably as a result of stack corruption or<br /> improper pointer use. Likely causes are overflow of local<br /> ("automatic," stack-allocated) arrays; inadvertent use of null<br /> pointers (see also questions 5.2 and 5.20) or uninitialized,<br /> misaligned, or otherwise improperly allocated pointers (see<br /> questions 7.1 and 7.2); corruption of the malloc arena (see<br /> question 7.19); and mismatched function arguments, especially<br /> involving pointers; two possibilities are scanf() (see question<br /> 12.12) and fprintf() (make sure it receives its first FILE *<br /> argument).<br /><br /> See also questions 16.3 and 16.4.<br /><br /><br />Section 17. Style<br /><br />17.1: What's the best style for code layout in C?<br /><br />A: K&R, while providing the example most often copied, also supply<br /> a good excuse for disregarding it:<br /><br /> The position of braces is less important,<br /> although people hold passionate beliefs.<br /> We have chosen one of several popular styles.<br /> Pick a style that suits you, then use it<br /> consistently.<br /><br /> It is more important that the layout chosen be consistent (with<br /> itself, and with nearby or common code) than that it be<br /> "perfect." If your coding environment (i.e. local custom or<br /> company policy) does not suggest a style, and you don't feel<br /> like inventing your own, just copy K&R. (The tradeoffs between<br /> various indenting and brace placement options can be<br /> exhaustively and minutely examined, but don't warrant repetition<br /> here. See also the Indian Hill Style Guide.)<br /><br /> The elusive quality of "good style" involves much more than mere<br /> code layout details; don't spend time on formatting to the<br /> exclusion of more substantive code quality issues.<br /><br /> See also question 10.6.<br /><br /> References: K&R1 Sec. 1.2 p. 10; K&R2 Sec. 1.2 p. 10.<br /><br />17.3: Here's a neat trick for checking whether two strings are equal:<br /><br /> if(!strcmp(s1, s2))<br /><br /> Is this good style?<br /><br />A: It is not particularly good style, although it is a popular<br /> idiom. The test succeeds if the two strings are equal, but the<br /> use of ! ("not") suggests that it tests for inequality.<br /><br /> Another option is to use a macro:<br /><br /> #define Streq(s1, s2) (strcmp((s1), (s2)) == 0)<br /><br /> See also question 17.10.<br /><br />17.4: Why do some people write if(0 == x) instead of if(x == 0)?<br /><br />A: It's a trick to guard against the common error of writing<br /><br /> if(x = 0)<br /><br /> If you're in the habit of writing the constant before the ==,<br /> the compiler will complain if you accidentally type<br /><br /> if(0 = x)<br /><br /> Evidently it can be easier for some people to remember to<br /> reverse the test than to remember to type the doubled = sign.<br /> (Of course, the trick only helps when comparing to a constant.)<br /><br /> References: H&S Sec. 7.6.5 pp. 209-10.<br /><br />17.5: I came across some code that puts a (void) cast before each call<br /> to printf(). Why?<br /><br />A: printf() does return a value, though few programs bother to<br /> check the return values from each call. Since some compilers<br /> (and lint) will warn about discarded return values, an explicit<br /> cast to (void) is a way of saying "Yes, I've decided to ignore<br /> the return value from this call, but please continue to warn me<br /> about other (perhaps inadvertently) ignored return values."<br /> It's also common to use void casts on calls to strcpy() and<br /> strcat(), since the return value is never surprising.<br /><br /> References: K&R2 Sec. A6.7 p. 199; Rationale Sec. 3.3.4; H&S<br /> Sec. 6.2.9 p. 172, Sec. 7.13 pp. 229-30.<br /><br />17.8: What is "Hungarian Notation"? Is it worthwhile?<br /><br />A: Hungarian Notation is a naming convention, invented by Charles<br /> Simonyi, which encodes information about a variable's type (and<br /> perhaps its intended use) in its name. It is well-loved in some<br /> circles and roundly castigated in others. Its chief advantage<br /> is that it makes a variable's type or intended use obvious from<br /> its name; its chief disadvantage is that type information is not<br /> necessarily a worthwhile thing to carry around in the name of a<br /> variable.<br /><br /> References: Simonyi and Heller, "The Hungarian Revolution" .<br /><br />17.9: Where can I get the "Indian Hill Style Guide" and other coding<br /> standards?<br /><br />A: Various documents are available for anonymous ftp from:<br /><br /> Site: File or directory:<br /><br /> ftp.cs.washington.edu pub/cstyle.tar.Z<br /> (the updated Indian Hill guide)<br /><br /> ftp.cs.toronto.edu doc/programming<br /> (including Henry Spencer's<br /> "10 Commandments for C Programmers")<br /><br /> ftp.cs.umd.edu pub/style-guide<br /><br /> You may also be interested in the books _The Elements of<br /> Programming Style_, _Plum Hall Programming Guidelines_, and _C<br /> Style: Standards and Guidelines_; see the Bibliography.<br /><br /> See also question 18.9.<br /><br />17.10: Some people say that goto's are evil and that I should never use<br /> them. Isn't that a bit extreme?<br /><br />A: Programming style, like writing style, is somewhat of an art and<br /> cannot be codified by inflexible rules, although discussions<br /> about style often seem to center exclusively around such rules.<br /><br /> In the case of the goto statement, it has long been observed<br /> that unfettered use of goto's quickly leads to unmaintainable<br /> spaghetti code. However, a simple, unthinking ban on the goto<br /> statement does not necessarily lead immediately to beautiful<br /> programming: an unstructured programmer is just as capable of<br /> constructing a Byzantine tangle without using any goto's<br /> (perhaps substituting oddly-nested loops and Boolean control<br /> variables, instead).<br /><br /> Most observations or "rules" about programming style usually<br /> work better as guidelines than rules, and work much better if<br /> programmers understand what the guidelines are trying to<br /> accomplish. Blindly avoiding certain constructs or following<br /> rules without understanding them can lead to just as many<br /> problems as the rules were supposed to avert.<br /><br /> Furthermore, many opinions on programming style are just that:<br /> opinions. It's usually futile to get dragged into "style wars,"<br /> because on certain issues (such as those referred to in<br /> questions 9.2, 5.3, 5.9, and 10.7), opponents can never seem to<br /> agree, or agree to disagree, or stop arguing.<br /><br /><br />Section 18. Tools and Resources<br /><br />18.1: I need: A: Look for programs (see also<br /> question 18.16) named:<br /><br /> a C cross-reference cflow, cxref, calls, cscope,<br /> generator xscope, or ixfw<br /><br /> a C beautifier/pretty- cb, indent, GNU indent, or<br /> printer vgrind<br /><br /> a revision control or CVS, RCS, or SCCS<br /> configuration management<br /> tool<br /><br /> a C source obfuscator obfus, shroud, or opqcp<br /> (shrouder)<br /><br /> a "make" dependency makedepend, or try cc -M or<br /> generator cpp -M<br /><br /> tools to compute code ccount, Metre, lcount, or csize,<br /> metrics or see URL http://www.qucis.queensu.ca/<br /> Software-Engineering/Cmetrics.html ;<br /> there is also a package sold<br /> by McCabe and Associates<br /><br /> a C lines-of-source this can be done very<br /> counter crudely with the standard<br /> Unix utility wc, and<br /> somewhat better with<br /> grep -c ";"<br /><br /> a C declaration aid check volume 14 of<br /> (cdecl) comp.sources.unix (see<br /> question 18.16) and K&R2<br /><br /> a prototype generator see question 11.31<br /><br /> a tool to track down<br /> malloc problems see question 18.2<br /><br /> a "selective" C<br /> preprocessor see question 10.18<br /><br /> language translation see questions 11.31 and<br /> tools 20.26<br /><br /> C verifiers (lint) see question 18.7<br /><br /> a C compiler! see question 18.3<br /><br /> (This list of tools is by no means complete; if you know of<br /> tools not mentioned, you're welcome to contact this list's<br /> maintainer.)<br /><br /> Other lists of tools, and discussion about them, can be found in<br /> the Usenet newsgroups comp.compilers and comp.software-eng.<br /><br /> See also questions 18.3 and 18.16.<br /><br />18.2: How can I track down these pesky malloc problems?<br /><br />A: A number of debugging packages exist to help track down malloc<br /> problems; one popular one is Conor P. Cahill's "dbmalloc",<br /> posted to comp.sources.misc in 1992, volume 32. Others are<br /> "leak", available in volume 27 of the comp.sources.unix<br /> archives; JMalloc.c and JMalloc.h in the "Snippets" collection;<br /> and MEMDEBUG from ftp.crpht.lu in pub/sources/memdebug . See<br /> also question 18.16.<br /><br /> A number of commercial debugging tools exist, and can be<br /> invaluable in tracking down malloc-related and other stubborn<br /> problems:<br /><br /> Bounds-Checker for DOS, from Nu-Mega Technologies,<br /> P.O. Box 7780, Nashua, NH 03060-7780, USA, 603-889-2386.<br /><br /> CodeCenter (formerly Saber-C) from Centerline Software,<br /> 10 Fawcett Street, Cambridge, MA 02138, USA, 617-498-3000.<br /><br /> Insight, from ParaSoft Corporation, 2500 E. Foothill<br /> Blvd., Pasadena, CA 91107, USA, 818-792-9941,<br /> insight@parasoft.com .<br /><br /> Purify, from Pure Software, 1309 S. Mary Ave., Sunnyvale,<br /> CA 94087, USA, 800-224-7873, http://www.pure.com ,<br /> info-home@pure.com .<br /> (I believe Pure was recently acquired by Rational.)<br /><br /> Final Exam Memory Advisor, from PLATINUM Technology<br /> (formerly Sentinel from AIB Software), 1815 South Meyers<br /> Rd., Oakbrook Terrace, IL 60181, USA, 630-620-5000,<br /> 800-442-6861, info@platinum.com, www.platinum.com .<br /><br /> ZeroFault, from The Kernel Group, 1250 Capital of Texas<br /> Highway South, Building Three, Suite 601, Austin,<br /> TX 78746, 512-433-3333, http://www.tkg.com, zf@tkg.com .<br /><br />18.3: What's a free or cheap C compiler I can use?<br /><br />A: A popular and high-quality free C compiler is the FSF's GNU C<br /> compiler, or gcc. It is available by anonymous ftp from<br /> prep.ai.mit.edu in directory pub/gnu, or at several other FSF<br /> archive sites. An MS-DOS port, djgpp, is also available;<br /> see the djgpp home page at http://www.delorie.com/djgpp/ .<br /><br /> There is a shareware compiler called PCC, available as<br /> PCC12C.ZIP .<br /><br /> A very inexpensive MS-DOS compiler is Power C from Mix Software,<br /> 1132 Commerce Drive, Richardson, TX 75801, USA, 214-783-6001.<br /><br /> Another recently-developed compiler is lcc, available for<br /> anonymous ftp from ftp.cs.princeton.edu in pub/lcc/.<br /><br /> A shareware MS-DOS C compiler is available from<br /> ftp.hitech.com.au/hitech/pacific. Registration is optional for<br /> non-commercial use.<br /><br /> There are currently no viable shareware compilers for the<br /> Macintosh.<br /><br /> Archives associated with comp.compilers contain a great deal of<br /> information about available compilers, interpreters, grammars,<br /> etc. (for many languages). The comp.compilers archives<br /> (including an FAQ list), maintained by the moderator, John R.<br /> Levine, are at iecc.com . A list of available compilers and<br /> related resources, maintained by Mark Hopkins, Steven Robenalt,<br /> and David Muir Sharnoff, is at ftp.idiom.com in pub/compilers-<br /> list/. (See also the comp.compilers directory in the<br /> news.answers archives at rtfm.mit.edu and ftp.uu.net; see<br /> question 20.40.)<br /><br /> See also question 18.16.<br /><br />18.4: I just typed in this program, and it's acting strangely. Can<br /> you see anything wrong with it?<br /><br />A: See if you can run lint first (perhaps with the -a, -c, -h, -p<br /> or other options). Many C compilers are really only half-<br /> compilers, electing not to diagnose numerous source code<br /> difficulties which would not actively preclude code generation.<br /><br /> See also questions 16.5, 16.8, and 18.7.<br /><br /> References: Ian Darwin, _Checking C Programs with lint_ .<br /><br />18.5: How can I shut off the "warning: possible pointer alignment<br /> problem" message which lint gives me for each call to malloc()?<br /><br />A: The problem is that traditional versions of lint do not know,<br /> and cannot be told, that malloc() "returns a pointer to space<br /> suitably aligned for storage of any type of object." It is<br /> possible to provide a pseudoimplementation of malloc(), using a<br /> #define inside of #ifdef lint, which effectively shuts this<br /> warning off, but a simpleminded definition will also suppress<br /> meaningful messages about truly incorrect invocations. It may<br /> be easier simply to ignore the message, perhaps in an automated<br /> way with grep -v. (But don't get in the habit of ignoring too<br /> many lint messages, otherwise one day you'll overlook a<br /> significant one.)<br /><br />18.7: Where can I get an ANSI-compatible lint?<br /><br />A: Products called PC-Lint and FlexeLint (in "shrouded source<br /> form," for compilation on 'most any system) are available from<br /><br /> Gimpel Software<br /> 3207 Hogarth Lane<br /> Collegeville, PA 19426 USA<br /> (+1) 610 584 4261<br /> gimpel@netaxs.com<br /><br /> The Unix System V release 4 lint is ANSI-compatible, and is<br /> available separately (bundled with other C tools) from UNIX<br /> Support Labs or from System V resellers.<br /><br /> Another ANSI-compatible lint (which can also perform higher-<br /> level formal verification) is LCLint, available via anonymous<br /> ftp from larch.lcs.mit.edu in pub/Larch/lclint/.<br /><br /> In the absence of lint, many modern compilers do attempt to<br /> diagnose almost as many problems as lint does. (Many netters<br /> recommend gcc -Wall -pedantic .)<br /><br />18.8: Don't ANSI function prototypes render lint obsolete?<br /><br />A: No. First of all, prototypes work only if they are present and<br /> correct; an inadvertently incorrect prototype is worse than<br /> useless. Secondly, lint checks consistency across multiple<br /> source files, and checks data declarations as well as functions.<br /> Finally, an independent program like lint will probably always<br /> be more scrupulous at enforcing compatible, portable coding<br /> practices than will any particular, implementation-specific,<br /> feature- and extension-laden compiler.<br /><br /> If you do want to use function prototypes instead of lint for<br /> cross-file consistency checking, make sure that you set the<br /> prototypes up correctly in header files. See questions 1.7 and<br /> 10.6.<br /><br />18.9: Are there any C tutorials or other resources on the net?<br /><br />A: There are several of them:<br /><br /> Tom Torfs has a nice tutorial at<br /> http://members.xoom.com/tomtorfs/cintro.html .<br /><br /> "Notes for C programmers," by Christopher Sawtell, are<br /> available from svr-ftp.eng.cam.ac.uk in misc/sawtell_C.shar and<br /> garbo.uwasa.fi in /pc/c-lang/c-lesson.zip .<br /><br /> Tim Love's "C for Programmers" is available by ftp from svr-<br /> ftp.eng.cam.ac.uk in the misc directory. An html version is at<br /> http://www-h.eng.cam.ac.uk/help/tpl/languages/C/teaching_C/<br /> teaching_C.html .<br /><br /> The Coronado Enterprises C tutorials are available on Simtel<br /> mirrors in pub/msdos/c or on the web at http://www.swcp.com/~dodrill .<br /><br /> Rick Rowe has a tutorial which is available from ftp.netcom.com<br /> as pub/rowe/tutorde.zip or ftp.wustl.edu as<br /> pub/MSDOS_UPLOADS/programming/c_language/ctutorde.zip .<br /><br /> There is evidently a web-based course at<br /> http://www.strath.ac.uk/CC/Courses/CCourse/CCourse.html .<br /><br /> Martin Brown has C course material on the web at<br /> http://www-isis.ecs.soton.ac.uk/computing/c/Welcome.html .<br /><br /> On some Unix machines you can try typing "learn c" at the shell<br /> prompt (but the lessons may be quite dated).<br /><br /> Finally, the author of this FAQ list teaches a C class<br /> and has placed its notes on the web; they are at<br /> http://www.eskimo.com/~scs/cclass/cclass.html .<br /><br /> [Disclaimer: I have not reviewed many of these tutorials, and<br /> I gather that they tend to contain errors. With the exception<br /> of the one with my name on it, I can't vouch for any of them.<br /> Also, this sort of information rapidly becomes out-of-date;<br /> these addresses may not work by the time you read this and<br /> try them.]<br /><br /> Several of these tutorials, plus a great deal of other<br /> information about C, are accessible via the web at<br /> http://www.lysator.liu.se/c/index.html .<br /><br /> Vinit Carpenter maintains a list of resources for learning C and<br /> C++; it is posted to comp.lang.c and comp.lang.c++, and archived<br /> where this FAQ list is (see question 20.40), or on the web at<br /> http://www.cyberdiem.com/vin/learn.html .<br /><br /> See also questions 18.10 and 18.15c.<br /><br />18.10: What's a good book for learning C?<br /><br />A: There are far too many books on C to list here; it's impossible<br /> to rate them all. Many people believe that the best one was<br /> also the first: _The C Programming Language_, by Kernighan and<br /> Ritchie ("K&R," now in its second edition). Opinions vary on<br /> K&R's suitability as an initial programming text: many of us did<br /> learn C from it, and learned it well; some, however, feel that<br /> it is a bit too clinical as a first tutorial for those without<br /> much programming background. Several sets of annotations and<br /> errata are available on the net, see e.g.<br /> http://www.csd.uwo.ca/~jamie/.Refs/.Footnotes/C-annotes.html,<br /> http://www.eskimo.com/~scs/cclass/cclass.html, and<br /> http://www.lysator.liu.se/c/c-errata.html#main .<br /><br /> Many comp.lang.c regulars recommend _C: A Modern Approach_,<br /> by K.N. King.<br /><br /> An excellent reference manual is _C: A Reference Manual_, by<br /> Samuel P. Harbison and Guy L. Steele, now in its fourth edition.<br /><br /> Though not suitable for learning C from scratch, this FAQ list<br /> has been published in book form; see the Bibliography.<br /><br /> Mitch Wright maintains an annotated bibliography of C and Unix<br /> books; it is available for anonymous ftp from ftp.rahul.net in<br /> directory pub/mitch/YABL/.<br /><br /> Scott McMahon has a nice set of reviews at<br /> http://www.skwc.com/essent/cyberreviews.html .<br /><br /> The Association of C and C++ Users (ACCU) maintains a<br /> comprehensive set of bibliographic reviews of C/C++ titles, at<br /> http://bach.cis.temple.edu/accu/bookcase or<br /> http://www.accu.org/accu .<br /><br /> This FAQ list's editor has a large collection of assorted<br /> old recommendations which various people have posted; it<br /> is available upon request. See also question 18.9 above.<br /><br />18.13: Where can I find the sources of the standard C libraries?<br /><br />A: One source (though not public domain) is _The Standard C<br /> Library_, by P.J. Plauger (see the Bibliography).<br /> Implementations of all or part of the C library have been<br /> written and are readily available as part of the NetBSD and GNU<br /> (also Linux) projects. See also questions 18.15c and 18.16.<br /><br />18.13b: Is there an on-line C reference manual?<br /><br />A: Two possibilities are<br /> http://www.cs.man.ac.uk/standard_c/_index.html and<br /> http://www.dinkumware.com/htm_cl/index.html .<br /><br />18.13c: Where can I get a copy of the ANSI/ISO C Standard?<br /><br />A: See question 11.2.<br /><br />18.14: I need code to parse and evaluate expressions.<br /><br />A: Two available packages are "defunc," posted to comp.sources.misc<br /> in December, 1993 (V41 i32,33), to alt.sources in January, 1994,<br /> and available from sunsite.unc.edu in<br /> pub/packages/development/libraries/defunc-1.3.tar.Z, and<br /> "parse," at lamont.ldgo.columbia.edu. Other options include the<br /> S-Lang interpreter, available via anonymous ftp from<br /> amy.tch.harvard.edu in pub/slang, and the shareware Cmm ("C-<br /> minus-minus" or "C minus the hard stuff"). See also questions<br /> 18.16 and 20.6.<br /><br /> There is also some parsing/evaluation code in _Software<br /> Solutions in C_ (chapter 12, pp. 235-55).<br /><br />18.15: Where can I get a BNF or YACC grammar for C?<br /><br />A: The definitive grammar is of course the one in the ANSI<br /> standard; see question 11.2. Another grammar (along with<br /> one for C++) by Jim Roskind is in pub/c++grammar1.1.tar.Z<br /> at ics.uci.edu (or perhaps ftp.ics.uci.edu, or perhaps<br /> OLD/pub/c++grammar1.1.tar.Z), or at ftp.eskimo.com in<br /> u/s/scs/roskind_grammar.Z . A fleshed-out, working instance<br /> of the ANSI grammar (due to Jeff Lee) is on ftp.uu.net<br /> (see question 18.16) in usenet/net.sources/ansi.c.grammar.Z<br /> (including a companion lexer). The FSF's GNU C compiler<br /> contains a grammar, as does the appendix to K&R2.<br /><br /> The comp.compilers archives contain more information about<br /> grammars; see question 18.3.<br /><br /> References: K&R1 Sec. A18 pp. 214-219; K&R2 Sec. A13 pp. 234-<br /> 239; ISO Sec. B.2; H&S pp. 423-435 Appendix B.<br /><br />18.15b: Does anyone have a C compiler test suite I can use?<br /><br />A: Plum Hall (formerly in Cardiff, NJ; now in Hawaii) sells one;<br /> other packages are Ronald Guilmette's RoadTest(tm) Compiler Test<br /> Suites (ftp to netcom.com, pub/rfg/roadtest/announce.txt for<br /> information) and Nullstone's Automated Compiler Performance<br /> Analysis Tool (see http://www.nullstone.com). The FSF's GNU C<br /> (gcc) distribution includes a c-torture-test which checks a<br /> number of common problems with compilers. Kahan's paranoia<br /> test, found in netlib/paranoia on netlib.att.com, strenuously<br /> tests a C implementation's floating point capabilities.<br /><br />18.15c: Where are some collections of useful code fragments and<br /> examples?<br /><br />A: Bob Stout's popular "SNIPPETS" collection is available from<br /> ftp.brokersys.com in directory pub/snippets or on the web at<br /> http://www.brokersys.com/snippets/ .<br /><br /> Lars Wirzenius's "publib" library is available from ftp.funet.fi<br /> in directory pub/languages/C/Publib/.<br /><br /> See also questions 14.12, 18.9, 18.13, and 18.16.<br /><br />18.15d: I need code for performing multiple precision arithmetic.<br /><br />A: Some popular packages are the "quad" functions within the BSD<br /> Unix libc sources (ftp.uu.net, /systems/unix/bsd-sources/..../<br /> /src/lib/libc/quad/*), the GNU MP library, the MIRACL package<br /> (see http://indigo.ie/~mscott/ ), and the old Unix libmp.a.<br /> See also questions 14.12 and 18.16.<br /><br /> References: Schumacher, ed., _Software Solutions in C_ Sec. 17<br /> pp. 343-454.<br /><br />18.16: Where and how can I get copies of all these freely distributable<br /> programs?<br /><br />A: As the number of available programs, the number of publicly<br /> accessible archive sites, and the number of people trying to<br /> access them all grow, this question becomes both easier and more<br /> difficult to answer.<br /><br /> There are a number of large, public-spirited archive sites out<br /> there, such as ftp.uu.net, archive.umich.edu, oak.oakland.edu,<br /> sumex-aim.stanford.edu, and wuarchive.wustl.edu, which have huge<br /> amounts of software and other information all freely available.<br /> For the FSF's GNU project, the central distribution site is<br /> prep.ai.mit.edu . These well-known sites tend to be extremely<br /> busy and hard to reach, but there are also numerous "mirror"<br /> sites which try to spread the load around.<br /><br /> On the connected Internet, the traditional way to retrieve files<br /> from an archive site is with anonymous ftp. For those without<br /> ftp access, there are also several ftp-by-mail servers in<br /> operation. More and more, the world-wide web (WWW) is being<br /> used to announce, index, and even transfer large data files.<br /> There are probably yet newer access methods, too.<br /><br /> Those are some of the easy parts of the question to answer. The<br /> hard part is in the details -- this article cannot begin to<br /> track or list all of the available archive sites or all of the<br /> various ways of accessing them. If you have access to the net<br /> at all, you probably have access to more up-to-date information<br /> about active sites and useful access methods than this FAQ list<br /> does.<br /><br /> The other easy-and-hard aspect of the question, of course, is<br /> simply *finding* which site has what you're looking for. There<br /> is a tremendous amount of work going on in this area, and there<br /> are probably new indexing services springing up every day. One<br /> of the first was "archie", and of course there are a number of<br /> high-profile commercial net indexing and searching services such<br /> as Alta Vista, Excite, and Yahoo.<br /><br /> If you have access to Usenet, see the regular postings in the<br /> comp.sources.unix and comp.sources.misc newsgroups, which<br /> describe the archiving policies for those groups and how to<br /> access their archives, two of which are<br /> ftp://gatekeeper.dec.com/pub/usenet/comp.sources.unix/ and<br /> ftp://ftp.uu.net/usenet/comp.sources.unix/. The comp.archives<br /> newsgroup contains numerous announcements of anonymous ftp<br /> availability of various items. Finally, the newsgroup<br /> comp.sources.wanted is generally a more appropriate place to<br /> post queries for source availability, but check *its* FAQ list,<br /> "How to find sources," before posting there.<br /><br /> See also questions 14.12, 18.13, and 18.15c.<br /><br /><br />Section 19. System Dependencies<br /><br />19.1: How can I read a single character from the keyboard without<br /> waiting for the RETURN key? How can I stop characters from<br /> being echoed on the screen as they're typed?<br /><br />A: Alas, there is no standard or portable way to do these things in<br /> C. Concepts such as screens and keyboards are not even<br /> mentioned in the Standard, which deals only with simple I/O<br /> "streams" of characters.<br /><br /> At some level, interactive keyboard input is usually collected<br /> and presented to the requesting program a line at a time. This<br /> gives the operating system a chance to support input line<br /> editing (backspace/delete/rubout, etc.) in a consistent way,<br /> without requiring that it be built into every program. Only<br /> when the user is satisfied and presses the RETURN key (or<br /> equivalent) is the line made available to the calling program.<br /> Even if the calling program appears to be reading input a<br /> character at a time (with getchar() or the like), the first call<br /> blocks until the user has typed an entire line, at which point<br /> potentially many characters become available and many character<br /> requests (e.g. getchar() calls) are satisfied in quick<br /> succession.<br /><br /> When a program wants to read each character immediately as it<br /> arrives, its course of action will depend on where in the input<br /> stream the line collection is happening and how it can be<br /> disabled. Under some systems (e.g. MS-DOS, VMS in some modes),<br /> a program can use a different or modified set of OS-level input<br /> calls to bypass line-at-a-time input processing. Under other<br /> systems (e.g. Unix, VMS in other modes), the part of the<br /> operating system responsible for serial input (often called the<br /> "terminal driver") must be placed in a mode which turns off line-<br /> at-a-time processing, after which all calls to the usual input<br /> routines (e.g. read(), getchar(), etc.) will return characters<br /> immediately. Finally, a few systems (particularly older, batch-<br /> oriented mainframes) perform input processing in peripheral<br /> processors which cannot be told to do anything other than line-<br /> at-a-time input.<br /><br /> Therefore, when you need to do character-at-a-time input (or<br /> disable keyboard echo, which is an analogous problem), you will<br /> have to use a technique specific to the system you're using,<br /> assuming it provides one. Since comp.lang.c is oriented towards<br /> those topics that the C language has defined support for, you<br /> will usually get better answers to other questions by referring<br /> to a system-specific newsgroup such as comp.unix.questions or<br /> comp.os.msdos.programmer, and to the FAQ lists for these groups.<br /> Note that the answers are often not unique even across different<br /> variants of a system; bear in mind when answering system-<br /> specific questions that the answer that applies to your system<br /> may not apply to everyone else's.<br /><br /> However, since these questions are frequently asked here, here<br /> are brief answers for some common situations.<br /><br /> Some versions of curses have functions called cbreak(),<br /> noecho(), and getch() which do what you want. If you're<br /> specifically trying to read a short password without echo, you<br /> might try getpass(). Under Unix, you can use ioctl() to play<br /> with the terminal driver modes (CBREAK or RAW under "classic"<br /> versions; ICANON, c_cc[VMIN] and c_cc[VTIME] under System V or<br /> POSIX systems; ECHO under all versions), or in a pinch, system()<br /> and the stty command. (For more information, see <sgtty.h> and<br /> tty(4) under classic versions, <termio.h> and termio(4) under<br /> System V, or <termios.h> and termios(4) under POSIX.) Under<br /> MS-DOS, use getch() or getche(), or the corresponding BIOS<br /> interrupts. Under VMS, try the Screen Management (SMG$)<br /> routines, or curses, or issue low-level $QIO's with the<br /> IO$_READVBLK function code (and perhaps IO$M_NOECHO, and others)<br /> to ask for one character at a time. (It's also possible to set<br /> character-at-a-time or "pass through" modes in the VMS terminal<br /> driver.) Under other operating systems, you're on your own.<br /><br /> (As an aside, note that simply using setbuf() or setvbuf() to<br /> set stdin to unbuffered will *not* generally serve to allow<br /> character-at-a-time input.)<br /><br /> If you're trying to write a portable program, a good approach is<br /> to define your own suite of three functions to (1) set the<br /> terminal driver or input system into character-at-a-time mode<br /> (if necessary), (2) get characters, and (3) return the terminal<br /> driver to its initial state when the program is finished.<br /> (Ideally, such a set of functions might be part of the C<br /> Standard, some day.) The extended versions of this FAQ list<br /> (see question 20.40) contain examples of such functions for<br /> several popular systems.<br /><br /> See also question 19.2.<br /><br /> References: PCS Sec. 10 pp. 128-9, Sec. 10.1 pp. 130-1; POSIX<br /> Sec. 7.<br /><br />19.2: How can I find out if there are characters available for reading<br /> (and if so, how many)? Alternatively, how can I do a read that<br /> will not block if there are no characters available?<br /><br />A: These, too, are entirely operating-system-specific. Some<br /> versions of curses have a nodelay() function. Depending on your<br /> system, you may also be able to use "nonblocking I/O", or a<br /> system call named "select" or "poll", or the FIONREAD ioctl, or<br /> c_cc[VTIME], or kbhit(), or rdchk(), or the O_NDELAY option to<br /> open() or fcntl(). See also question 19.1.<br /><br />19.3: How can I display a percentage-done indication that updates<br /> itself in place, or show one of those "twirling baton" progress<br /> indicators?<br /><br />A: These simple things, at least, you can do fairly portably.<br /> Printing the character '\r' will usually give you a carriage<br /> return without a line feed, so that you can overwrite the<br /> current line. The character '\b' is a backspace, and will<br /> usually move the cursor one position to the left.<br /><br /> References: ISO Sec. 5.2.2.<br /><br />19.4: How can I clear the screen?<br /> How can I print text in color?<br /> How can I move the cursor to a specific x, y position?<br /><br />A: Such things depend on the terminal type (or display) you're<br /> using. You will have to use a library such as termcap,<br /> terminfo, or curses, or some system-specific routines, to<br /> perform these operations. On MS-DOS systems, two functions<br /> to look for are clrscr() and gotoxy().<br /><br /> For clearing the screen, a halfway portable solution is to print<br /> a form-feed character ('\f'), which will cause some displays to<br /> clear. Even more portable (albeit even more gunky) might be to<br /> print enough newlines to scroll everything away. As a last<br /> resort, you could use system() (see question 19.27) to invoke<br /> an operating system clear-screen command.<br /><br /> References: PCS Sec. 5.1.4 pp. 54-60, Sec. 5.1.5 pp. 60-62.<br /><br />19.5: How do I read the arrow keys? What about function keys?<br /><br />A: Terminfo, some versions of termcap, and some versions of curses<br /> have support for these non-ASCII keys. Typically, a special key<br /> sends a multicharacter sequence (usually beginning with ESC,<br /> '\033'); parsing these can be tricky. (curses will do the<br /> parsing for you, if you call keypad() first.)<br /><br /> Under MS-DOS, if you receive a character with value 0 (*not*<br /> '0'!) while reading the keyboard, it's a flag indicating that<br /> the next character read will be a code indicating a special key.<br /> See any DOS programming guide for lists of keyboard scan codes.<br /> (Very briefly: the up, left, right, and down arrow keys are 72,<br /> 75, 77, and 80, and the function keys are 59 through 68.)<br /><br /> References: PCS Sec. 5.1.4 pp. 56-7.<br /><br />19.6: How do I read the mouse?<br /><br />A: Consult your system documentation, or ask on an appropriate<br /> system-specific newsgroup (but check its FAQ list first). Mouse<br /> handling is completely different under the X window system, MS-<br /> DOS, the Macintosh, and probably every other system.<br /><br /> References: PCS Sec. 5.5 pp. 78-80.<br /><br />19.7: How can I do serial ("comm") port I/O?<br /><br />A: It's system-dependent. Under Unix, you typically open, read,<br /> and write a device file in /dev, and use the facilities of the<br /> terminal driver to adjust its characteristics. (See also<br /> questions 19.1 and 19.2.) Under MS-DOS, you can use the<br /> predefined stream stdaux, or a special file like COM1, or some<br /> primitive BIOS interrupts, or (if you require decent<br /> performance) any number of interrupt-driven serial I/O packages.<br /> Several netters recommend the book _C Programmer's Guide to<br /> Serial Communications_, by Joe Campbell.<br /><br />19.8: How can I direct output to the printer?<br /><br />A: Under Unix, either use popen() (see question 19.30) to write to<br /> the lp or lpr program, or perhaps open a special file like<br /> /dev/lp. Under MS-DOS, write to the (nonstandard) predefined<br /> stdio stream stdprn, or open the special files PRN or LPT1.<br /><br /> References: PCS Sec. 5.3 pp. 72-74.<br /><br />19.9: How do I send escape sequences to control a terminal or other<br /> device?<br /><br />A: If you can figure out how to send characters to the device at<br /> all (see question 19.8 above), it's easy enough to send escape<br /> sequences. In ASCII, the ESC code is 033 (27 decimal), so code<br /> like<br /><br /> fprintf(ofd, "\033[J");<br /><br /> sends the sequence ESC [ J .<br /><br />19.10: How can I do graphics?<br /><br />A: Once upon a time, Unix had a fairly nice little set of device-<br /> independent plot functions described in plot(3) and plot(5).<br /> The GNU libplot package maintains the same spirit and supports<br /> many modern plot devices;<br /> see http://www.gnu.org/software/plotutils/plotutils.html .<br /><br /> If you're programming for MS-DOS, you'll probably want to use<br /> libraries conforming to the VESA or BGI standards.<br /><br /> If you're trying to talk to a particular plotter, making it draw<br /> is usually a matter of sending it the appropriate escape<br /> sequences; see also question 19.9. The vendor may supply a C-<br /> callable library, or you may be able to find one on the net.<br /><br /> If you're programming for a particular window system (Macintosh,<br /> X windows, Microsoft Windows), you will use its facilities; see<br /> the relevant documentation or newsgroup or FAQ list.<br /><br /> References: PCS Sec. 5.4 pp. 75-77.<br /><br />19.11: How can I check whether a file exists? I want to warn the user<br /> if a requested input file is missing.<br /><br />A: It's surprisingly difficult to make this determination reliably<br /> and portably. Any test you make can be invalidated if the file<br /> is created or deleted (i.e. by some other process) between the<br /> time you make the test and the time you try to open the file.<br /><br /> Three possible test functions are stat(), access(), and fopen().<br /> (To make an approximate test using fopen(), just open for<br /> reading and close immediately, although failure does not<br /> necessarily indicate nonexistence.) Of these, only fopen() is<br /> widely portable, and access(), where it exists, must be used<br /> carefully if the program uses the Unix set-UID feature.<br /><br /> Rather than trying to predict in advance whether an operation<br /> such as opening a file will succeed, it's often better to try<br /> it, check the return value, and complain if it fails.<br /> (Obviously, this approach won't work if you're trying to avoid<br /> overwriting an existing file, unless you've got something like<br /> the O_EXCL file opening option available, which does just what<br /> you want in this case.)<br /><br /> References: PCS Sec. 12 pp. 189,213; POSIX Sec. 5.3.1,<br /> Sec. 5.6.2, Sec. 5.6.3.<br /><br />19.12: How can I find out the size of a file, prior to reading it in?<br /><br />A: If the "size of a file" is the number of characters you'll be<br /> able to read from it in C, it is difficult or impossible to<br /> determine this number exactly.<br /><br /> Under Unix, the stat() call will give you an exact answer.<br /> Several other systems supply a Unix-like stat() which will give<br /> an approximate answer. You can fseek() to the end and then use<br /> ftell(), or maybe try fstat(), but these tend to have the same<br /> sorts of problems: fstat() is not portable, and generally tells<br /> you the same thing stat() tells you; ftell() is not guaranteed<br /> to return a byte count except for binary files. Some systems<br /> provide functions called filesize() or filelength(), but these<br /> are obviously not portable, either.<br /><br /> Are you sure you have to determine the file's size in advance?<br /> Since the most accurate way of determining the size of a file as<br /> a C program will see it is to open the file and read it, perhaps<br /> you can rearrange the code to learn the size as it reads.<br /><br /> References: ISO Sec. 7.9.9.4; H&S Sec. 15.5.1; PCS Sec. 12 p.<br /> 213; POSIX Sec. 5.6.2.<br /><br />19.12b: How can I find the modification date and time of a file?<br /><br />A: The Unix and POSIX function is stat(), which several other<br /> systems supply as well. (See also question 19.12.)<br /><br />19.13: How can a file be shortened in-place without completely clearing<br /> or rewriting it?<br /><br />A: BSD systems provide ftruncate(), several others supply chsize(),<br /> and a few may provide a (possibly undocumented) fcntl option<br /> F_FREESP. Under MS-DOS, you can sometimes use write(fd, "", 0).<br /> However, there is no portable solution, nor a way to delete<br /> blocks at the beginning. See also question 19.14.<br /><br />19.14: How can I insert or delete a line (or record) in the middle of a<br /> file?<br /><br />A: Short of rewriting the file, you probably can't. The usual<br /> solution is simply to rewrite the file. (Instead of deleting<br /> records, you might consider simply marking them as deleted, to<br /> avoid rewriting.) Another possibility, of course, is to use a<br /> database instead of a flat file. See also questions 12.30 and<br /> 19.13.<br /><br />19.15: How can I recover the file name given an open stream or file<br /> descriptor?<br /><br />A: This problem is, in general, insoluble. Under Unix, for<br /> instance, a scan of the entire disk (perhaps involving special<br /> permissions) would theoretically be required, and would fail if<br /> the descriptor were connected to a pipe or referred to a deleted<br /> file (and could give a misleading answer for a file with<br /> multiple links). It is best to remember the names of files<br /> yourself as you open them (perhaps with a wrapper function<br /> around fopen()).<br /><br />19.16: How can I delete a file?<br /><br />A: The Standard C Library function is remove(). (This is therefore<br /> one of the few questions in this section for which the answer is<br /> *not* "It's system-dependent.") On older, pre-ANSI Unix<br /> systems, remove() may not exist, in which case you can try<br /> unlink().<br /><br /> References: K&R2 Sec. B1.1 p. 242; ISO Sec. 7.9.4.1; H&S<br /> Sec. 15.15 p. 382; PCS Sec. 12 pp. 208,220-221; POSIX<br /> Sec. 5.5.1, Sec. 8.2.4.<br /><br />19.16b: How do I copy files?<br /><br />A: Either use system() to invoke your operating system's copy<br /> utility (see question 19.27), or open the source and destination<br /> files (using fopen() or some lower-level file-opening system call),<br /> read characters or blocks of characters from the source file,<br /> and write them to the destination file.<br /><br /> References: K&R Sec. 1, Sec. 7.<br /><br />19.17: Why can't I open a file by its explicit path? The call<br /><br /> fopen("c:\newdir\file.dat", "r")<br /><br /> is failing.<br /><br />A: The file you actually requested -- with the characters \n and \f<br /> in its name -- probably doesn't exist, and isn't what you<br /> thought you were trying to open.<br /><br /> In character constants and string literals, the backslash \ is<br /> an escape character, giving special meaning to the character<br /> following it. In order for literal backslashes in a pathname to<br /> be passed through to fopen() (or any other function) correctly,<br /> they have to be doubled, so that the first backslash in each<br /> pair quotes the second one:<br /><br /> fopen("c:\\newdir\\file.dat", "r")<br /><br /> Alternatively, under MS-DOS, it turns out that forward slashes<br /> are also accepted as directory separators, so you could use<br /><br /> fopen("c:/newdir/file.dat", "r")<br /><br /> (Note, by the way, that header file names mentioned in<br /> preprocessor #include directives are *not* string literals, so<br /> you may not have to worry about backslashes there.)<br /><br />19.18: I'm getting an error, "Too many open files". How can I increase<br /> the allowable number of simultaneously open files?<br /><br />A: There are typically at least two resource limitations on the<br /> number of simultaneously open files: the number of low-level<br /> "file descriptors" or "file handles" available in the operating<br /> system, and the number of FILE structures available in the stdio<br /> library. Both must be sufficient. Under MS-DOS systems, you<br /> can control the number of operating system file handles with a<br /> line in CONFIG.SYS. Some compilers come with instructions (and<br /> perhaps a source file or two) for increasing the number of stdio<br /> FILE structures.<br /><br />19.20: How can I read a directory in a C program?<br /><br />A: See if you can use the opendir() and readdir() functions, which<br /> are part of the POSIX standard and are available on most Unix<br /> variants. Implementations also exist for MS-DOS, VMS, and other<br /> systems. (MS-DOS also has FINDFIRST and FINDNEXT routines which<br /> do essentially the same thing.) readdir() only returns file<br /> names; if you need more information about the file, try calling<br /> stat(). To match filenames to some wildcard pattern, see<br /> question 13.7.<br /><br /> References: K&R2 Sec. 8.6 pp. 179-184; PCS Sec. 13 pp. 230-1;<br /> POSIX Sec. 5.1; Schumacher, ed., _Software Solutions in C_<br /> Sec. 8.<br /><br />19.22: How can I find out how much memory is available?<br /><br />A: Your operating system may provide a routine which returns this<br /> information, but it's quite system-dependent.<br /><br />19.23: How can I allocate arrays or structures bigger than 64K?<br /><br />A: A reasonable computer ought to give you transparent access to<br /> all available memory. If you're not so lucky, you'll either<br /> have to rethink your program's use of memory, or use various<br /> system-specific techniques.<br /><br /> 64K is (still) a pretty big chunk of memory. No matter how much<br /> memory your computer has available, it's asking a lot to be able<br /> to allocate huge amounts of it contiguously. (The C Standard<br /> does not guarantee that single objects can be 32K or larger,<br /> or 64K for C9X.) Often it's a good idea to use data<br /> structures which don't require that all memory be contiguous.<br /> For dynamically-allocated multidimensional arrays, you can<br /> use pointers to pointers, as illustrated in question 6.16.<br /> Instead of a large array of structures, you can use a linked<br /> list, or an array of pointers to structures.<br /><br /> If you're using a PC-compatible (8086-based) system, and running<br /> up against a 64K or 640K limit, consider using "huge" memory<br /> model, or expanded or extended memory, or malloc variants such<br /> as halloc() or farmalloc(), or a 32-bit "flat" compiler (e.g.<br /> djgpp, see question 18.3), or some kind of a DOS extender, or<br /> another operating system.<br /><br /> References: ISO Sec. 5.2.4.1; C9X Sec. 5.2.4.1.<br /><br />19.24: What does the error message "DGROUP data allocation exceeds 64K"<br /> mean, and what can I do about it? I thought that using large<br /> model meant that I could use more than 64K of data!<br /><br />A: Even in large memory models, MS-DOS compilers apparently toss<br /> certain data (strings, some initialized global or static<br /> variables) into a default data segment, and it's this segment<br /> that is overflowing. Either use less global data, or, if you're<br /> already limiting yourself to reasonable amounts (and if the<br /> problem is due to something like the number of strings), you may<br /> be able to coax the compiler into not using the default data<br /> segment for so much. Some compilers place only "small" data<br /> objects in the default data segment, and give you a way (e.g.<br /> the /Gt option under Microsoft compilers) to configure the<br /> threshold for "small."<br /><br />19.25: How can I access memory (a memory-mapped device, or graphics<br /> memory) located at a certain address?<br /><br />A: Set a pointer, of the appropriate type, to the right number<br /> (using an explicit cast to assure the compiler that you really<br /> do intend this nonportable conversion):<br /><br /> unsigned int *magicloc = (unsigned int *)0x12345678;<br /><br /> Then, *magicloc refers to the location you want. (Under MS-DOS,<br /> you may find a macro like MK_FP() handy for working with<br /> segments and offsets.)<br /><br /> References: K&R1 Sec. A14.4 p. 210; K&R2 Sec. A6.6 p. 199; ISO<br /> Sec. 6.3.4; Rationale Sec. 3.3.4; H&S Sec. 6.2.7 pp. 171-2.<br /><br />19.27: How can I invoke another program (a standalone executable,<br /> or an operating system command) from within a C program?<br /><br />A: Use the library function system(), which does exactly that.<br /> Note that system's return value is at best the command's exit<br /> status (although even that is not guaranteed), and usually has<br /> nothing to do with the output of the command. Note also that<br /> system() accepts a single string representing the command to be<br /> invoked; if you need to build up a complex command line, you can<br /> use sprintf(). See also question 19.30.<br /><br /> References: K&R1 Sec. 7.9 p. 157; K&R2 Sec. 7.8.4 p. 167,<br /> Sec. B6 p. 253; ISO Sec. 7.10.4.5; H&S Sec. 19.2 p. 407; PCS<br /> Sec. 11 p. 179.<br /><br />19.30: How can I invoke another program or command and trap its output?<br /><br />A: Unix and some other systems provide a popen() function, which<br /> sets up a stdio stream on a pipe connected to the process<br /> running a command, so that the output can be read (or the input<br /> supplied). (Also, remember to call pclose().)<br /><br /> If you can't use popen(), you may be able to use system(), with<br /> the output going to a file which you then open and read.<br /><br /> If you're using Unix and popen() isn't sufficient, you can learn<br /> about pipe(), dup(), fork(), and exec().<br /><br /> (One thing that probably would *not* work, by the way, would be<br /> to use freopen().)<br /><br /> References: PCS Sec. 11 p. 169.<br /><br />19.31: How can my program discover the complete pathname to the<br /> executable from which it was invoked?<br /><br />A: argv[0] may contain all or part of the pathname, or it may<br /> contain nothing. You may be able to duplicate the command<br /> language interpreter's search path logic to locate the<br /> executable if the name in argv[0] is present but incomplete.<br /> However, there is no guaranteed solution.<br /><br /> References: K&R1 Sec. 5.11 p. 111; K&R2 Sec. 5.10 p. 115; ISO<br /> Sec. 5.1.2.2.1; H&S Sec. 20.1 p. 416.<br /><br />19.32: How can I automatically locate a program's configuration files<br /> in the same directory as the executable?<br /><br />A: It's hard; see also question 19.31 above. Even if you can<br /> figure out a workable way to do it, you might want to consider<br /> making the program's auxiliary (library) directory configurable,<br /> perhaps with an environment variable. (It's especially<br /> important to allow variable placement of a program's<br /> configuration files when the program will be used by several<br /> people, e.g. on a multiuser system.)<br /><br />19.33: How can a process change an environment variable in its caller?<br /><br />A: It may or may not be possible to do so at all. Different<br /> operating systems implement global name/value functionality<br /> similar to the Unix environment in different ways. Whether the<br /> "environment" can be usefully altered by a running program, and<br /> if so, how, is system-dependent.<br /><br /> Under Unix, a process can modify its own environment (some<br /> systems provide setenv() or putenv() functions for the purpose),<br /> and the modified environment is generally passed on to child<br /> processes, but it is *not* propagated back to the parent<br /> process. Under MS-DOS, it's possible to manipulate the master<br /> copy of the environment, but the required techniques are arcane.<br /> (See an MS-DOS FAQ list.)<br /><br />19.36: How can I read in an object file and jump to locations in it?<br /><br />A: You want a dynamic linker or loader. It may be possible to<br /> malloc some space and read in object files, but you have to know<br /> an awful lot about object file formats, relocation, etc. Under<br /> BSD Unix, you could use system() and ld -A to do the linking for<br /> you. Many versions of SunOS and System V have the -ldl library<br /> which allows object files to be dynamically loaded. Under VMS,<br /> use LIB$FIND_IMAGE_SYMBOL. GNU has a package called "dld". See<br /> also question 15.13.<br /><br />19.37: How can I implement a delay, or time a user's response, with sub-<br /> second resolution?<br /><br />A: Unfortunately, there is no portable way. V7 Unix, and derived<br /> systems, provided a fairly useful ftime() function with<br /> resolution up to a millisecond, but it has disappeared from<br /> System V and POSIX. Other routines you might look for on your<br /> system include clock(), delay(), gettimeofday(), msleep(),<br /> nap(), napms(), nanosleep(), setitimer(), sleep(), times(), and<br /> usleep(). (A function called wait(), however, is at least under<br /> Unix *not* what you want.) The select() and poll() calls (if<br /> available) can be pressed into service to implement simple<br /> delays. On MS-DOS machines, it is possible to reprogram the<br /> system timer and timer interrupts.<br /><br /> Of these, only clock() is part of the ANSI Standard. The<br /> difference between two calls to clock() gives elapsed execution<br /> time, and may even have subsecond resolution, if CLOCKS_PER_SEC<br /> is greater than 1. However, clock() gives elapsed processor time<br /> used by the current program, which on a multitasking system may<br /> differ considerably from real time.<br /><br /> If you're trying to implement a delay and all you have available<br /> is a time-reporting function, you can implement a CPU-intensive<br /> busy-wait, but this is only an option on a single-user, single-<br /> tasking machine as it is terribly antisocial to any other<br /> processes. Under a multitasking operating system, be sure to<br /> use a call which puts your process to sleep for the duration,<br /> such as sleep() or select(), or pause() in conjunction with<br /> alarm() or setitimer().<br /><br /> For really brief delays, it's tempting to use a do-nothing loop<br /> like<br /><br /> long int i;<br /> for(i = 0; i < 1000000; i++)<br /> ;<br /><br /> but resist this temptation if at all possible! For one thing,<br /> your carefully-calculated delay loops will stop working properly<br /> next month when a faster processor comes out. Perhaps worse, a<br /> clever compiler may notice that the loop does nothing and<br /> optimize it away completely.<br /><br /> References: H&S Sec. 18.1 pp. 398-9; PCS Sec. 12 pp. 197-8,215-<br /> 6; POSIX Sec. 4.5.2.<br /><br />19.38: How can I trap or ignore keyboard interrupts like control-C?<br /><br />A: The basic step is to call signal(), either as<br /><br /> #include <signal.h><br /> signal(SIGINT, SIG_IGN);<br /><br /> to ignore the interrupt signal, or as<br /><br /> extern void func(int);<br /> signal(SIGINT, func);<br /><br /> to cause control to transfer to function func() on receipt of an<br /> interrupt signal.<br /><br /> On a multi-tasking system such as Unix, it's best to use a<br /> slightly more involved technique:<br /><br /> extern void func(int);<br /> if(signal(SIGINT, SIG_IGN) != SIG_IGN)<br /> signal(SIGINT, func);<br /><br /> The test and extra call ensure that a keyboard interrupt typed<br /> in the foreground won't inadvertently interrupt a program<br /> running in the background (and it doesn't hurt to code calls to<br /> signal() this way on any system).<br /><br /> On some systems, keyboard interrupt handling is also a function<br /> of the mode of the terminal-input subsystem; see question 19.1.<br /> On some systems, checking for keyboard interrupts is only<br /> performed when the program is reading input, and keyboard<br /> interrupt handling may therefore depend on which input routines<br /> are being called (and *whether* any input routines are active at<br /> all). On MS-DOS systems, setcbrk() or ctrlbrk() functions may<br /> also be involved.<br /><br /> References: ISO Secs. 7.7,7.7.1; H&S Sec. 19.6 pp. 411-3; PCS<br /> Sec. 12 pp. 210-2; POSIX Secs. 3.3.1,3.3.4.<br /><br />19.39: How can I handle floating-point exceptions gracefully?<br /><br />A: On many systems, you can define a function matherr() which will<br /> be called when there are certain floating-point errors, such as<br /> errors in the math routines in <math.h>. You may also be able<br /> to use signal() (see question 19.38 above) to catch SIGFPE. See<br /> also question 14.9.<br /><br /> References: Rationale Sec. 4.5.1.<br /><br />19.40: How do I... Use sockets? Do networking? Write client/server<br /> applications?<br /><br />A: All of these questions are outside of the scope of this list and<br /> have much more to do with the networking facilities which you<br /> have available than they do with C. Good books on the subject<br /> are Douglas Comer's three-volume _Internetworking with TCP/IP_<br /> and W. R. Stevens's _UNIX Network Programming_. (There is also<br /> plenty of information out on the net itself, including the<br /> "Unix Socket FAQ" at http://kipper.york.ac.uk/~vic/sock-faq/ .)<br /><br />19.40b: How do I... Use BIOS calls? Write ISR's? Create TSR's?<br /><br />A: These are very particular to specific systems (PC compatibles<br /> running MS-DOS, most likely). You'll get much better<br /> information in a specific newsgroup such as<br /> comp.os.msdos.programmer or its FAQ list; another excellent<br /> resource is Ralf Brown's interrupt list.<br /><br />19.40c: I'm trying to compile this program, but the compiler is<br /> complaining that "union REGS" is undefined, and the linker<br /> is complaining that int86() is undefined.<br /><br />A: Those have to do with MS-DOS interrupt programming. They don't<br /> exist on other systems.<br /><br />19.41: But I can't use all these nonstandard, system-dependent<br /> functions, because my program has to be ANSI compatible!<br /><br />A: You're out of luck. Either you misunderstood your requirement,<br /> or it's an impossible one to meet. ANSI/ISO Standard C simply<br /> does not define ways of doing these things; it is a language<br /> standard, not an operating system standard. An international<br /> standard which does address many of these issues is POSIX<br /> (IEEE 1003.1, ISO/IEC 9945-1), and many operating systems (not<br /> just Unix) now have POSIX-compatible programming interfaces.<br /><br /> It is possible, and desirable, for *most* of a program to be<br /> ANSI-compatible, deferring the system-dependent functionality to<br /> a few routines in a few files which are rewritten for each<br /> system ported to.<br /><br /><br />Section 20. Miscellaneous<br /><br />20.1: How can I return multiple values from a function?<br /><br />A: Either pass pointers to several locations which the function can<br /> fill in, or have the function return a structure containing the<br /> desired values, or (in a pinch) consider global variables. See<br /> also questions 2.7, 4.8, and 7.5a.<br /><br />20.3: How do I access command-line arguments?<br /><br />A: They are pointed to by the argv array with which main() is<br /> called. See also questions 8.2, 13.7, and 19.20.<br /><br /> References: K&R1 Sec. 5.11 pp. 110-114; K&R2 Sec. 5.10 pp. 114-<br /> 118; ISO Sec. 5.1.2.2.1; H&S Sec. 20.1 p. 416; PCS Sec. 5.6 pp.<br /> 81-2, Sec. 11 p. 159, pp. 339-40 Appendix F; Schumacher, ed.,<br /> _Software Solutions in C_ Sec. 4 pp. 75-85.<br /><br />20.5: How can I write data files which can be read on other machines<br /> with different word size, byte order, or floating point formats?<br /><br />A: The most portable solution is to use text files (usually ASCII),<br /> written with fprintf() and read with fscanf() or the like.<br /> (Similar advice also applies to network protocols.) Be<br /> skeptical of arguments which imply that text files are too big,<br /> or that reading and writing them is too slow. Not only is their<br /> efficiency frequently acceptable in practice, but the advantages<br /> of being able to interchange them easily between machines, and<br /> manipulate them with standard tools, can be overwhelming.<br /><br /> If you must use a binary format, you can improve portability,<br /> and perhaps take advantage of prewritten I/O libraries, by<br /> making use of standardized formats such as Sun's XDR (RFC 1014),<br /> OSI's ASN.1 (referenced in CCITT X.409 and ISO 8825 "Basic<br /> Encoding Rules"), CDF, netCDF, or HDF. See also questions 2.12<br /> and 12.38.<br /><br /> References: PCS Sec. 6 pp. 86, 88.<br /><br />20.6: If I have a char * variable pointing to the name of a function,<br /> how can I call that function?<br /><br />A: The most straightforward thing to do is to maintain a<br /> correspondence table of names and function pointers:<br /><br /> int func(), anotherfunc();<br /><br /> struct { char *name; int (*funcptr)(); } symtab[] = {<br /> "func", func,<br /> "anotherfunc", anotherfunc,<br /> };<br /><br /> Then, search the table for the name, and call via the associated<br /> function pointer. See also questions 2.15, 18.14, and 19.36.<br /><br /> References: PCS Sec. 11 p. 168.<br /><br />20.8: How can I implement sets or arrays of bits?<br /><br />A: Use arrays of char or int, with a few macros to access the<br /> desired bit at the proper index. Here are some simple macros to<br /> use with arrays of char:<br /><br /> #include <limits.h> /* for CHAR_BIT */<br /><br /> #define BITMASK(b) (1 << ((b) % CHAR_BIT))<br /> #define BITSLOT(b) ((b) / CHAR_BIT)<br /> #define BITSET(a, b) ((a)[BITSLOT(b)] |= BITMASK(b))<br /> #define BITTEST(a, b) ((a)[BITSLOT(b)] & BITMASK(b))<br /><br /> (If you don't have <limits.h>, try using 8 for CHAR_BIT.)<br /><br /> References: H&S Sec. 7.6.7 pp. 211-216.<br /><br />20.9: How can I determine whether a machine's byte order is big-endian<br /> or little-endian?<br /><br />A: One way is to use a pointer:<br /><br /> int x = 1;<br /> if(*(char *)&x == 1)<br /> printf("little-endian\n");<br /> else printf("big-endian\n");<br /><br /> It's also possible to use a union.<br /><br /> See also question 10.16.<br /><br /> References: H&S Sec. 6.1.2 pp. 163-4.<br /><br />20.10: How can I convert integers to binary or hexadecimal?<br /><br />A: Make sure you really know what you're asking. Integers are<br /> stored internally in binary, although for most purposes it is<br /> not incorrect to think of them as being in octal, decimal, or<br /> hexadecimal, whichever is convenient. The base in which a<br /> number is expressed matters only when that number is read in<br /> from or written out to the outside world.<br /><br /> In source code, a non-decimal base is indicated by a leading 0<br /> or 0x (for octal or hexadecimal, respectively). During I/O, the<br /> base of a formatted number is controlled in the printf and scanf<br /> family of functions by the choice of format specifier (%d, %o,<br /> %x, etc.) and in the strtol() and strtoul() functions by the<br /> third argument. If you need to output numeric strings in<br /> arbitrary bases, you'll have to supply your own function to do<br /> so (it will essentially be the inverse of strtol). During<br /> *binary* I/O, however, the base again becomes immaterial.<br /><br /> For more information about "binary" I/O, see question 2.11.<br /> See also questions 8.6 and 13.1.<br /><br /> References: ISO Secs. 7.10.1.5,7.10.1.6.<br /><br />20.11: Can I use base-2 constants (something like 0b101010)?<br /> Is there a printf() format for binary?<br /><br />A: No, on both counts. You can convert base-2 string<br /> representations to integers with strtol(). See also question<br /> 20.10.<br /><br />20.12: What is the most efficient way to count the number of bits which<br /> are set in an integer?<br /><br />A: Many "bit-fiddling" problems like this one can be sped up and<br /> streamlined using lookup tables (but see question 20.13 below).<br /><br />20.13: What's the best way of making my program efficient?<br /><br />A: By picking good algorithms, implementing them carefully, and<br /> making sure that your program isn't doing any extra work. For<br /> example, the most microoptimized character-copying loop in the<br /> world will be beat by code which avoids having to copy<br /> characters at all.<br /><br /> When worrying about efficiency, it's important to keep several<br /> things in perspective. First of all, although efficiency is an<br /> enormously popular topic, it is not always as important as<br /> people tend to think it is. Most of the code in most programs<br /> is not time-critical. When code is not time-critical, it is<br /> usually more important that it be written clearly and portably<br /> than that it be written maximally efficiently. (Remember that<br /> computers are very, very fast, and that seemingly "inefficient"<br /> code may be quite efficiently compilable, and run without<br /> apparent delay.)<br /><br /> It is notoriously difficult to predict what the "hot spots" in a<br /> program will be. When efficiency is a concern, it is important<br /> to use profiling software to determine which parts of the<br /> program deserve attention. Often, actual computation time is<br /> swamped by peripheral tasks such as I/O and memory allocation,<br /> which can be sped up by using buffering and caching techniques.<br /><br /> Even for code that *is* time-critical, one of the least<br /> effective optimization techniques is to fuss with the coding<br /> details. Many of the "efficient coding tricks" which are<br /> frequently suggested (e.g. substituting shift operators for<br /> multiplication by powers of two) are performed automatically by<br /> even simpleminded compilers. Heavyhanded optimization attempts<br /> can make code so bulky that performance is actually degraded,<br /> and are rarely portable (i.e. they may speed things up on one<br /> machine but slow them down on another). In any case, tweaking<br /> the coding usually results in at best linear performance<br /> improvements; the big payoffs are in better algorithms.<br /><br /> For more discussion of efficiency tradeoffs, as well as good<br /> advice on how to improve efficiency when it is important, see<br /> chapter 7 of Kernighan and Plauger's _The Elements of<br /> Programming Style_, and Jon Bentley's _Writing Efficient<br /> Programs_.<br /><br />20.14: Are pointers really faster than arrays? How much do function<br /> calls slow things down? Is ++i faster than i = i + 1?<br /><br />A: Precise answers to these and many similar questions depend of<br /> course on the processor and compiler in use. If you simply must<br /> know, you'll have to time test programs carefully. (Often the<br /> differences are so slight that hundreds of thousands of<br /> iterations are required even to see them. Check the compiler's<br /> assembly language output, if available, to see if two purported<br /> alternatives aren't compiled identically.)<br /><br /> It is "usually" faster to march through large arrays with<br /> pointers rather than array subscripts, but for some processors<br /> the reverse is true.<br /><br /> Function calls, though obviously incrementally slower than in-<br /> line code, contribute so much to modularity and code clarity<br /> that there is rarely good reason to avoid them.<br /><br /> Before rearranging expressions such as i = i + 1, remember that<br /> you are dealing with a compiler, not a keystroke-programmable<br /> calculator. Any decent compiler will generate identical code<br /> for ++i, i += 1, and i = i + 1. The reasons for using ++i or<br /> i += 1 over i = i + 1 have to do with style, not efficiency.<br /> (See also question 3.12.)<br /><br />20.15b: People claim that optimizing compilers are good and that we no<br /> longer have to write things in assembler for speed, but my<br /> compiler can't even replace i/=2 with a shift.<br /><br />A: Was i signed or unsigned? If it was signed, a shift is not<br /> equivalent (hint: think about the result if i is negative and<br /> odd), so the compiler was correct not to use it.<br /><br />20.15c: How can I swap two values without using a temporary?<br /><br />A: The standard hoary old assembly language programmer's trick is:<br /><br /> a ^= b;<br /> b ^= a;<br /> a ^= b;<br /><br /> But this sort of code has little place in modern, HLL<br /> programming. Temporary variables are essentially free,<br /> and the idiomatic code using three assignments, namely<br /><br /> int t = a;<br /> a = b;<br /> b = t;<br /><br /> is not only clearer to the human reader, it is more likely to be<br /> recognized by the compiler and turned into the most-efficient<br /> code (e.g. using a swap instruction, if available). The latter<br /> code is obviously also amenable to use with pointers and<br /> floating-point values, unlike the XOR trick. See also questions<br /> 3.3b and 10.3.<br /><br />20.17: Is there a way to switch on strings?<br /><br />A: Not directly. Sometimes, it's appropriate to use a separate<br /> function to map strings to integer codes, and then switch on<br /> those. Otherwise, of course, you can fall back on strcmp() and<br /> a conventional if/else chain. See also questions 10.12, 20.18,<br /> and 20.29.<br /><br /> References: K&R1 Sec. 3.4 p. 55; K&R2 Sec. 3.4 p. 58; ISO<br /> Sec. 6.6.4.2; H&S Sec. 8.7 p. 248.<br /><br />20.18: Is there a way to have non-constant case labels (i.e. ranges or<br /> arbitrary expressions)?<br /><br />A: No. The switch statement was originally designed to be quite<br /> simple for the compiler to translate, therefore case labels are<br /> limited to single, constant, integral expressions. You *can*<br /> attach several case labels to the same statement, which will let<br /> you cover a small range if you don't mind listing all cases<br /> explicitly.<br /><br /> If you want to select on arbitrary ranges or non-constant<br /> expressions, you'll have to use an if/else chain.<br /><br /> See also question 20.17.<br /><br /> References: K&R1 Sec. 3.4 p. 55; K&R2 Sec. 3.4 p. 58; ISO<br /> Sec. 6.6.4.2; Rationale Sec. 3.6.4.2; H&S Sec. 8.7 p. 248.<br /><br />20.19: Are the outer parentheses in return statements really optional?<br /><br />A: Yes.<br /><br /> Long ago, in the early days of C, they were required, and just<br /> enough people learned C then, and wrote code which is still in<br /> circulation, that the notion that they might still be required<br /> is widespread.<br /><br /> (As it happens, parentheses are optional with the sizeof<br /> operator, too, under certain circumstances.)<br /><br /> References: K&R1 Sec. A18.3 p. 218; ISO Sec. 6.3.3, Sec. 6.6.6;<br /> H&S Sec. 8.9 p. 254.<br /><br />20.20: Why don't C comments nest? How am I supposed to comment out<br /> code containing comments? Are comments legal inside quoted<br /> strings?<br /><br />A: C comments don't nest mostly because PL/I's comments, which C's<br /> are borrowed from, don't either. Therefore, it is usually<br /> better to "comment out" large sections of code, which might<br /> contain comments, with #ifdef or #if 0 (but see question 11.19).<br /><br /> The character sequences /* and */ are not special within double-<br /> quoted strings, and do not therefore introduce comments, because<br /> a program (particularly one which is generating C code as<br /> output) might want to print them.<br /><br /> Note also that // comments, as in C++, are not yet legal in C,<br /> so it's not a good idea to use them in C programs (even if your<br /> compiler supports them as an extension).<br /><br /> References: K&R1 Sec. A2.1 p. 179; K&R2 Sec. A2.2 p. 192; ISO<br /> Sec. 6.1.9, Annex F; Rationale Sec. 3.1.9; H&S Sec. 2.2 pp. 18-<br /> 9; PCS Sec. 10 p. 130.<br /><br />20.20b: Is C a great language, or what? Where else could you write<br /> something like a+++++b ?<br /><br />A: Well, you can't meaningfully write it in C, either.<br /> The rule for lexical analysis is that at each point during a<br /> straightforward left-to-right scan, the longest possible token<br /> is determined, without regard to whether the resulting sequence<br /> of tokens makes sense. The fragment in the question is<br /> therefore interpreted as<br /><br /> a ++ ++ + b<br /><br /> and cannot be parsed as a valid expression.<br /><br /> References: K&R1 Sec. A2 p. 179; K&R2 Sec. A2.1 p. 192; ISO<br /> Sec. 6.1; H&S Sec. 2.3 pp. 19-20.<br /><br />20.24: Why doesn't C have nested functions?<br /><br />A: It's not trivial to implement nested functions such that they<br /> have the proper access to local variables in the containing<br /> function(s), so they were deliberately left out of C as a<br /> simplification. (gcc does allow them, as an extension.) For<br /> many potential uses of nested functions (e.g. qsort comparison<br /> functions), an adequate if slightly cumbersome solution is to<br /> use an adjacent function with static declaration, communicating<br /> if necessary via a few static variables. (A cleaner solution,<br /> though unsupported by qsort(), is to pass around a pointer to<br /> a structure containing the necessary context.)<br /><br />20.24b: What is assert() and when would I use it?<br /><br />A: It is a macro, defined in <assert.h>, for testing "assertions".<br /> An assertion essentially documents an assumption being made by<br /> the programmer, an assumption which, if violated, would indicate<br /> a serious programming error. For example, a function which was<br /> supposed to be called with a non-null pointer could write<br /><br /> assert(p != NULL);<br /><br /> A failed assertion terminates the program. Assertions should<br /> *not* be used to catch expected errors, such as malloc() or<br /> fopen() failures.<br /><br /> References: K&R2 Sec. B6 pp. 253-4; ISO Sec. 7.2; H&S Sec. 19.1<br /> p. 406.<br /><br />20.25: How can I call FORTRAN (C++, BASIC, Pascal, Ada, LISP) functions<br /> from C? (And vice versa?)<br /><br />A: The answer is entirely dependent on the machine and the specific<br /> calling sequences of the various compilers in use, and may not<br /> be possible at all. Read your compiler documentation very<br /> carefully; sometimes there is a "mixed-language programming<br /> guide," although the techniques for passing arguments and<br /> ensuring correct run-time startup are often arcane. More<br /> information may be found in FORT.gz by Glenn Geers, available<br /> via anonymous ftp from suphys.physics.su.oz.au in the src<br /> directory.<br /><br /> cfortran.h, a C header file, simplifies C/FORTRAN interfacing on<br /> many popular machines. It is available via anonymous ftp from<br /> zebra.desy.de or at http://www-zeus.desy.de/~burow .<br /><br /> In C++, a "C" modifier in an external function declaration<br /> indicates that the function is to be called using C calling<br /> conventions.<br /><br /> References: H&S Sec. 4.9.8 pp. 106-7.<br /><br />20.26: Does anyone know of a program for converting Pascal or FORTRAN<br /> (or LISP, Ada, awk, "Old" C, ...) to C?<br /><br />A: Several freely distributable programs are available:<br /><br /> p2c A Pascal to C converter written by Dave Gillespie,<br /> posted to comp.sources.unix in March, 1990 (Volume 21);<br /> also available by anonymous ftp from<br /> csvax.cs.caltech.edu, file pub/p2c-1.20.tar.Z .<br /><br /> ptoc Another Pascal to C converter, this one written in<br /> Pascal (comp.sources.unix, Volume 10, also patches in<br /> Volume 13?).<br /><br /> f2c A FORTRAN to C converter jointly developed by people<br /> from Bell Labs, Bellcore, and Carnegie Mellon. To find<br /> out more about f2c, send the mail message "send index<br /> from f2c" to netlib@research.att.com or research!netlib.<br /> (It is also available via anonymous ftp on<br /> netlib.att.com, in directory netlib/f2c.)<br /><br /> This FAQ list's maintainer also has available a list of a few<br /> other commercial translation products, and some for more obscure<br /> languages.<br /><br /> See also questions 11.31 and 18.16.<br /><br />20.27: Is C++ a superset of C? Can I use a C++ compiler to compile C<br /> code?<br /><br />A: C++ was derived from C, and is largely based on it, but there<br /> are some legal C constructs which are not legal C++.<br /> Conversely, ANSI C inherited several features from C++,<br /> including prototypes and const, so neither language is really a<br /> subset or superset of the other; the two also define the meaning<br /> of some common constructs differently. In spite of the<br /> differences, many C programs will compile correctly in a C++<br /> environment, and many recent compilers offer both C and C++<br /> compilation modes. See also questions 8.9 and 20.20.<br /><br /> References: H&S p. xviii, Sec. 1.1.5 p. 6, Sec. 2.8 pp. 36-7,<br /> Sec. 4.9 pp. 104-107.<br /><br />20.28: I need a sort of an "approximate" strcmp routine, for comparing<br /> two strings for close, but not necessarily exact, equality.<br /><br />A: Some nice information and algorithms having to do with<br /> approximate string matching, as well as a useful bibliography,<br /> can be found in Sun Wu and Udi Manber's paper "AGREP -- A Fast<br /> Approximate Pattern-Matching Tool."<br /><br /> Another approach involves the "soundex" algorithm, which maps<br /> similar-sounding words to the same codes. Soundex was designed<br /> for discovering similar-sounding names (for telephone directory<br /> assistance, as it happens), but it can be pressed into service<br /> for processing arbitrary words.<br /><br /> References: Knuth Sec. 6 pp. 391-2 Volume 3; Wu and Manber,<br /> "AGREP -- A Fast Approximate Pattern-Matching Tool" .<br /><br />20.29: What is hashing?<br /><br />A: Hashing is the process of mapping strings to integers, usually<br /> in a relatively small range. A "hash function" maps a string<br /> (or some other data structure) to a bounded number (the "hash<br /> bucket") which can more easily be used as an index in an array,<br /> or for performing repeated comparisons. (Obviously, a mapping<br /> from a potentially huge set of strings to a small set of<br /> integers will not be unique. Any algorithm using hashing<br /> therefore has to deal with the possibility of "collisions.")<br /> Many hashing functions and related algorithms have been<br /> developed; a full treatment is beyond the scope of this list.<br /><br /> References: K&R2 Sec. 6.6; Knuth Sec. 6.4 pp. 506-549 Volume 3;<br /> Sedgewick Sec. 16 pp. 231-244.<br /><br />20.31: How can I find the day of the week given the date?<br /><br />A: Use mktime() or localtime() (see questions 13.13 and 13.14, but<br /> beware of DST adjustments if tm_hour is 0), or Zeller's<br /> congruence (see the sci.math FAQ list), or this elegant code by<br /> Tomohiko Sakamoto:<br /><br /> int dayofweek(int y, int m, int d) /* 0 = Sunday */<br /> {<br /> static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};<br /> y -= m < 3;<br /> return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;<br /> }<br /><br /> See also questions 13.14 and 20.32.<br /><br /> References: ISO Sec. 7.12.2.3.<br /><br />20.32: Will 2000 be a leap year? Is (year % 4 == 0) an accurate test<br /> for leap years?<br /><br />A: Yes and no, respectively. The full expression for the present<br /> Gregorian calendar is<br /><br /> year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)<br /><br /> See a good astronomical almanac or other reference for details.<br /> (To forestall an eternal debate: references which claim the<br /> existence of a 4000-year rule are wrong.) See also questions<br /> 13.14 and 13.14b.<br /><br />20.34: Here's a good puzzle: how do you write a program which produces<br /> its own source code as output?<br /><br />A: It is actually quite difficult to write a self-reproducing<br /> program that is truly portable, due particularly to quoting and<br /> character set difficulties.<br /><br /> Here is a classic example (which ought to be presented on one<br /> line, although it will fix itself the first time it's run):<br /><br /> char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";<br /> main(){printf(s,34,s,34);}<br /><br /> (This program, like many of the genre, neglects to #include<br /> <stdio.h>, and assumes that the double-quote character " has the<br /> value 34, as it does in ASCII.)<br /><br />20.35: What is "Duff's Device"?<br /><br />A: It's a devastatingly deviously unrolled byte-copying loop,<br /> devised by Tom Duff while he was at Lucasfilm. In its "classic"<br /> form, it looks like:<br /><br /> register n = (count + 7) / 8; /* count > 0 assumed */<br /> switch (count % 8)<br /> {<br /> case 0: do { *to = *from++;<br /> case 7: *to = *from++;<br /> case 6: *to = *from++;<br /> case 5: *to = *from++;<br /> case 4: *to = *from++;<br /> case 3: *to = *from++;<br /> case 2: *to = *from++;<br /> case 1: *to = *from++;<br /> } while (--n > 0);<br /> }<br /><br /> where count bytes are to be copied from the array pointed to by<br /> from to the memory location pointed to by to (which is a memory-<br /> mapped device output register, which is why to isn't<br /> incremented). It solves the problem of handling the leftover<br /> bytes (when count isn't a multiple of 8) by interleaving a<br /> switch statement with the loop which copies bytes 8 at a time.<br /> (Believe it or not, it *is* legal to have case labels buried<br /> within blocks nested in a switch statement like this. In his<br /> announcement of the technique to C's developers and the world,<br /> Duff noted that C's switch syntax, in particular its "fall<br /> through" behavior, had long been controversial, and that "This<br /> code forms some sort of argument in that debate, but I'm not<br /> sure whether it's for or against.")<br /><br />20.36: When will the next International Obfuscated C Code Contest<br /> (IOCCC) be held? How can I get a copy of the current and<br /> previous winning entries?<br /><br />A: The contest is in a state of flux; see<br /> http://www.ioccc.org/index.html for current details.<br /><br /> Contest winners are usually announced at a Usenix conference,<br /> and are posted to the net sometime thereafter. Winning entries<br /> from previous years (back to 1984) are archived at ftp.uu.net<br /> (see question 18.16) under the directory pub/ioccc/; see also<br /> http://www.ioccc.org/index.html .<br /><br />20.37: What was the entry keyword mentioned in K&R1?<br /><br />A: It was reserved to allow the possibility of having functions<br /> with multiple, differently-named entry points, a la FORTRAN. It<br /> was not, to anyone's knowledge, ever implemented (nor does<br /> anyone remember what sort of syntax might have been imagined for<br /> it). It has been withdrawn, and is not a keyword in ANSI C.<br /> (See also question 1.12.)<br /><br /> References: K&R2 p. 259 Appendix C.<br /><br />20.38: Where does the name "C" come from, anyway?<br /><br />A: C was derived from Ken Thompson's experimental language B, which<br /> was inspired by Martin Richards's BCPL (Basic Combined<br /> Programming Language), which was a simplification of CPL<br /> (Cambridge Programming Language). For a while, there was<br /> speculation that C's successor might be named P (the third<br /> letter in BCPL) instead of D, but of course the most visible<br /> descendant language today is C++.<br /><br />20.39: How do you pronounce "char"?<br /><br />A: You can pronounce the C keyword "char" in at least three ways:<br /> like the English words "char," "care," or "car" (or maybe even<br /> "character"); the choice is arbitrary.<br /><br />20.39b: What do "lvalue" and "rvalue" mean?<br /><br />A: Simply speaking, an "lvalue" is an expression that could appear<br /> on the left-hand sign of an assignment; you can also think of it<br /> as denoting an object that has a location. (But see question<br /> 6.7 concerning arrays.) An "rvalue" is any expression that has<br /> a value (and that can therefore appear on the right-hand sign of<br /> an assignment).Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0