Chapter 13 पद्माकर | class 11th | Ncert solution for Hindi Antra

NCERT Solutions for Class 11th: पाठ 13 – पद्माकर

प्रश्न अभ्यास

1. पहले छंद में कवि ने किस ऋतु का वर्णन किया है?

उत्तर

पद्माकर ने पहले छंद में बसंत ऋतु का प्रभावशाली वर्णन किया है।

2. इस ऋतु में प्रकृति में क्या परिवर्तन होते हैं?

उत्तर

इस ऋतु में प्रकृति में ये परिवर्तन होते हैं-
• वसंत ऋतु में वृक्षों के झुंडों में भँवरे गुंजार करने लगते हैं।
• बगीचों में विभिन्न रंगों के फूल खिलने लगते हैं।
• आम का बौर अपनी सुगंध से सारे वातावरण को मादक बना देता है।
• पक्षी के समूह शोर मचाने लगते हैं।
• वनस्पतियाँ रस-रंग से परिपूर्ण हो जाती हैं।
• युवावर्ग आनंद में झूमने लगता है|

3. ‘और’ की बार-बार आवृत्ति से अर्थ में क्या विशिष्टता उत्पन्न हुई है?

उत्तर

कवि ने अपने कवित्त में ‘और’ शब्द की आवृत्ति से प्रकट किया है कि ऋतुराज वसंत का प्रभाव तो अति विशिष्ट है; बिलकुल अलग प्रकार का है, वैसा प्रभाव तो किसी ऋतु का हो ही नहीं सकता। प्रकृति तथा लोगों में वसंत ऋतु के आने पर मन में जो चमत्कारी बदलाव हुआ है, इस शब्द के माध्यम से उसे दिखाने में कवि सफल हो पाए हैं| इस शब्द से पता चलता है कि अभी जो प्राकृतिक सुंदरता थी उसमें और भी वृद्धि हुई है।

4. ‘पद्माकर के काव्य में अनुप्रास की योजना अनूठी बन पड़ी है।’ उक्त कथन को प्रथम छंद के आधार पर स्पष्ट कीजिए।

उत्तर

पद्माकर ने अनुप्रास अलंकार का सहज-स्वाभाविक प्रयोग तो किया ही है| उन्होंने स्थान-स्थान पर अनुप्रास का ऐसा प्रयोग किया है कि उनकी योजना अनूठी बन गई है। इसके उदाहरण इस प्रकार हैं-
(क) भीर भौंर
(ख) छलिया छबीले छैल और छबि छ्वै गए
(ग) गोकुल के कुल के गली के गोप गाउन के
(घ) कछू-को-कछू भाखत भनै
(ङ) चलित चतुर
(च) चुराई चित चोराचोरी
(छ) मंजुल मलारन
(ज) छवि छावनो

5. होली के अवसर पर सारा गोकुल गाँव किस प्रकार रंगों के सागर में डूब जाता है? दूसरे छंद के आधार पर लिखिए।

उत्तर

गोकुल की गलियों में सभी लोग होली के रंगों में डूबकर किसी को कुछ भी कह देते हैं। गोपों द्वारा घरों के आगे-पीछे दौड़कर होली खेली जा रही है। होली का हुड़दंग मचा हुआ है। एक गोपी कृष्ण के प्रेम के स्याम रंग में भीगी हुई है। वह इसे हटाना नहीं चाहती है, बस इसी में डूबना चाहती है। किसी को किसी का लिहाज़ नहीं है। कोई भी कुछ भी सुनना नहीं चाहता है। उनके विषय में कुछ भी कहना संभव नहीं है।

6. ‘बोरत तौं बोर्यो पै निचोरत बनै नहीं’ इस पंक्ति में गोपिका के मन का क्या भाव व्यक्त हुआ है?

उत्तर

इस पंक्ति में गोपी कहती हैं कि मैं तो कृष्ण के रंग में चोरी-चोरी रंग गई हूँ अर्थात मैंने सबसे चोरी अपने मन को कृष्ण के रंग में रंग दिया है। एक बार अपना मन कृष्ण के रंग में रंग देने के पश्चात अब मैं उसे निचोड़ने यानी उससे मुक्त होने के लिए तैयार नहीं हूँ।

7. पद्माकर ने किस तरह भाषा शिल्प से भाव-सौंदर्य को और अधिक बढ़ाया है? सोदाहरण लिखिए।

उत्तर

पद्माकर भाषा शिल्प में माहिर थे। उन्होंने अपना सारा काव्य ब्रजभाषा में रचा है जिसमें अलंकारों की अधिकता है। सूक्ष्म अनुभूतियों को दिखाने के लिए लाक्षणिक शब्द का इस्तेमाल किया गया है। उदाहरण के लिए यह उदाहरण देखें-
औरै भाँति कुंजन में गुंजरत भीर भौंर,
औरे डौर झौरन पैं बौरन के ह्वै गए।
‘औरै’ शब्द की पुनरुक्ति चमत्कार उत्पन्न देती है। अनुप्रास अलंकार के प्रयोग के जो ध्वनिचित्र बने हैं, वे अद्भुत हैं। उदाहरण के लिए देखिए-
1. छलिया छबीले छैल औरे छबि छ्वै गए
2. गोकुल के कुल के गली के गोप गाउन के
इसी कवित्त में ‘बोरत तौँ बोर्यो पै निचोरत बनीं नहीं’ में विशेषोक्ति अलंकार है। ‘होली वर्णन’ के पद में कवि ने चाक्षुक बिंब का आकर्षक विधान किया है तथा ‘हौं तो स्याम-रंग में चुराई चित चोरा चोरी’ में अनुप्रास तथा ‘स्याम-रंग’ में श्लेष अलंकार का सहज भाव से प्रयोग किया गया है।

8. तीसरे छंद में कवि ने सावन ऋतु की किन-किन विशेषताओं की ओर ध्यान आकर्षित किया है?

उत्तर

सावन ऋतु की विशेषताएँ इस प्रकार हैं-
• बगीचे में भँवरों का स्वर फैल गया है। उनका गुंजार मल्हार राग के समान प्रतीत होता है।
• इस ऋतु के प्रभाव से ही अपना प्रिय प्राण से अधिक प्यारा लगता है।
• मोर की ध्वनि हिंडोलों की छवि-सी लगती है।
• यह प्रेम की ऋतु है।
• झूले झूलने के लिए यह सर्वोत्तम ऋतु है।

9. संदर्भ सहित व्याख्या कीजिए-

(क) औरै भाँति कुंजन”…..”छबि छ्वै गए।

उत्तर

प्रसंग- प्रस्तुत पंक्ति प्रसिद्ध कवि पद्माकर द्वारा रचित है। इसमें कवि वसंत ऋतु में बाग-बगीचों में होने वाले परिवर्तन को दर्शा रहे हैं।

व्याख्या- प्रस्तुत पंक्तियों में वसंत ऋतु के आने पर वातावरण की विशेषता बताई गई है। पद्माकर कहते हैं कि बाग में भवरों के समूहों की भीड़ बढ़ गई है। बागों में आम के पेड़ों पर बौरें लग गई हैं। इससे पता चलता है कि फल अब लगने ही वाले हैं। भाव यह है कि वसंत ऋतु में बाग में फूल खिलने लगते हैं, जिसके कारण भवरों की संख्या में वृद्धि हो गई है। ऐसे ही आम के वृक्षों पर बौरें लग गई हैं, जो इस बात का प्रमाण है कि फल लगने वाले हैं।

(ख) तौ लौं चलित “बनै नहीं।

उत्तर

प्रसंग- प्रस्तुत पंक्ति प्रसिद्ध कवि पद्माकर द्वारा रचित है। इसमें एक गोपी की दशा का वर्णन किया गया है। उस पर श्याम रंग चढ़ गया है और वह उसे उतारना नहीं चाहती है।

व्याख्या- पद्माकर कहते हैं कि होली खेलते समय एक गोपी कहती हैं कि मेरे पर कृष्ण का रंग चढ़ गया है। दूसरी सखी उसे इस रंग को निचोड़कर उतारने के लिए कहती है। वह गोपी इस रंग को उतारना नहीं चाहती है। यह रंग कृष्ण के प्रेम का रंग है। वह कहती है कि यदि वह इस रंग को निचोड़ देगी, तो यह रंग निकल जाएगा। वह इस रंग में डूब जाना चाहती है। अतः वह दूसरी गोपी को मना कर देती है। भाव यह है कि जो कृष्ण से प्रेम करता है, वह उसके रंग को अपना लेता है। गोपी भी कृष्ण को प्रेम करती है। अतः कृष्ण से प्रेम करने के कारण कृष्ण का काला रंग भी उसे अच्छा लगता है।

(ग) कहैं पद्माकर…”लगत है।

उत्तर

प्रसंग- प्रस्तुत पंक्ति प्रसिद्ध कवि पद्माकर द्वारा रचित है। प्रस्तुत पंक्ति में पद्माकर वर्षा ऋतु की विशेषता बता रहे हैं। उनके अनुसार यह प्रेम की ऋतु है और इसमें रूठना-मनाना अच्छा लगता है।

व्याख्या- पद्माकर कहते हैं कि वर्षा ऋतु में प्रेमिका को अपना प्रियमत अच्छा लगता है। इसमें रूठे प्रेमी को मनाने में भी आनंद आता है। भाव यह है कि प्रायः जब प्रियतम रूठ जाता है, तो मनुष्य अहंकार वश मनाता नहीं है। वर्षा ऋतु में यदि प्रेमी नाराज़ हो जाए, तो उसे मनाना अच्छा लगता है। यह ऋतु का ही प्रभाव है कि नाराज़ प्रेमी को मनाकर आनंद प्राप्त किया जाता है।

Read More

Chapter 8: Communication Open Source Concept | NCERT Solution for class 12th COMPUTER SCIENCE


NCERT Solutions for Class 12 Computer Science (C++) – Networking and Open Source Concepts

TOPIC-1
Communication Technoiogies

Very Short Answer Type Questions [1 mark each]

Question 1:
Identify the Domain name and URL from the following :
http://www.income.in/home.aboutus.hml
Answer:
Domain name – income.in
URL – http://www.income.in/home.aboutus.hml

Question 2:
What is Web Hosting?
Answer:
Web hosting is the service that makes our website available to be viewed by others on the Internet. A web host provides space on its server, so that other computers around the world can access our website by means of a network or modem.

Question 3:
What is the difference between packet & message switching ?
Answer:

Packet SwitchingMessage switching
There is a tight upper limit on the block size. A fixed size of packet is specified.In message switching there was no upper limit.
All the packets are stored in main memory in switching office.In message switching packets are stored on disk. This increases the performance as access time is reduced.

Question 4:
Which protocol in used in creating a connection with a remote machine ?
Answer:
Telnet : It is an older internet utility that allow us to log on to remote computer system. It also facilitates for terminal emulation purpose.

Question 5:
Which protocol is used to create a connection with a remote machine? Give any two advantage of using Optical Fibers.
Answer:
Telnet Two advantage of using Optical Fibers are

  1. Capable of extremely high speed.
  2. No Electromagnetic interference.
  3. Extremely low attending

Question 6:
What is cloud computing ?
Answer:
The sharing of computer resources (dedicated, time-shared, or dynamically shared servers) and related infrastructurer components (load balancers, firewalls, network storage, developer tools, monitors and management tools) to facilitate the deployment and operation of web and network based applications. Cloud computing relies on sharing of resources to achieve coherence and economies of scale, similar to a utility (like the electricity grid) over a network.

Question 7:
Write two characterstics of Wi-Fi.
Answer:

  1. It is wireless network.
  2. It is for short range.

Question 8:
Expand the following :

  1. GSM
  2. GPRS

Answer:

  1. GSM – Global System for Mobile Communication.
  2. GPRS – General Packet Radio Service.

Question 9:
Which type of network out of LAN, PAN and MAN is formed, when you connect two mobiles using Bluetooth to transfer a video
Answer:
PAN

Question 10:
Write one characterstic each for 2G and 3G mobile technologies.
Answer:
2G networks primarily involve the transmission of voice information while 3G technology provides the additional advantage of data transfer.

Question 11:
What is the difference between Packet switching and circuit switching techniques ?
Answer:
In circuit switching, a dedicated path exists from source to destination while in packet switching, there is no fixed path.

Question 12:
Write two advantages of using an optical fibre cable over an Ethernet cable to connect two service stations, which are 200 m away from each other.
Answer:
Advantages of optical fibre :

  1. Faster speed than ethernet
  2. Lower Attenuation

Question 13:
Write one advantage of bus topology of network. Also illustrate how four (4) computers can be connected with each other using bus topology of network.
Answer:
Advantage (benefits) of Linear Bus Topology is that the cable length required for this topology is the least compared to the other networks.
Bus Topology of Network:
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(198-1)

Question 14:
Give one suitable example of each URL and Domain Name.
Answer:
URL: http://waltons.in
Domain Name: gmail.com

Question 15:
Write one advantage of star topology of network ? Also, illustrate how five (5) computers can be connected with each other using star topology of network.
Answer:
Advantage (benefits) of star toplogy:
Easy to replace, install or remove hosts or other devices.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(198-2)

Question 16:
Identify the type of topology on the basis of the following :
(a) Since every node is directly connected to the server, a large amount of cable is needed which increases the installation cost of the network.
(b) It has a single common data path connecting all the nods.
Answer:
(a) Star Topology
(b) Bus Topology

Question 17:
Expand the following :
(a) VOIP
(b) SMTP
Answer:
(a) Voice Over Internet Protocol
(b) Simple Mail Transfer Protocol

Question 18:
Daniel has to share the data among various computers of his two offices branches situated in the same city. Name the network (out of LAN, WAN, PAN and MAN) which is being formed in this process.
Answer:
MAN

Question 19:
ABC International School is planning to connect • all computers, each spread over a distance of 50 metres. Suggest an economic cable type having high speed data transfer to connect these computers.
Answer:
Optical Fibre Cable.

Question 20:
Mahesh wants to transfer data within a city at very high speed. Write the wired transmission medium and type of network.
Answer:
Wired transmission medium – Optical fibre cable Type of network – MAN.

Question 21:
Which device is used to connect all computers inside a lab ?
Answer:
Hub or Switch

Question 22:
Which device is used to connect all computers to the internet using telephone wire ?
Answer:
RJ – 45. It is an eight wired connectors used to connect computers on a LAN.

Question 23:
What is Wi-Fi Card ?
Answer:
Wi-Fi cards are small and portable cards that allow the computer to connect to the internet through a wireless network. The transmission is through the use of radio waves.

Question 24:
Explain the purpose of a router.
Answer:
A router establishes connection between two network and it can handle network with different protocols. Using a routing table, routers make sure that the data packets are travelling through the best possible paths to reach their destination.

Question 25:
Identify the type of topology from the following.
(a) Each node is connected with the help of a single cable
(b) Each node is connected with the help of independent cable with central switching.
Answer:
(a) Bus topology
(b) Star topology

Question 26:
What is the difference between LAN and MAN ?
Answer:
LAN : It is Local Area Network. The diameter is not more than a single building.
WAN : It is Metropolitan Area Network. LAN spans a few kms while MAN spans 5-50 km diameter and is larger than a WAN.

Short Answer Type Questions-I [2 marks each]

Question 1:
Write any 1 advantage and 1 disadvantage of Bus topology.
Answer:
Advantage : Since there is a single common data path connecting all the nodes, the bus topology uses a very short cable length which considerably reduces the installation cost. Disadvantage : Fault detection and isolation is difficult. This is because control of the network is not centralized in any particular node. If a node is faulty on the bus, detection of fault may have to be performed at many points on the network. The faulty node has then to be rectified at that connection point.

Question 2:
SunRise Pvt. Ltd. is setting up the network in the Ahmedabad. There are four departments named as MrktDept, FinDept, LegalDept, SalesDept.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(199-1)
Distance between varioud buldings is as given:

MrktDept to FinDept80 m
MrktDept to LegalDept180 m
MrktDept to SalesDept100 m
LegalDept to SalesDept150 m
LegalDept to FinDept100 m
FinDept to SalesDept50 m

Number of Computers in the buildings :

MrktDept20
LegalDept10
FinDept08
SalesDept42

(i) Suggest a cable layout of connections between the Departments and specify the topology.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(200-1)
Star Topology should be used.
(ii) Suggest the most suitable building to place the server by giving suitable reason.
Answer:
As per 80 – 20 rule, server should be placed in MrktDept because it has maximium no. of computers.
(iii) Suggest the placement of (i) modem (ii) Hub/ Switch in the network.
Answer:
Each building should have hub/switch and moderm in case Internet connection is required.
(iv) The organization is planning to link its sale counter situated in various part of the same city, which type of network out of LAN, WAN, MAN will be formed ? Justify.
Answer:
MAN (Metropolitan Area Network) as MAN network can be carried out in a city network.

Question 3:
Name the protocol
(i) Used to transfer voice using packet switched network.
Answer:
VAns.VOIP (Voice Over Internet Protocol)
(ii) Used for chatting between 2 group or between 2 individuals.
Answer:
IRC (Internet Relay Chat)

Question 4:
What is an IP Address ?
Answer:
IP address is a unique identifier for a node or host connection on an IP network. An IP address is a 32 bit binary number usually represented as 4 decimal values, each representing 8 bits, in the range 0 to 255 (know as octets) separated by decimal points. This is known as “dotted decimal” notation.
Example : 140.179.220.200

Question 5:
What is HTTP ?
Answer:
HTTP is a protocol that is used for transferring hypertext (i.e., text,graphic,image,sound,video,e tc,) between 2 computers and is particularly used on the world wideWeb (WWW).
[1 mark for definition/explanation]

Question 6:
Explain the importance of Cookies.
Answer:
When the user browses a website, the web server sends a text file to the web browser. This small text file is a cookie. They are usually used to track the pages that we visit so that information can be customised for us for that visit.

Question 7:
How is 4G different from 3G?
Answer:
3G technology adds multimedia facilities such as video, audio and graphics applications whereas 4G will provide better than TV quality images and video-links.

Question 8:
Illustrate the layout for connecting 5 computers
in a Bus and a Start topology of Networks.
Answer:
Bus topology
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(200-2)
Or any valid illustration of Bus and Star Topology.

Question 9:
What is a spam mail ?
Answer:
Spam is the abuse of electronic messaging systems (including most broadcast media, digital delivery systems) to send unsolicited bulk messages indiscriminately.

Question 10:
Differentiate between FTP and HTTP
Answer:
FTP is a protocol to transfer files over the Internet
HTTP is a protocol which allows the use of HTML to browse web pages in the World Wide Web.

Question 11:
Answer:
following, which is the fastest

  1. wired and
  2. wireless medium of communication ?

Answer:

  1. Wired – Optical Fiber
  2. Wireless – Infrared OR Microwave

Question 12:
What is Worm ? How is it removed ?
Answer:
A worm is a self-replicating computer program. It uses a network to send copies of itself to other computers on the network and it may do so without any user intervention.
Most of .the common anti-virus (anti-worm) remove worm.

Question 13:
Out of the following, which all comes under cyber crime ?
(i) Stealing away a brand new computer from a showroom.
(ii) Getting in someone’s social networking account without his consent and posting pictures on his behalf to harash him.
(iii) Secretly copying files from server of a call center and selling it to the other organization.
(iv) Viewing sites on a internet browser.
Answer:
(ii) & (iii)

Question 14:
Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA. [O.D, 2015]
You as a network expert have to suggest the best network related solutions for their problems raised in (i) to (iv), keeping in mind the distances between the buildings and other given parameters.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(201-1)
Shortest distances between various buildings.

ADMIN To ENGINEERING55 m
ADMIN to BUSINESS90 m
ADMIN to MEDIA90 m
ENGINEERING to BUSINESS55 m
ENGINEERING to MEDIA90 m
BUSINESS to MEDIA45 m
DELHI Head Office to CHENNAI Campus2175 km

Number of Computers Installed at various buildings are as follows :

ADMIN110
ENGINEERING75
BUSINESS40
MEDIA12
DELHI Head Office20

(i) Suggest the most appropriate location of the server inside the Chennai campus (out of the 4 buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
Answer:
ADMIN (Due to maximum number of computers)
OR
Media (Due to shorter distance from the other buildings)
(ii) Suggest and draw the cable layout to efficiently connect various buildings within the Chennai Campus for connecting the computers.
Answer:
Anyone of the following
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(201-2)
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(202-1)
(iii) Which hardware device will you suggest to be procured by the company to be installed to protect and control the internet uses within the campus ?
Answer:
Firewall OR Router
(iv) Which of the following will you suggest to establish the online face-to-face communication between the people in the Admin Office of Chennai Campus and Delhi Head Office ?
Answer:
Cable TV

Question 15:
What kind of data gets stored in cookies and how is it useful ?
Answer:
When a Website with cookie capabilities is visited, its server sends certain information about the browser, which is stored in the hard drive as a text file. It is as way for the server to remember things about the visited sites.

Question 16:
Differentiate between packet switching over message switching ?
Answer:
Packet Switching : Follow store and forward principle for fixed packets. Fixes an upper limit for packet size.
Message Switching : Follows store and forward principle for complete message. No limit on block size.

Question 17:
Out of the following, which is the fastest
(i) wired and
(ii) wireless medium of communication ?
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber
Answer:
(i) Wired : Optical Fiber
(ii) Wireless : Infrared OR Microwave

Question 18:
What is Trojan Horse ?
Answer:
A Trojan Horse is a code hidden in a program, that looks safe but has hidden side effects typically causing loss or theft of data, and possible system harm.

Question 19:
Out of the following, which all comes under cyber crime ?

  1. Stealing away a brand new hard disk from a showroom.
  2. Getting in someone’s social networking account without his consent and posting on his behalf.
  3. Secretly copying data from server of an organization and selling it to tire other organization.
  4. Looking at online activities of a friends blog.

Answer:
(ii) & (iii)

Question 20:
Write any two differences between twisted pair and coaxial pair cable.
Answer:

Twisted PairCo-axial Cable
Their bandwidth is not as high as coaxial cables.It has high bandwidth.
A twisted pair consists of two copper wires twisted around each other (each has its own insulation around it) like a double helix.A coaxial cable consists of a copper wire core covered by an insulating material and a layer of conducting material over that.

Question 21:
Write one advantage of Bus Topology of network, also, illustrate how 4 computers can be connected with each other using star topology of network.
Answer:
Cable length required for his topology is the least compared to other networks.
OR
Any other correct advantage of Bus Topology of network.
Illustration of 4 computers connected with each other using star topology of network.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(202-2)

Short Answer Type Question-II [3 marks]

Question 1:
Uplifting Skills Hub India is a knowledge and skill community which has an aim to uplift the standard of knowledge and skills in the society. It is planning to setup its training centres in multiple towns and villages pan India with its head offices in the nearest cities. They have created a model of their network with a city, a town and 3 villages as follows.
As a network consultant, you have to suggest the best network related solutions for their issues/problems raised in (i) to (iv) keeping in mind the distance between various locations and given parameters.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(203-1)
Shortest distance between various location :

VILLAGE 1 to B_TOWN2 KM
VILLAGE 2 to B_TOWN1.0 KM
VILLAGE 3 to B_TOWN1.5 KM
VILLAGE 1 to VILLAGE 23.5 KM
VILLAGE 1 to VILLAGE 34.5 KM
VILLAGE 2 to VILLAGE 32.5 KM
A CITY Head Office to B HUB25 KM

Number of Computers installed at various locations are as follows :

B_TOWN120
VILLAGE 115
VILLAGE 210
VILLAGE 315
A_CITY OFFICE6

Note :

• In Villages, there are community centres, in which one room has been given as training center to this organization to install computers.
• The organization has got financial support from the government and top IT companies.

  1. Suggest the most appropriate location of the SERVER in the BHUB (out of the 4 locations), to get the best and effective connectivity. Justify your answer.
  2. Suggest the best wired medium and draw the cable layout (location to location) to efficiently connect various locations within the B HUB.
  3. Which hardware device will you suggest to connect all the computers within each location of B_HUB ?
  4. Which service/protocol will be most helpful to conduct live interactions of Experts from Head Office and people at all locations of B HUB ?

Answer:
(i) B-TOWN can house the server as it has the maximum no. of computers.
(ii) Optical fibre cable is the best for this star topology.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(203-2)
(iii) Switch
(iv) VoIP

Long Answer Type Questions [4 marks each]

Question 1:
Indian School in Mumbai is starting up the network between its different wings. There are Four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as shown below.:
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(203-3)
The distance between various buildings is as follows:

ADMIN TO SENIOR200m
ADMIN TO JUNIOR150m
ADMIN TO HOSTEL50m
SENIOR TO JUNIOR250m
SENIOR TO HOSTEL350m
JUNIOR TO HOSTEL350m

Number of Computers in Each Building :

SENIOR130
JUNIOR80
ADMIN160
HOSTEL50

(b1) Suggest the cable layout of connections between the buildings.
(b2) Suggest the most suitable place (i.e., building) to house the server of this school, provide a suitable reason.
(b3) Suggest the placement of the following devices with justification, i Repeater i Hub/Switch
(b4) The organisation also has inquiry office in another dty about 50-60 km away in hilly region. Suggest the suitable transmission media to interconnect to school and inquiry office out of the following : i Fiber optic cable, i Microwave, i Radiowave
Answer:
(b1)

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(204-1)

(b2) Server can be placed in the ADMIN building as it has the maxium number of computer.
(b3) Repeater can be placed between ADMIN and SENIOR building as the distance is more than 110 m.
(b4) Radiowaves can be used in hilly regions as they can travel through obstacles.

Question 2:
Vidya Senior Secondary Public School in Nainital is setting up the network between its different wings. There are 4 wings named as SENIOR(S), JUNIOR(J), ADMIN(A) and HOSTEL(H).
Distance between various wings are given below :

Wing A to Wing S100 m
Wing A to Wing J200 m
Wing A to Wing H400 m
Wing S to Wing J300 m
Wing S to Wing H100 m
Wing J to Wing H450 m
WingNumber of Computers
Wing A
Wing S
Wing J
Wing H
20
150
50
25

(ii) Name the most suitable wing where the Server should be installed. Justify your answer.
(iii) Suggest where all Hub(s)/Switch(es) should be placed in the network.
(iv) Which communication medium would you suggest to connect this school with its main branch in Delhi ?
Answer:
(i) Star Topology

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(204-2)

(ii) Server should be in Wing S as it has the maximum number of computers.
(iii) All Wings need hub/switch as it has more than one computer.
(iv) Since the distance is more, wireless transmission would be better. Radiowaves are reliable and can travel through obstacles

Question 3:
Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and suggest them the best available solutions. Their queries are mentioned as (i) to (iv) below.
Physical Locations of the blocks of TTC


ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(204-3)

Block to Block distances (in Mtrs.)

Block (From)Block (To)Distance
Human ResourceConference110
Human ResourceFinance40
ConferenceFinance80

Expected Number of Computers to be installed in each block

BlockComputers
Human Resource
Finance
Conference
25
120
90
  1. What will be the most appropriate block, where TTC should plan to install their server?
  2. Draw a block diagram showing cable layout to connect all the buildings in the most appropriate manner for efficient communication.
  3. What will be the best possible connectivity out of the following, you will suggest to connect the new setup of offices in Bangalore with its London based office.
    • Satellite Link
    • Infrared
    • Ethernet Cable
  4. Which of the following device will be suggested by you to connect each computer in each of the buildings?
    • Switch
    • Modem
    • Gateway

Answer:
(i) Finance block because it has maximum number of computers.
(ii)

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(205-1)

(iii) Satellite link
(iv) Switch

Question 4:
Tech Up Corporation (TUC) is a professional consultancy company. The company is planning to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and suggest them the best available solutions. Their queries are mentioned as (i) to (iv) below.
Physical Locations of the blocks of TUC

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(205-2)
Block to Block distances (in Mtrs.)

Block (From)Block (To)Distance
Human ResourceConference60
Human ResourceFinance120
ConferenceFinance80

Expected Number of Computers to be installed in each block

BlockComputers
Human Resource
Finance
Conference
25
120
90
  1. What will be the most appropriate block, where TUC should plan to install their server?
  2. Draw a block to block cable layout to connect all the buildings in the most appropriate manner for efficient communication.
  3. What will be the best possible connectivity out of the following you will suggest to connect the new setup of offices in Bangalore with its London based office?
    • Infrared
    • Satellite Link
    • Ethernet Cable
  4. Which of the following devices will be suggested by you to connect each computer in each of the buildings?
    • Gateway
    • Switch
    • Modem

Answer:
(i) Human resource block because it has maximum number of computers.
(ii)
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(205-3)
(iii) Satellite link
(iv) Switch

Question 5:
G.R.K International Inc. is planning to connect its Bengaluru Office Setup with its Head Office in Delhi. The Bengaluru Office G.R.K. inter-national Inc. is spread across and area of approx. 1 square kilometer, consisting of 3 blocks – Human Resources, Academics and Administration.
You as a network expert have to suggest answers to the four queries (i) to (iv) raised by them.
Note : Keep the distance’ between blocks and no. of computers in each block in mind, while providing them the solutions.

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(205-4)

Shortest distances between various blocks :

Human Resources to Administration100 m
Human Resources to Academics65 m
Academics to Administration110 m
Delhi Head Office to Bengaluru Office Setup2350 km

Number of Computers installed at various blocks are as follows:

BLOCKNo. of Computers
Human Resources155
Administration20
Academics100
Delhi Head Office20
  1. Suggest the most suitable block in the Bengaluru Office Setup, to host the server. Give a suitable reason with your suggestion.
  2. Suggest the cable layout among the various blocks within the Bengaluru Office Setup for connecting the Blocks.
  3. Suggest a suitable networking device to be installed in each of the blocks essentially required for connecting computers inside the blocks with fast and efficient connectivity.
  4. Suggest the most suitable media to provide secure, fast and reliable data connectivity between Delhi Head Office and the Bengaluru Office Setup.

Answer:

(i) Human Resources because it has maximum number of computers.
(ii)

ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(206-1)
(iii) Switch
(iv) Satellite link

Question 6:
Rovenza Communications International (RCI) is an online corporate training provider company for IT related courses. The company is setting up their new campus in Kolkata. You as a network expert have to study the physical locations of various blocks and the number of computers to be installed. In the planning phase, provide the best possible answers for the queries (i) to (iv) raised by them.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(206-2)
Block to Block Distances (in Mtrs.)

FromToDistance
Administrative Block
Administrative Block
Finance Block
Finance Block Faculty
Recording Block Faculty
Recording Block
60
120
70

Expected Computers to be installed in each block

BlockComputers
Administrative Block
Finance Block
Faculty Recording Block
30
20
100
  1. Suggest the most appropriate block, where RCI should plan to install the server.
  2. Suggest the most appropriate block to block cable layout to connect all three blocks for efficient communication.
  3. Which type of network out of the following is formed by connecting the computers of these three blocks?
    • LAN
    • MAN
    • WAN
  4. Which wireless channel out of the following should be opted by RCI to connect to students from all over the world?
    • Infrared
    • Microwave
    • Satellite
  5. Write two advantages of using open source software over proprietary software.
  6. Which of the following crime(s) does not come under cybercrime ?
    1. Copying some important data from a computer without taking permission from the owner of-the data.
    2. Stealing keyboard and mouse from a shop.
    3. Getting into unknown person’s social networking account and start messaging on his behalf.

Answer:
(i) Faculty Recording Block.
(ii) Bus Topology
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(206-3)
(iii) LAN
(iv) Satellite connection
(v) Advantages of open source over proprietary software :
• Open source software’s source code is available, can be modified copied & distributed while propritary software can’t be change.
• Open source is free while propriatary is paid.
(vi) (ii) Stealing keyboard & mouse from-a shop.

Question 7:
(a) What is the difference between domain name and IP address?
(b) Write two advantages of using an optical fibre cable over an Ethernet cable to connect two sendee stations, which are 190 m away from each other.
(c) Expertia Professsional Global (EPG) is an online, corporate training provider company for IT related courses. The company is setting up their new campus in Mumbai. You as a network expert have to study the physical locations of various buildings and the number of computers to be installed. In the planning phase, provide the best possible answer for the queries (i) to (iv) raised by them.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(207-1)
Building to Building Distances (in Mtrs.)

FromToDistance
Administrative Building
Administrative Building
Finance Building
Finance Building
Recording Studio Building
Faculty Studio Building
60
120
70

Expected Computers to be installed in each Building:

BuildingComputers
Administrative Building
Finance Building
Faculty Studio Building
20
40
120
  1. Suggest the most appropriate building, where EPG should plan to install the server.
  2. Suggest the most appropriate building to building cable layout to connect all three buildings for efficient communication.
  3. Which type of network out of the following is formed by connecting the computers of these three buildings?
    • LAN
    • MAN
    • WAN
  4. Which wireless channel out of the following should be opted by EPG to connect to students of all over the world?
    • Infrared
    • Microwave
    • Satellite

Answer:
(a) Domain Name is alphanumeric address of a resource over network IP address is a Numeric Address of a resoure in a Network. Example :
Domain Name
WWW.Gabsclasses.com
IP Address
102.112.0.153
(b) Optical fibre Advantages :
(i) Faculty Studio Building.
(ii) Bus Topology.
Faculty Finance
Administrative Building
Studio Building
(iii) LAN
(iv) Satellite

Question 8:
To provide telemedicine faculty in a hilly state, a computer network is to be setup to connect hospitals in 6 small villages (VI, V2, …, V6) to the base hospital (H) in the state capital. This is shown in the following diagram.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(207-2)
No village is more than 20 km away from the state capital.
Imagine yourself as a computer consultant for this project and answer the following questions with justification :

  1. Out of the following what kind of link should be provided to setup this network :
    1. Microwave link,
    2. Radio Link,
    3. Wired Link ?
  2. What kind of network will be formed; LAN, MAN, or WAN ?
  3. Many times doctors at village hospital will have to consult senior doctors at the base hospital. For this purpose, how should they contact them: using email, sms, telephone, or video conference ?
  4. Out of SMTP and POP3 which protocol is used to receive emails ?
  5. What are cookies in the context of computer networks?
  6. Rajeshwari is trying for on-line subscription to a magazine. For this she has filled in a form on the magazine’s web site. When the clicks submit button she gets a message that she has left e-mail field empty and she must fill it. For such checking which type of script is generally executed; client side script or server-side script ?
  7. Mention any one difference between free-ware and free software.

Answer:
(i) Radio Link
(ii) MAN
(iii) e-mail
(iv) POP3
(v) Cookies are files that store user information that is used to identify the user when he logs into the system.
(vi) Server-side script.
(vii) Freeware is a software that has the user to get unlimited usage. Free software may be free for a certain period’only.

Question 9:
Work a lot Consultants are setting up a secured network for their office campus at Gurgaon for their day-to-day office and web- based activities. They are planning to have connectivity between three buildings and the head office situated in Mumbai. Answer the questions (i) to (iv) after going through the building positions in the campus and other details, which are given below:
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(208-1)
Distances between various buildings :

Building “GREEN” to Building “RED”110 m
Building “GREEN” to Building “BLUE”45 m
Building “BLUE” to Building “RED”65 m
Gurgaon Campus to Head Office1760 km

Number of computers

Building “GREEN”32
Building “RED”150
Building “BLUE”45
Head Office10
  1. Suggest the most suitable place (i.e., building) to house the server of this organization. Also give a reason to justify your suggested location.
  2. Suggest a cable layout of connections between the buildings inside the campus.
  3. Suggest the placement of the following devices with justification:
    1. Repeater.
    2. Switch.
  4. The organization is planning to provide a high speed link with its head office situated in Mumbai using a wired connection. Which of the following cables will be most suitable for this job ?
    1. Optical Fibre
    2. Coaxial Cable
    3. Ethernet Cable

Answer:
(i) The most suitable place to install server is building “RED” because this building has maximum computer which reduce communication delay.
(ii) Cable layout is Bus topology
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(208-2)
(iii) Since the cabling distance between buildings GREEN, BLUE and RED are quite large, so a repeater, would ideally be needed along their path to avoid loss of signals during the course of data flow in there routes.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(208-3)
(2) In the layout a switch each would be needed in all the building, to interconnect the group of cables from the different computers in each building.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(209-1)
(iv) Optical fibre.

Question 10:
Granuda Consultants are setting up a secured network for their office campus at Faridabad for their day to day office and web based activities. They are planning to have connectivity between 3 building and the head office situated in Kolkata. Answer the questions (i) to (iv) after going through the building positions in the campus and other details, which are given below :
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(209-2)
Distances between various buildings :

Building “RAVI” to Building “JAMUNA”120 m
Building “RAVI” to Building “GANGA”50 m
Building “GANGA” to Building “JAMUNA”65 m
Faridabad Campus to Head Office1460 km

Number of computers

Building “RAVI”25
Building “JAMUNA”150
Building “GANGA”51
Head Office10
  1. Suggest the most suitable place (i.e., block) to house the server of this organization. Also give a reason to justify your suggested location.
  2. Suggest a cable layout of connections between the buildings inside the campus.
  3. Suggest the placement of the following devices with justification:
    1. Repeater
    2. Switch
  4. The organization is planning to provide a high speed link with its head office situated in the KOLKATA using a wired connection. Which of the following cable will be most suitable for this job ?
    1. Optical Fibre
    2. Coaxial Cable
    3. Ethernet Cable

Answer:
(i) The most suitable place to install server is in building “JAMUNA” because this building has maximum computer which reduce the communication delay.
(ii) Cable layout. (Bus topology).
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(209-3)
(iii) (1) Since the cabling distance between buildings RAVI, GANGA and JAMUNA are quite large, so a repeater, would ideally be needed along their path to avoid loss of signals during the course of data flow in these routes.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(209-4)
(2) In the layout a switch would be needed in all the building, to interconnect the group of cables from the different computers in each building.
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(210-1)
(iv) Optical fibre.

Question 11:
Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as shown in the diagram given below :
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(210-2)
Distances between various buildings are as follows:

Accounts to Research Lab55 m
Accounts to Store150 m
Store to Packaging Unit160 m
Packaging Unit to Research Lab60 m
Accounts to Packaging Unit125 m
Store to Research Lab180 m

Number of computers

Accounts25
Research Lab100
Store15
Packaging Unit60

As a network expert, provide the best possible answer for the following queries :

  1. Suggest a cable layout of connections between the buildings.
  2. Suggest the most suitable place (i.e. buildings) to house the server of this origanization.
  3. Suggest the placement of the following device with justification :
    (a) Repeater
    (b) Switch/Hub
  4. Suggest a system (hardware/sofware) to prevent unauthorized access to or from the network.

Answer:
(i) Layout 1
ncert-solutions-for-class-12-computer-science-c-networking-and-open-source-concepts-(210-3)
(ii) The most suitable place/building to house the server of this organization would be in Research Lab, building as this building contains the maximum number of computers.
(iii) (a) For layout I, since the cabling distance between Accounts to Store is quite large, so a repeater would ideally be needed along their path to avoid loss of signals during the course of data flow in this route. For layotat2, since the cabling distance between Store to Research Lab is quite large, so a repeater would ideally be placed.
(b) In both the layouts, a Flub/Switch each would be needed in all the buildings to interconnect the group of cables from the different computers in each building.
(iv) Firewall

Question 12:
Who is a hacker ?
Answer:
A computer enthusiast, who uses his computer . programming skills to intentionally access a computer without authorization is known as hacker. A hacker accesses the computer without the intention of destorying data or maliciously harming the computer.

Question 13:
The following is a 32 bit binary number usually represented as 4 decimal values, each representing 8 bits, in the range 0 to 255 (know as octets) separated by decimal points. 140.179.220.200
What is it? What is its importance?
Answer:
It is an IP Address. It is used to identify the computers on a network.

TOPIC-2
Network Security and Web Service

Very Short Answer Type Questions [1 mark each]

Question 1:
Define firewall.
Answer:
A system designed to prevent unauthorized access to or from a private network is called firewall. It can be implemented in both hardware and software or combination of both.

Question 2:
Write any two examples of Server side Scripts.
Answer:

  1. ASP
  2. PHP

Question 3:
What is the difference between E-mail & chat?
Answer:

  1. Chat occurs in near real time, while E-mail doesn’t.
  2. Chat is a 2-way communication which require the permission of both parties, while E-mail is a 1-way communication.

Question 4:
Write names of any two popular open source software, which are used as operating systems.
Answer:

  1. Kernels
  2. Unix
  3. Linux

Question 5:
What is the difference between video conferencing and chat.
Answer:
In conference, we can include more than one person and it allows text, video and audio while chat is one-to-one communication.

Question 6:
Expand the following abbreviations :

  1. HTTP
  2. VOIP

Answer:

  1. HTTP-Hyper Text Transfer Protocol.
  2. VOIP-Voice Over Internet Protocol.

Question 7:
What is the difference between HTTP and FTP?
Answer:
Hyper Text Transfer Protocol deals with Transfer of Text and Multimedia content over internet while FTP (File Transfer Protocol) deals with transfer of files over the internet.

Question 8:
What out of the following, will you use to have an audio-visual chat with an expert sitting in a far-away place to fix-up a technical issue ?

  1. VOIP
  2. Email
  3. FTP

Answer:
(i) VOIP

Question 9:
Name one server side scripting language and one client side scripting language.
Answer:
Client Side :

  1. JAVASCRIPT
  2. VBSCRIPT

Server Side :

  1. ASP
  2. JSP

Question 10:
Which out of the following comes under cyber crime ?

  1. Operating someone’s internet banking account, without his knowledge.
  2. Stealing a keyboard from someone’s computer.
  3. Working on someone’s Computer with his/ her permission.

Answer:
(i) Operating someone’s internet banking account, without his knowledge.

Question 11:
Name two proprietary softwares along with their application.
Answer:

  1. MS-Office – All office applications MS-Word, MS-Excel, MS-PowerPoint.
  2. Visual Studio – Visual Basic, Visual C+ + softwares for application development.

Question 12:
Name some cyber offences under the IT Act.
Answer:

  1. Tampering with computer source documents
  2. Hacking.
  3. Publishing of information which is obscene in electronic form.

Question 13:
What are the 3 ways of protecting intellectual property ?
Answer:

  1. Patents
  2. Copyrights
  3. Trademark

Question 14:
When a user browses a website, the web server sends a text file to the web browser. What is the name of this ?
Answer:
Cookies.

Short Answer Type Questions – I [2 mark each]

Question 1:
Define the following :

  1. Firewall
  2. VoIP

Answer:
(i) Firewall : A system designed to prevent unauthorized access to or from a private network is called firewall. It can be implemented in both hardware and software or combination of both.
(ii) VoIP : Voice -over-Internet Protocol(VoIP) is a methodology and group of technologies for delivering voice communications and multimedia sessions over Internet Protocol(IP) networks, such as the Internet.

Question 2:
Give the full form of the following terms.

  1. XML
  2. FLOSS
  3. HTTP
  4. FTP

Answer:

  1. XML: Extensible Markup Language.
  2. FLOSS: Free-Libre Open Source Software.
  3. HTTP: Hyper Text Transfer Protocol.
  4. FTP: File Transfer Protocol.

Question 3:
Differentiate between WORM and VIRUS in Computer terminology.
Answer:
VIRUS directly effects the system by corrupting the useful data. A computer virus attaches itself to a program or file enabling it to spread from one computer to another.
A worm is similar to a virus by design and is considered to be sub class of a virus. Worm spread from computer to computer, but unlike a virus, it has the capability to travel without any human action.

Abbrevations :
Question 4:
Expand the following

  1. GSM
  2. GPRS.

Answer:

  1. GSM : Global System for Mobile Communication.
  2. GPRS : General Packet Radio Service.

Question 5:
Expand the following abbreviations :

  1. HTTP
  2. VOIP

Answer:

  1. HTTP : Hyper Text Transfer Protocol.
  2. VOIP : Voice Over Internet Protocol.

Question 6:
Give the full form of :

  1. FOSS
  2. HTTP

Answer:

  1. FOSS : Free Open Source Software.
  2. HTTP : Hyper Text Transfer Protocol.

Question 7:
Write the full forms of the following :

  1. GNU
  2. XML

Answer:

  1. GNU : GNU’s Not Unix
  2. XML : Extensible Markup Language.

Question 8:
Expand the following terminologies :

  1. GSM
  2. WLL

Answer:

  1. GSM : Global System for Mobile Communication
  2. WLL : Wireless Local Loop.

Question 9:
Give the full forms of the following terms :

  1. CDMA
  2. TDMA
  3. FDMA

Answer:

  1. CDMA : Code Division Multiple Access
  2. TDMA : Time Division Multiple Access
  3. FDMA : Frequency Division Multiple Access

Question 10:
Expand the following abbreviations :

  1. FTP
  2. TCP
  3. SMTP
  4. VOIP

Answer:

  1. FTP : File Transfer Protocol
  2. TCP : Transmission Control Protocol.
  3. SMTP : Simple Mail Transfer Protocol.
  4. VOIP : Voice Over Internet Protocol.

Short Answer Type Questions-II [3 marks each]

Question 1:
Give two examples of PAN and LAN type of networks.
Answer:

PANLAN
(i) Personal Area Network
(ii) Spans a few meters
Example :
Bluetooth using 2 moblies and laptops sharing files.
(i) Local Area Network
(ii) Spans upto a km.
Example :
System in a lab in a school, systems at home.

Question 2:
Which protocol helps us to browse through web pages using internet browsers ? Name any one internet browser.
Answer:
HTTP
Google Chrome is a browser

Question 3:
Write two advantages of 4G over 3G Mobile Telecommunication Technologies in terms of speed and services.
Answer:
4G has very high data rates upto 100 Mbps.
It covers a wider lange than 3G

Question 1:
Write two characteristics of Web 2.0
Answer:
Web 2.0

  1. dynamic and interactive websites
  2. Only the changed part is reloaded so faster
Read More

Chapter 7: Boolean Algebra | NCERT Solution for class 12th COMPUTER SCIENCE

NCERT Solutions for Class 12 Computer Science (C++) – Boolean Algebra

TOPIC-1
Basics of Boolean Algebra

Very Short Answer Type Questions    [1 mark each]

Question 1:
Which gates are known as universal gates ? Why?
Аnswer:
Universal gates are the ones which can be used for implementing any gate like AND, OR and NOT or any combination of these basic gates. NAND and NOR gates are universal gates.

Question 2:
Draw the equivalent logic circuit for the following Boolean expression :
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(178-1)

Question 3:
Express the OR operator in terms of AND and NOT operator.
Аnswer:
(A . B)’ = \(\overline { A }\) + \(\overline { B }\)
(\(\overline { A }\) + \(\overline { B }\))’ = A + B

Question 4:
Specify which axioms/theorems are being used in the following Boolean reductions :
(a) (be)’ + be = 1
(b) xyz + zx = xz
Аnswer:
(a) x + x’ = 1 & Complementary law
(b) y + x = x & Absorption law.

Question 5:
State and verify Associative law using Truth Table.
Аnswer:
Associative Law: This law states that:
(A + B) + C = A + (B + C)
(A.B).C = A. (B.C)
Proof:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(178-2)
∴ From above truth table,
(A + B) + C = A + (B + C)
Similarly, we can prove,
A. (B.C) = (A. B).C
ncert-solutions-class-12-computer-science-c-boolean-algebra-(179-1)

Short Answer Type Questions-I    [2 mark each]

Question 1:
Correct the following boolean statements :
1. X+1 = X
2. (A’)’ = A’
3.  A+A’ = 0
4.  (A+B)’ = A.B
Аnswer:
1. X+l=l or X+0=X
2. ((A’)’) = A
3. A + A’ = 1 or A. A’ = 0
4. (A 4- B)’ = A’.B1

Question 2:
Write the POS form of a Boolean Function F, which is represented in a truth table as follows :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(179-2)
Аnswer:
(P+Q+R).(P’+Q+R).(P’+Q’+R)

Short Answer Type Questions-II  [3 mark each]

Laws and Theorems
Question 1:
State and Verify Absorption law algebraically.
Аnswer:
Absorption law states that :
A + AB = A and A. (A + B) = A
Algebraic method :
Taking LHS
A + AB = (A.l) + (A.B) by Identity
= A. (1 + B) by Distribution
= A.l by Null Element
= A

Question 2:
State and define principle of duality. Why is it so important in Boolean Algebra ?
Аnswer:
Principle of duality : Duality principle states that from every boolean relation another boolean relation can be derived by :
(i) Changing each OR sign (+) to an AND sign (-).
(ii) Changing each AND sign (-) to an OR sign (+)
ex : Dual of A + A’B = A. (A’ + B)
Importance in Boolean Algebra : The principle of duality is an important concept in Boolean algebra, particularly in proving various theorems. The principle of duality is used extensively in proving Boolean algebra theorem. Once we prove that an expression is valid, by the principle of duality, its dual is also valid. Hence, our effort in proving various theorems is reduced to half.

Question 3:
Name the law shown below & verify it using a . truth table.
X+ \(\overline { X }\).Y = X + Y.
Аnswer:
This law is called “Absorption Law” also referred as redundance law.
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-1)

Question 4:
Draw a logic circuit for the following Boolean expression : ab + c.d’.
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-2)

Question 5:
Write the SOP form of a Boolean function F, which is represented in a truth table as follows :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-3)
Аnswer:
A’B’C + A’BC + AB’C + AB’C

Question 6:
Draw the Logic Circuit for the following Boolean Expression :
(U + V). w + z
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-4)

Question 7:
Verify the following using Boolean Laws :
LT + V = LTV + LP.V + U.V
Аnswer:
L.H.S.
= U’ + V
= U’ . (V + V) + V (LP + U)
= U’ . V + LP . V + U . V + U. V
= U’. V + LP. V + U. V
= R.H.S.

OR

R.H.S.
= U’V’ + U’. V + U. V
= LP . (V + V) + U. V
= U’ 1 + U.V
= U’ + U.V
= U’ +V
= L.H.S.

Question 8:
Draw the Logic Circuit for the following Boolean Expression :
(X’ + Y). Z + W’
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-5)

Question 9:
Write the equivalent boolean expression for the following logic circuit.
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-6)
Аnswer:
((X’.Y)’ + (X.Y’)’)’

Question 10:
Write the equivalent Boolean Expression for the. following Logic Circuit :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(180-7)
Аnswer:
Z = (A+B)(B’ +C)
= A.B’ + AC + B.B’ + BC
= A.B’ + AC + BC

Question 11:
Obtain the Boolean Expression for the logic circuit shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-1)
Аnswer:
F = \(\left( \overline { A } .B \right) +\left( \overline { C+\overline { D } }\right)\)
= \(\left( \overline { A } .B \right) +\overline { C } .D\)

Question 12:
Name the law shown below & verify it using a truth table.
A + B . C = (A + B). (A + C).
Аnswer:
This law is called “Distributive Law”.
Prove by Truth table
ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-2)

Question 13:
Obtain the Boolean Expression for the logic circuit shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-3)
Аnswer:
F = ( X.\(\overline { Y }\) ) + ( \(\overline { Z }\) + W).
F = \(\overline { X }\) + Y + \(\overline { Z }\) + W.

Question 14:
State Demorgan’s law. Verify one of them using truth table.
Аnswer:
There are two Demorgan’s law :
(i)  \(\overline { A.B }\) = \(\overline { A }\) + \(\overline { B }\)
(ii)  \(\overline { A+B }\) = \(\overline { XA}\) . \(\overline { B }\)
Proof :
(i)  \(\overline { A.B }\) = \(\overline { A }\) + \(\overline { B }\)

ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-4)

Question 15:
Draw a logic Circuit for the boolean expression:
A . \(\overline { B }\) + (C + \(\overline { B }\)). \(\overline { A }\)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-5)

Question 16:
Obtain the Boolean Expression for the logic circuit shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(181-6)
F = P’ Q + (Q + R’)
= Q. (P’ + R’)

Question 17:
Verify the following using Boolean Laws X + Z = X + X’. Z + Y. Z
Аnswer:
Taking RHS
X + X’Z + YZ
= (X + X’). (X + Z) + YZ (Distribution Law)
= 1. (X + Z) + YZ    (A + A’ = 1)
= X + Z + YZ
= X + Z (1 + Y)
= X + Z    (1 + A = 1; 1. A = A)
= Hence verified

Question 18:
Verify the following using Boolean Laws : A + C = A + A. C + B.C
Аnswer:
A + C = A + A’.C + BC
Solve RHS
A + A’C + BC
(A + A). (A + C) + BC [Using distributive law]
1. (A + C) + BC
= A + C + BC
= A + C(1 + B)
= A + C.1
= A + C
= LHS (Hence, verified)

Question 19:
Obtain the Boolean Expression for the logic circuit shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-1)
Expression at F :
( \(\overline { X }\) . Y) + (Y + \(\overline { Z }\) )
( \(\overline { X }\) + 1) Y + \(\overline { Z }\)    [Distributive law]
Y + \(\overline { Z }\)    [ ∴ 1 + Z = 1]

Question 20:
Verify the following using truth table :
(i) X . X’ = 0
(ii) X + 1 = 1
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-2)

Question 21:
Write the equivalent boolean expression for the following logic circuit :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-3)
Аnswer:
Y = U \(\overline { V }\) + \(\overline { U}\) \(\overline { W }\)

Question 22:
Write the equivalent boolean expression for the following logic circuit :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-4)
Аnswer:
Y = (U + \(\overline { V }\) ). (U + \(\overline { W }\) )

Question 23:
Verify the following using truth table :
(i) X + 0 = X
(ii) X + X’ = 1
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-5)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-6)

Question 24:
Derive a Canonical SOP expression for a Boolean function F, represented by the following truth table :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-7)
Аnswer:
F(A, B, C) = A’B’C + A’BC + AB’C + ABC
OR
F(A,B,C) =∑(0, 3,4,7)

Question 25:
Derive a Canonical POS expression for a Boolean function F, represented by the following truth table :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(182-8)
Аnswer:
F(RQ,R) = (P+Q+R’)(P+Q,+R)(P’+Q,+R’) (P’+Q’+R)
OR
F(RQ,R)=II(1,2,5,6)

Question 26:
Obtain a simplified form for a Boolean expression :
F(U, V, W, Z) = II (0,1,3,5, 6, 7,15)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(183-1)
(u + v + w).(u+z’).(v’+w’).(u’+w’+z)

Question 27:
Reduce the following Boolean Expression to its simplest form using K-Map :
F (X, X Z, W) = X (0,1, 6, 8, 9,10,11,12,15)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(183-2)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(183-3)
Simplified Expression : XY + Y’Z’ + XZ’W’ + XZW + X’YZW’

Question 28:
Reduce the following Boolean Expression to its simplest form using K-Map :
F(X, Y, Z, W) = X (0,1,4, 5,6, 7,8, 9,11,15)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(183-4)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(184-1)
Simplified Expression : Y’Z’ + XY + XZW

Question 29:
Verify the following using Boolean Laws.
X + Y’ = X. Y + X. Y + X’. Y
Аnswer:
L. H. S.
= X + Y’
= X. (Y+Y’) + (X + X’). Y’
= X. Y + X. Y’ + X. Y’ + X’. Y’
= X. Y + X. Y’ + X’. Y’
= R. H. S
OR
= X. Y + X. Y’ + X’. Y’
= X. (Y + Y’) + X’. Y’
= X. 1 + X’. Y’
= X + X’. Y’
= X + Y
= L. H. S

Question 30:
State Distributive law and verify it using truth table.
Аnswer:
Distributive law : This law states that
(i) x(y + z) = xy + x.z.
(ii) x + yz = (x + y)(x + z)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(184-2)

Question 31:
Reduce the following Boolean Expression using KMap :
F(A, B, C, D) = ∑{0,1,3, 5, 6, 7,9,11,13,14,15}
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(184-3)
A’B’C’+D+BC

TOPIC-2
Karnaugh Map Minimization and Applications of Boolean Algebra

Very Short Answer Type Questions [1 mark each]

Question 1:
Write Product of Sum expression of the function F (a, b, c, d) from the given truth table
ncert-solutions-class-12-computer-science-c-boolean-algebra-(186-1)
Аnswer:
F (a, b, c, d) =
(a + b + c + d).(a + b + c + d’). (a + b’ + c + d) . (a + b’ + c’ + d’). (a’ + b + c + d).
(a’ + b + c + d’). (a’ + b’ + c + d). (a’ + b’ + c + d’) . (a’ + b’ + c’ + d)

Question 2:
Convert the following boolean expression inti! its equivalent Canonical Sum of Products form (SOP) :
(U + V + W) (U + V + W’) (U’ + V + W) (U’ + V’ + W’)
Аnswer:
π (0,1, 4, 7)
∑(2, 3, 5, 6)
010 011 101 110
= U’VW’ + U’VW + UV’W + UVW’

Question 3:
Write the Sum of Product form of the function F(R Q, R) for the following truth table representation of F :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(186-2)

Question 4:
Write the Product of Sum form of the function F(X, Y, Z) for the following truth table representation of F :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(186-3)

Question 5:
Write the Product of Sum form of the function G(U, V W) for the following truth table representation of G :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(186-4)

Question 6:
Write the Product of Sum form of function G(U, V, W) for the following truth table representation of G :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(186-5)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-1)

Question 7:
Write the Sum of Product form of the function F(A, B, C) for the following truth table reprsentation of
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-2)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-3)
SOP = A’BC’ + A’BC + AB’C’ + ABC

Question 8:
Write the SOP form of a boolean function F, which is represented in a truth table as follows:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-4)
Аnswer:
F(X, Y, Z) = X’.Y’. Z’ + X’. Y. Z’ + X. Y’. Z’+ X.Y.Z

Question 9:
Write the POS form of boolean function G, which is represented in a truth table as follows :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-5)
Аnswer:
G (A, B, C) = (A + B + C). (A + B’ + C’). (A’ + B + C). (A’ + B + C’)

Short Answer Type Questions-II

Question 1:
Obtain the minimal SOP form for the following Boolean expression using K-Map.
F(A,B,C,D) = ∑ (0,2,3,5,7,8,10,1143,15)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(187-6)
Quad 1 = m0 + m2 + m8 + m10 = B’D’
Quad 2 = m3 + m7 + m15 + m11 = CD
Quad 3 = m5 + m7 + m15 + m13 = BD
Minimal SOP = B’D’ + CD + BD

Question 2:
Reduce the following Boolean expression using
K-Map :
F(A,B,C,D) = 7r (0,1,2,4,5,6,8,10)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(188-1)
F(A, B, C, D) = π(0,1,2,4, 5, 6,8,10) F = (A + C).(A + D).(B + D)

Question 3:
Reduce the following using K-Map :
F (A, B,C,D) = ∑(1,3,4,5,6,7,12,13)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(188-2)

Question 4:
Reduce the following boolean expression using
K-map.
F(EQ,R,S) = 2(0,2,4,5,6,7,8,10,13,15).
Аnswer:
\(\overline { P }\) Q + \(\overline { Q }\)\(\overline { S }\) + QS.
ncert-solutions-class-12-computer-science-c-boolean-algebra-(188-3)

Question 5:
Reduce the following Boolean Expression using K-Map :
F(P, Q, R, S) = ∑(1,2, 3,4,5, 6, 7, 8,10)
Аnswer:
ncert-solutions-class-12-computer-science-c-boolean-algebra-(188-4)
F(P, Q, R, S) = P’Q + P’S + P’R’S’ + PQ’S’

Question 6:
Reduce the following Boolean Expression using
K-Map :
F (A, B, C, D) = ∑(2, 3,4,5, 6, 7,8,10,11)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(188-5)
F (A, B, C, D) = A’B + A’C + B’C + ABD’

Long Answer Type Questions [4 marks each]

Question 1:
Verify the following using Boolean Laws :
[Delhi, 2016]
A ‘ + B’ . C=A’ . B ‘ . C ‘ + A’ . B . C ‘ + A’ .B.C + A’ .B’ .C+ A.B’ .C
Аnswer:
A’+ B’C = A’B’C’ + A,BCI + A’BC’ + A’BC + A’B’C + ABC
=A’C'(B’+B)+A’C (Grouping)
(B+B’)+AB’C
=> A’C’+ A’C + AB’C
(x+x’y=x+y)
=> A’ (C+C’ ) +AB’ C
=> A’+AB’C
(x+x’=1)
=> A’+B’C
X=A’ y=B’C
= LHS
Hence Proved.

Question 2:
Write the Boolean Expression for the result of the Logic Circuit as shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(189-1)
Аnswer:
F = (u+v’).(u+w).(v+w’)

Question 3:
Derive a Canonical POS expression for a Boolen function F, represented by the following truth table :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(189-2)
Аnswer:
F = ∑(0, 3,4,5)
= (P + Q + R) (P + Q’ + R’) (P’ + Q + R) (P’ + Q + R’)

Question 4:
Reduce the following Boolean Expression to its simplest form using K-Map :
F (X, Y, Z, W)
∑(2,6,7,8,9,10,11,13,14,15)
Аnswer:
∑(2,6,7,8,9,10,11,13,14,15)
ncert-solutions-class-12-computer-science-c-boolean-algebra-(189-3)
F = XY’ + ZW’+ XW + YZ

Question 5:
Write the Boolean Expression for the result of the Logic Circuit as shown below :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(189-4)
Аnswer:
G = PQ’ + PR + QR’

Question 6:
Derive a Canonical SOP expression for a Boolean function G, represented by the following truth table :
ncert-solutions-class-12-computer-science-c-boolean-algebra-(189-5)
Аnswer:
G = ∑{(0,2,6,7)
= A’B’C’ + A’BC’ + ABC’ + ABC

Question 7:
Verify the following using Boolean Laws :
X’+ Y’Z = X’ .Y’ .Z’+X’ .Y.Z’+X’ .Y.Z+X’ .Y’ .Z + X.Y’.Z.
Аnswer:
X ‘+Y’ Z=X ‘ Y ‘ Z ‘ +X ‘ YZ ‘ +X ‘ YZ+X ‘ Y ‘ Z+XY ‘ Z
Taking RHS
Grouping terms
=> x’Z’ (Y’+Y)+X’ Z(Y+Y’)+XY’Z
=> X’Z’+X’Z+XY’Z
(Y+Y’=1)
=> X'(Z’+Z)+XY’Z
(Grouping)
=> X’+XY’Z (Z+Z’=l)
=> X’+Y’Z (Substitute X=X’ Y=Y’Z X+X’ Y = X+Y)
= LHS

Read More

Chapter 6: Database & SQL | NCERT Solution for class 12th COMPUTER SCIENCE

Class 12 Computer Science Chapter 6: Database & SQL



• Database is a collection of related tables. MySQL is a ‘relational’ DBMS.

• DDL (Data Definition Language) includes SQL statements such as, Create table, Alter table and Drop table.

• DML (Data Manipulation Language) includes SQL statements such as, insert, select, update and delete.

• A table is a collection of rows and columns, where each row is a record and columns describe the feature of records.

• ALTER TABLE statement is used to make changes in the structure of a table like adding, removing or changing datatype of column(s).

• UPDATE statement is used to modify existing data in a table.

• WHERE clause in SQL query is used to enforce condition(s).

• DISTINCT clause is used to eliminate repetition and display the values only once.

• The BETWEEN operator defines the range of values inclusive of boundary values.

• The IN operator selects values that match any value in the given list of values.

• NULL values can be tested using IS NULL and IS NOT NULL.

• ORDER BY clause is used to display the result of a SQL query in ascending or descending order with respect to specified attribute values. By default the order is ascending.

• LIKE operator is used for pattern matching. % and _ are two wild card characters. The per cent (%) symbol is used to represent zero or more characters. The underscore (_) symbol is used to represent a single character.

• A Function is used to perform a particular task and return a value as a result.

• Single Row functions work on a single row of the table and return a single value.

• Multiple Row functions work on a set of records as a whole and return a single value. Examples include COUNT, MAX, MIN, AVG and SUM.

• GROUP BY function is used to group rows of a table that contain the same values in a specified column.

• Join is an operation which is used to combine rows from two or more tables based on one or more common fields between them.


1. Answer the following questions:

a) Define RDBMS. Name any two RDBMS software.

Answer: RDBMS stands for Relational Database Management System. An RDBMS is a DBMS designed especially for relational databases, which provide the facility to store and manage large amount of data. It allows to store the data in structured format using rows and columns.

Two RDBMS Software are – MySQL, Oracle

b) What is the purpose of the following clauses in a select statement?

i) ORDER BY

ii) GROUP BY

Answer     (i) ORDER BY – ORDER BY clause is used with SELECT statement, to arranges the result of an SQL query in either ascending or descending on the basis of particular columns (fields).

(ii) GROUP BY – The GROUP BY clause is used in SELECT statement, to divide the table into groups i.e combines all records that have identical values in a particular field.

Grouping can be done by a common column name or with aggregate functions in which case the aggregate produces a value for each.

For example :

mysql> SELECT GENDER, COUNT(*) FROM STUDENT GROUP BY GENDER;

OUTPUT:

GENDER COUNT(*)

MALE 20

FEMALE 15


c) Site any two differences between Single-row functions and Aggregate functions.

Answer   : Single Row Functions and Aggregate Functions

  • Single Row Function applied on the each row while Aggregate Functions applied on the group of rows.
  • Single Row Functions return multiple output i.e. output based on each row while Aggregate function returns only one result i.e. output based on group of rows.

d) What do you understand by Cartesian Product?

Answer : A Cartesian product combines the tuples of one relation with all the tuples of the other relation. It is created when two tables are joined without any join condition.

e) Differentiate between the following statements :

i) ALTER and UPDATE ii) DELETE and DROP

i) ALTER and UPDATE

Answer : The ALTER TABLE is a DDL command used to make changes in the structure of a table, such as, adding or deleting a column, modifying the definition of a column, adding / deleting / modifying constraints. It can also used to RENAME the table.

The UPDATE is a DML command used to modify the data stored in a table, such as modifying records or updating records.

ii) DELETE and DROP

Answer : DELETE is a DML command, which is used to remove tuples / records from a table. Delete command will delete only records not a table.

DROP is a DDL command, which is used to remove table, database and views. It deletes entire table including records.

If DROP is used with ALTER TABLE command then it is use to delete/remove column, constraint.


f) Write the name of the functions to perform the following operations:

i) To display the day like “Monday”, “Tuesday”, from the date when India got independence.

Answer :  DAYNAME( )

ii) To display the specified number of characters from a particular position of the given string.

Answer :  MID( ) or SUBSTRING( )

iii) To display the name of the month in which you were born.

Answer :  MONTHNAME( )

iv) To display your name in capital letters.

Answer :  UCASE( ) or UPPER( )


2. Write the output produced by the following SQL commands:

a) SELECT POW(2,3);

sql pow function

b) SELECT ROUND(123.2345, 2), ROUND(342.9234,-1);

c) SELECT LENGTH(“Informatics Practices”);

d) SELECT YEAR(“1979/11/26”), MONTH(“1979/11/26”), DAY(“1979/11/26”), MONTHNAME(“1979/11/26”);

e) SELECT LEFT(“INDIA”,3), RIGHT (“Computer Science”,4);

f) SELECT MID(“Informatics”,3,4), SUBSTR(“Practices”,3);



3. Consider the following MOVIE table and write the SQL queries based on it.

MovieIDMovieNameCategoryReleaseDateProductionCostBusinessCost
001Hindi_MovieMusical2018-04-23124500130000
002Tamil_MovieAction2016-05-17112000118000
003English_MovieHorror2017-08-06245000360000
004Bengali_MovieAdventure2017-01-0472000100000
005Telugu_MovieActionNULL100000NULL
006Punjabi_MovieComedyNULL30500NULL

Table : Movie

a) Display all the information from the Movie table.

Answer : SELECT * FROM MOVIE;

b) List business done by the movies showing only MovieID, MovieName and Total_Earning. Total_Earning to be calculated as the sum of ProductionCost and BusinessCost.

Answer : SELECT MovieID, MovieName, ProductionCost + BusinessCost as “Total_Earning” FROM MOVIE;

c) List the different categories of movies.

Answer : SELECT DISTINCT Category FROM MOVIE;

OR

SELECT DISTINCT(Category) FROM MOVIE;

d) Find the net profit of each movie showing its MovieID, MovieName and NetProfit. Net Profit is to be calculated as the difference between Business Cost and Production Cost.

Answer : SELECT MovieID, MovieName, BusinessCost – ProductionCost as “Net Profict” FROM MOVIE;

e) List MovieID, MovieName and Cost for all movies with ProductionCost greater than 10,000 and less than 1,00,000.

Answer : SELECT MovieID, MovieName, ProductionCost FROM MOVIE WHERE ProductionCost > 10000 and ProductionCost < 100000;

f) List details of all movies which fall in the category of comedy or action.

Answer : SELECT * FROM MOVIE WHERE Category IN (‘Comedy’, ‘Action’);

g) List details of all movies which have not been released yet.

Answer : SELECT * FROM MOVIE WHERE ReleaseDate IS NULL;

4. Suppose your school management has decided to conduct cricket matches between students of Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team Titan, Team Rockers, Team Magnet and Team Hurricane. During summer vacations, various matches will be conducted between these teams. Help your sports teacher to do the following:

a) Create a database “Sports”.

Answer : CREATE DATABASE Sports;

b) Create a table “TEAM” with following considerations:

i) It should have a column TeamID for storing an integer value between 1 to 9, which refers to unique identification of a team.

ii) Each TeamID should have its associated name (TeamName), which should be a string of length not less than 10 characters.

Answer : CREATE TABLE TEAM (TeamID INTEGER CHECK (TeamID BETWEEN 1 AND 9), TeamName VARCHAR(30) CHECK(Length (TeamName) >= 10) )

c) Using table level constraint, make TeamID as the primary key.

Answer : CREATE TABLE TEAM (TeamID INTEGER CHECK (TeamID BETWEEN 1 AND 9), TeamName VARCHAR(30) CHECK(Length (TeamName) >= 10), PRIMARY KEY(TeamID) );

d) Show the structure of the table TEAM using a SQL statement.

Answer : DESC TEAM;

e) As per the preferences of the students four teams were formed as given below. Insert these four rows in TEAM table:

Row 1: (1, Team Titan)
Row 2: (2, Team Rockers)
Row 3: (3, Team Magnet)
Row 3: (4, Team Hurricane)

Answer : INSERT INTO TEAM VALUES (1, ‘Team Titan’);

INSERT INTO TEAM VALUES (2, ‘Team Rockers’);

INSERT INTO TEAM VALUES (1, ‘Team Magnet’);

INSERT INTO TEAM VALUES (1, ‘Team Hurricane’);

f) Show the contents of the table TEAM using a DML statement.

Answer : SELECT * FROM TEAM;

g) Now create another table MATCH_DETAILS and insert data as shown below. Choose appropriate data types and constraints for each attribute.

Table: MATCH_DETAILS

MatchIDMatchDateFirstTeamIDSecondTeamIDFirstTeamScoreSecondTeamScore
M12018-07-17129086
M22018-07-18344548
M32018-07-19137856
M42018-07-19245667
M52018-07-1814  3287
M62018-07-17236751

Table: MATCH_DETAILS

Answer : CREATE TABLE MATCH_DETAILS (

MatchId CHAR(2) NOT NULL PRIMARY KEY,

MatchDate DATE,

FirstTeamID INTEGER REFERENCES Team( TeamID),

SecondTeamID INTEGER REFERENCES Team(TeamID),

FirstTeamScore INTEGER,

SecondTeamScore INTEGER

);


5. Using the sports database containing two relations (TEAM, MATCH_DETAILS) and Write the queries for the following:

a) Display the MatchID of all those matches where both the teams have scored more than 70.

Answer : SELECT MatchID FROM MATCH_DETAILS WHERE FirstTeamScore > 70 AND SecondTeamScore > 70;

b) Display the MatchID of all those matches where FirstTeam has scored less than 70 but SecondTeam has scored more than 70.

Answer : SELECT MatchID FROM MATCH_DETAILS WHERE FirstTeamScore < 70 AND SecondTeamScore < 70;

c) Display the MatchID and date of matches played by Team 1 and won by it.

Answer : SELECT MatchID, MatchDate FROM MATCH_DETAILS WHERE (FirstTeamId = 1 AND FirstTeamScore > SecondTeamScore) OR (SecondTeamID = 1 AND SecondTeamScore > FirstTeamScore) ;

d) Display the MatchID of matches played by Team 2 and not won by it.

Answer : SELECT MatchID FROM MATCH_DETAILS WHERE SecondTeamScore < FirstTeamScore AND (FirstTeamID = 2 OR SecondTeamID = 2) ;

e) Change the name of the relation TEAM to T_DATA. Also change the attributes TeamID and TeamName to T_ID and T_NAME respectively.

Answer : ALTER TABLE TEAM RENAME TO T_DATA;

ALTER TABLE T_DATA CHANGE TeamID T_ID INTEGER;

ALTER TABLE T_DATA CHANGE TeamName T_Name VARCHAR(30) ;


6. A shop called Wonderful Garments who sells school uniforms maintains a database SCHOOLUNIFORM as shown below.

It consisted of two relations – UNIFORM and COST. They made UniformCode as the primary key for UNIFORM relations. Further, they used UniformCode and Size to be composite keys for COST relation. By analyzing the database schema and database state, specify SQL queries to rectify the following anomalies.

a) M/S Wonderful Garments also keeps handkerchiefs of red colour, medium size of Rs. 100 each.

b) INSERT INTO COST (UCode, Size, Price) values (7, ‘M’,100);

When the above query is used to insert data, the values for the handkerchief without entering its details in the UNIFORM relation is entered. Make a provision so that the data can be entered in the COST table only if it is already there in the UNIFORM table.

Answer : To overcome this anomalies, you need to create a foreign key constraint in cost table. Here UCode of cost table get related with the UniformCode Primary Key of Uniform table.

ALTER TABLE COST
ADD FOREIGN KEY (UCode) REFERENCES UNIFORM(UniformCode);

c) Further, they should be able to assign a new UCode to an item only if it has a valid UName. Write a query to add appropriate constraints to the SCHOOLUNIFORM database.

Answer : To overcome this this problem, you need to specify NOT NULL Constaint to UName column of UNIFORM table. So that you always suppose to enter valid name to uniform, while adding a record in a table.

ALTER TABLE UNIFORM
MODIFY UName VARCHAR(30) NOT NULL;

d) Add the constraint so that the price of an item is always greater than zero.

Answer : Add a CHECK constraint on price filed of COST table.

ALTER TABLE COST
ADD CONSTRAINT CHECK(Price > 0);



7. Consider the following table named “Product”, showing details of products being sold in a grocery shop.

Write SQL queries for the following:

a) Create the table Product with appropriate data types and constraints.

b) Identify the primary key in Product.

Answer: PCode

c) List the Product Code, Product name and price in descending order of their product name. If PName is the same then display the data in ascending order of price.

Answer:  SELECT PCODE, PNAME, UPRICE

             FROM PRODUCT

            ORDER BY PNAME DESC, UPRICE ASC;

d) Add a new column Discount to the table Product.

Answer:  ALTER TABLE PRODUCT ADD DISCOUNT DECIMAL (10,2);

e) Calculate the value of the discount in the table Product as 10 per cent of the UPrice for all those products where the UPrice is more than 100, otherwise the discount will be 0.

Answer:

mysql> UPDATE PRODUCT SET DISCOUNT = UPRICE * 0.10

            WHERE UPRICE > 100;

f) Increase the price by 12 per cent for all the products manufactured by Dove.

Answer:

mysql> UPDATE PRODUCT

            SET UPRICE = UPRICE + UPRICE * 0.12

          WHERE MANUFACTURER = ‘DOVE’;

g) Display the total number of products manufactured by each manufacturer.

Answer:

mysql > SELECT MANUFACTURER, COUNT(*)

          -> FROM PRODUCT

          -> GROUP BY MANUFACTURER;

Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product:

h. SELECT PName, Avg(UPrice) FROM Product GROUP BY Pname;

i. SELECT DISTINCT Manufacturer FROM Product;

j. SELECT COUNT(DISTINCT PName) FROM Product;

k. SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;


a) Add a new column Discount in the INVENTORY table.

Answer: ALTER TABLE INVENTORY ADD DISCOUNT DECIMAL(10,2);

b) Set appropriate discount values for all cars keeping in mind the following:

(i) No discount is available on the LXI model.

(ii) VXI model gives a 10% discount.

(iii) A 12% discount is given on cars other than LXI model and VXI model.

Answer: (I)     UPDATE INVENTORY   SET DISCOUNT = NULL  WHERE MODEL = ‘LXI’;

(II)    UPDATE INVENTORY SET DISCOUNT = PRICE * 0.10 WHERE MODEL = ‘VXI’;

(II)    UPDATE INVENTORY SET DISCOUNT = PRICE * 0.12 WHERE MODEL NOT IN (‘LXI’, ‘VXI’)

c) Display the name of the costliest car with fuel type “Petrol”.

Answer: SELECT CARNAME FROM INVENTORY WHERE PRICE = (SELECT MAX(PRICE)    FROM INVENTORY WHERE FUELTYPE = ‘PETROL’ );

d) Calculate the average discount and total discount available on Car4.

Answer: SELECT AVG(DISCOUNT), SUM(DISCOUNT) FROM INVENTORY GROUP BY CARNAME HAVING CARNAME = ‘CAR4’;

e) List the total number of cars having no discount.

Answer:          SELECT * FROM INVENTORY

                    WHERE DISCOUNT IS NULL;

Read More

Chapter 5: Data Structures | NCERT Solution for class 12th COMPUTER SCIENCE

Chapter 5 – DATA Structures, , Class 12, Computer Science


In Computer Science, a data structure is a particular way of storing and organizing data in a computer so
that it can be used efficiently. Different kinds of data structures are suited to different kinds of
applications, and some are highly specialized to specific tasks. For example, Stacks are used in function
call during execution of a program, while B-trees are particularly well-suited for implementation of
databases. The data structure can be classified into following two types:
Simple Data Structure: These data structures are normally built from primitive data types like integers,
floats, characters. For example arrays and structure.
Compound Data Structure: simple data structures can be combined in various ways to form more
complex structure called compound structures. Linked Lists, Stack, Queues and Trees are examples of
compound data structure.
 

Data Structure Arrays
Data structure array is defined as linear sequence of finite number of objects of same type with following
set of operation:

  • Creating : defining an array of required size
  •  Insertion: addition of a new data element in the in the array
  •  Deletion: removal of a data element from the array
  •  Searching: searching for the specified data from the array
  •  Traversing: processing all the data elements of the array
  •  Sorting : arranging data elements of the array in increasing or decreasing order
  •  Merging : combining elements of two similar types of arrays to form a new array of same type

In C++ an array can be defined as
Datatype arrayname[size];
Where size defines the maximum number of elements can be hold in the array. For example
float b[10];//b is an array which can store maximum 10 float values
int c[5];
Array initialization
void main()
{i
nt b[10]={3,5,7,8,9};//
cout<<b[4]<<endl;
cout<<b[5]<<endl;
}
Output is
9
0
In the above example the statement int b[10]={3,5,7,8,9} assigns first 5 elements with the given values
and the rest elements are initialized with 0. Since in C++ index of an array starts from 0 to size-1 so the
expression b[4] denotes the 5th element of the array which is 9 and b[5] denotes 6th element which is
initialized with 0.

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

We can use two different search algorithms for searching a specific data from an array

  •  Linear search algorithm
  •  Binary search algorithm


Linear search algorithm
In Linear search, each element of the array is compared with the given item to be searched for. This
method continues until the searched item is found or the last item is compared.
#include<iostream.h>
int linear_search(int a[], int size, int item)
{
int i=0;
while(i<size&& a[i]!=item)
i++;
if(i<size)
return i;//returns the index number of the item in the array
else
return -1;//given item is not present in the array so it returns -1 since -1 is not a legal index number
}
void main()
{
int b[8]={2,4,5,7,8,9,12,15},size=8;
int item;
cout<<”enter a number to be searched for”;
cin>>item;
int p=linear_search(b, size, item); //search item in the array b
if(p==-1)
cout<<item<<” is not present in the array”<<endl;
else
cout<<item <<” is present in the array at index no “<<p;
}
In linear search algorithm, if the searched item is the first elements of the array then the loop terminates
after the first comparison (best case), if the searched item is the last element of the array then the loop
terminates after size time comparison (worst case) and if the searched item is middle element of the array
then the loop terminates after size/2 time comparisons (average case). For large size array linear search not an efficient algorithm but it can be used for unsorted array also.

Binary search algorithm
Binary search algorithm is applicable for already sorted array only. In this algorithm, to search for the
given item from the sorted array (in ascending order), the item is compared with the middle element of the
array. If the middle element is equal to the item then index of the middle element is returned, otherwise, if
item is less than the middle item then the item is present in first half segment of the array (i.e. between 0
to middle-1), so the next iteration will continue for first half only, if the item is larger than the middle
element then the item is present in second half of the array (i.e. between middle+1 to size-1), so the next
iteration will continue for second half segment of the array only. The same process continues until either
the item is found (search successful) or the segment is reduced to the single element and still the item is
not found (search unsuccessful).

#include<iostream.h>
int binary_search(int a[ ], int size, int item)
{
int first=0,last=size-1,middle;
while(first<=last)
{
middle=(first+last)/2;

if(item==a[middle])
return middle; // item is found
else if(item< a[middle])
last=middle-1; //item is present in left side of the middle element
else
first=middle+1; // item is present in right side of the middle element
}
return -1; //given item is not present in the array, here, -1 indicates unsuccessful search
}
void main()
{
int b[8]={2,4,5,7,8,9,12,15},size=8;
int item;
cout<<”enter a number to be searched for”;
cin>>item;
int p=binary_search(b, size, item); //search item in the array b
if(p==-1)
cout<<item<<” is not present in the array”<<endl;
else
cout<<item <<” is present in the array at index no “<<p;
}
Let us see how this algorithm work for item=12
Initializing first =0 ; last=size-1; where size=8
Iteration 1

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

First=0, last=7
middle=(first+last)/2=(0+7)/2=3 // note integer division 3.5 becomes 3
value of a[middle] i.e. a[3] is 7
7<12 then first= middle+1 i.e. 3 + 1 =4
iteration 2

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

first=4, last=7
middle=(first+last)/2=(4+7)/2=5
value of a[middle] i.e. a[5] is 9
9<12 then first=middle+1;5+1=6
iteration 3

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

first=6,last=7

middle=(first+last)/2 = (6+7)/2=6
value of a[middle] i.e. a[6] is 12 which is equal to the value of item being search i.e.12
As a successful search the function binary_search() will return to the main function with value 6 as
index of 12 in the given array. In main function p hold the return index number.

Note that each iteration of the algorithm divides the given array in to two equal segments and the only one
segment is compared for the search of the given item in the next iteration. For a given array of size N= 2n
elements, maximum n number of iterations are required to make sure whether the given item is present in
the given array or not, where as the linear requires maximum 2n number of iteration. For example, the
number of iteration required to search an item in the given array of 1000 elements, binary search requires
maximum 10 (as 1000210) iterations where as linear search requires maximum 1000 iterations.

Inserting a new element in an array
We can insert a new element in an array in two ways

  •  If the array is unordered, the new element is inserted at the end of the array
  •  If the array is sorted then the new element is added at appropriate position without altering the order. To achieve this, all elements greater than the new element are shifted. For example, to add 10 in the given array below:
Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Following program implement insertion operation for sorted array

#include<iostream.h>
void insert(int a[ ], int &n, int item) //n is the number of elements already present in the array
{
int i=n-1;
while (i>=0 && a[i]>item)
{
a[i+1]=a[i]; // shift the ith element one position towards right
i–;
}
a[i+1]=item; //insertion of item at appropriate place
n++; //after insertion, number of elements present in the array is increased by 1
}
void main()
{int a[10]={2,4,5,7,8,11,12,15},n=8;
int i=0;
cout<<“Original array is: ”;
for(i=0;i<n;i++)
cout<<a[i]<<”, “;
insert(a,n,10);
cout<<” Array after inserting 10 is: ”;

for(i=0; i<n; i++)
cout<<a[i]<<”, “;
}

Output is
 

Original array is:
2, 4, 5, 7, 8, 11, 12, 15
Array after inserting 10 is:
2, 4, 5, 7, 8, 10, 11, 12, 15

Deletion of an item from a sorted array
In this algorithm the item to be deleted from the sorted array is searched and if the item is found in the
array then the element is removed and the rest of the elements are shifted one position toward left in the
array to keep the ordered array undisturbed. Deletion operation reduces the number of elements present in
the array by1. For example, to remove 11 from the given array below:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Following program implement deletion operation for sorted array
#include<iostream.h>
void delete_item(int a[ ], int &n, int item) //n is the number of elements already present in the array
{int i=0;
while(i<n && a[i]<item)
i++;
if (a[i]==item) // given item is found
{while (i<n)
{a[i]=a[i+1]; // shift the (i+1)th element one position towards left
i++;
}
cout<<” Given item is successfully deleted”;
}
else
cout<<” Given item is not found in the array”;
n–;
}
void main()
{int a[10]={2,4,5,7,8,11,12,15},n=8;
int i=0;
cout<<“Original array is : ”;
for(i=0;i<n;i++)
cout<<a[i]<<”, “;
delete_item(a,n,11);
cout<<” Array after deleting 11 is: ”;
for(i=0; i<n; i++)
cout<<a[i]<<”, “;
}
Output is
Original array is:
2, 4, 5, 7, 8, 11, 12, 15
Given item is successfully deleted
Array after deleting 11 is:
2, 4, 5, 7, 8, 12, 15

Traversal
Processing of all elements (i.e. from first element to the last element) present in one-dimensional array is
called traversal. For example, printing all elements of an array, finding sum of all elements present in an
array.

#include<iostream.h>
void print_array(int a[ ], int n) //n is the number of elements present in the array
{int i;
cout<<” Given array is : ”;
for(i=0; i<n; i++)
cout<<a[i]<<”, “;
}
int sum(int a[ ], int n)
{int i,s=0;
for(i=0; i<n; i++)
s=s+a[i];
return s;
}
void main()
{int b[10]={3,5,6,2,8,4,1,12,25,13},n=10;
int i, s;
print_array(b,n);
s=sum(b,n);
cout<<” Sum of all elements of the given array is : ”<<s;
}

Output is
Given array is
3, 5, 6, 2, 8, 4, 1, 12, 25, 13
Sum of all elements of the given array is : 79

Sorting
The process of arranging the array elements in increasing (ascending) or decreasing (descending) order is known as sorting. There are several sorting techniques are available e.g. selection sort, insertion sort,
bubble sort, quick sort, heap short etc. But in CBSE syllabus only selection sort, insertion sort, bubble sort
are specified.
 

Selection Sort
The basic idea of a selection sort is to repeatedly select the smallest element in the remaining unsorted
array and exchange the selected smallest element with the first element of the unsorted array. For
example, consider the following unsorted array to be sorted using selection sort

Original array

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

iteration 1 : Select the smallest element from unsorted array which is 3 and exchange 3 with the first
element of the unsorted array i.e. exchange 3 with 8. After iteration 1 the element 3 is at its
final position in the array.

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration 2: The second pass identify 4 as the smallest element and then exchange 4 with 5

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration 3: The third pass identify 5 as the smallest element and then exchange 5 with 9

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration 4: The third pass identify 7 as the smallest element and then exchange 7 with 8

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration 5: The third pass identify 8 as the smallest element and then exchange 8 with 16

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration 6: The third pass identify 9 as the smallest element and then exchange 9 with 9 which makes
no effect.

The unsorted array with only one element i.e. 16 is already at its appropriate position so no more iteration
is required. Hence to sort n numbers, the number of iterations required is n-1, where in each next iteration,
the number of comparison required to find the smallest element is decreases by 1 as in each pass one
element is selected from the unsorted part of the array and moved at the end of sorted part of the array .
For n=7 the total number of comparison required is calculated as
Pass1: 6 comparisons i.e. (n-1)
Pass2: 5 comparisons i.e. (n-2)
Pass3: 4 comparisons i.e. (n-3)
Pass4: 3 comparisons i.e. (n-4)
Pass5: 2 comparisons i.e. (n-5)
Pass6: 1 comparison i.e. (n-6)=(n-(n-1))
Total comparison for n=(n-1)+(n-2)+(n-3)+ ……….+(n-(n-1))= n(n-1)/2
7=6+5+4+3+2+1=7*6/2=21;
Note: For given array of n elements, selection sort always executes n(n-1)/2 comparison statements
irrespective of whether the input array is already sorted(best case), partially sorted(average case) or
totally unsorted(i.e. in reverse order)(worst case).
#include<iostream.h>
void select_sort(int a[ ], int n) //n is the number of elements present in the array
{int i, j, p, small;
for(i=0;i<n-1;i++)
{small=a[i]; // initialize small with the first element of unsorted part of the array
p=i; // keep index of the smallest number of unsorted part of the array in p
66
for(j=i+1; j<n; j++) //loop for selecting the smallest element form unsorted array
{if(a[j]<small)
{small=a[j];
p=j;
}
}// end of inner loop———-
//———-exchange the smallest element with ith element————-
a[p]=a[i];
a[i]=small;
//———–end of exchange————-
}
}//end of function
void main( )
{int a[7]={8,5,9,3,16,4,7},n=7,i;
cout<<” Original array is : ”;
for(i=0;i<n;i++)
cout<<a[i]<<”, “;
select_sort(a,n);
cout<<” The sorted array is: ”;
for(i=0; i<n; i++)
cout<<a[i]<<”, “;
}
Output is
Original array is
8, 5, 9, 3, 16, 4, 7
The sorted array is
3, 4, 5, 7, 8, 9, 16

Insertion Sort
Insertion sort algorithm divides the array of n elements in to two subparts, the first subpart contain a[0] to
a[k] elements in sorted order and the second subpart contain a[k+1] to a[n] which are to be sorted. The
algorithm starts with only first element in the sorted subpart because array of one element is itself in
sorted order. In each pass, the first element of the unsorted subpart is removed and is inserted at the
appropriate position in the sorted array so that the sorted array remain in sorted order and hence in each
pass the size of the sorted subpart is increased by 1 and size of unsorted subpart is decreased by 1. This
process continues until all n-1 elements of the unsorted arrays are inserted at their appropriate position in
the sorted array.

For example, consider the following unsorted array to be sorted using selection sort
 

Study with National ToppersJoin the Super Achievers of Class 12Join Now

Original array
Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science
Sorted unsorted
Initially the sorted subpart contains only one element i.e. 8 and the unsorted subpart contains n-1 elements
where n is the number of elements in the given array.

Iteration1: To insert first element of the unsorted subpart i.e. 5 into the sorted subpart, 5 is compared
with all elements of the sorted subpart starting from rightmost element to the leftmost
element whose value is greater than 5, shift all elements of the sorted subpart whose value
is greater than 5 one position towards right to create an empty place at the appropriate position in the sorted array, store 5 at the created empty place, here 8 will move from position a[0] to a[1] and a[0] is filled by 5. After first pass the status of the array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration2: In second pass 9 is the first element of the unsorted subpart, 9 is compared with 8, since 8
is less than 9 so no shifting takes place and the comparing loop terminates. So the element
9 is added at the rightmost end of the sorted subpart. After second pass the status of the
array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration3: in third pass 3 is compared with 9, 8 and 5 and shift them one position towards right and
insert 3 at position a[0]. After third pass the status of the array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration4: in forth pass 16 is greater than the largest number of the sorted subpart so it remains at the
same position in the array. After fourth pass the status of the array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration5: in fifth pass 4 is inserted after 3. After third pass the status of the array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration6: in sixth pass 7 is inserted after 5. After fifth pass the status of the array is:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Insertion sort take advantage of sorted(best case) or partially sorted(average case) array because if all
elements are at their right place then in each pass only one comparison is required to make sure that the
element is at its right position. So for n=7 only 6 (i.e. n-1) iterations are required and in each iteration only
one comparison is required i.e. total number of comparisons required= (n-1)=6 which is better than the
selection sort (for sorted array selection sort required n(n-1)/2 comparisons). Therefore insertion sort is
best suited for sorted or partially sorted arrays.
#include<iostream.h>
void insert_sort(int a[ ],int n) //n is the no of elements present in the array
{int i, j,p;
for (i=1; i<n; i++)
{p=a[i];
j=i-1;
//inner loop to shift all elements of sorted subpart one position towards right
0 1 2 3 4 5 6
3 5 8 9 16 4 7
68
while(j>=0&&a[j]>p)
{
a[j+1]=a[j];
j–;
}
//———end of inner loop
a[j+1]=p; //insert p in the sorted subpart
}
}
void main( )
{
int a[7]={8,5,9,3,16,4,7},n=7,i;
cout<<” Original array is : ”;
for(i=0;i<n;i++)
cout<<a[i]<<”, “;
insert_sort(a,n);
cout<<” The sorted array is: ”;
for(i=0; i<n; i++)
cout<<a[i]<<”, “;
}

Output is
Original array is
8, 5, 9, 3, 16, 4, 7
The sorted array is
3, 4, 5, 7, 8, 9, 16

Bubble Sort
Bubble sort compares a[i] with a[i+1] for all i=0..n-2, if a[i] and a[i+1] are not in ascending order then
exchange a[i] with a[i+1] immediately. After each iteration all elements which are not at their proper
position move at least one position towards their right place in the array. The process continues until all
elements get their proper place in the array (i.e. algorithm terminates if no exchange occurs in the last
iteration)
For example, consider the following unsorted array to be sorted using selection sort
Original array

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science
Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Since in iteration1 some elements were exchanged with each other which shows that array
was not sorted yet, next iteration continues. The algorithm will terminate only if the last
iteration do not process any exchange operation which assure that all elements of the array
are in proper order.
Iteration2: only exchange operations are shown in each pass

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

In iteration 2 some exchange operations were processed, so, at least one more iteration is
required to assure that array is in sorted order.

Iteration3:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration4:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

Iteration5:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

In iteration 5 no exchange operation executed because all elements are already in proper
order therefore the algorithm will terminate after 5th iteration.

Merging of two sorted arrays into third array in sorted order
Algorithm to merge arrays a[m](sorted in ascending order) and b[n](sorted in descending order) into third
array C[n+m] in ascending order.

#include<iostream.h>
Merge(int a[ ], int m, int b[n], int c[ ])// m is size of array a and n is the size of array b
{int i=0; // i points to the smallest element of the array a which is at index 0
int j=n-1;// j points to the smallest element of the array b which is at the index m-1 since b is
// sortet in descending order
int k=0; //k points to the first element of the array c
while(i<m&&j>=0)
{if(a[i]<b[j])
c[k++]=a[i++]; // copy from array a into array c and then increment i and k
else
c[k++]=b[j–]; // copy from array b into array c and then decrement j and increment k
}
while(i<m) //copy all remaining elements of array a
c[k++]=a[i++];
while(j>=0) //copy all remaining elements of array b
c[k++]=b[j–];
}
void main()
{int a[5]={2,4,5,6,7},m=5; //a is in ascending order
int b[6]={15,12,4,3,2,1},n=6; //b is in descending order
int c[11];
merge(a, m, b, n, c);
cout<<”The merged array is : ”;
for(int i=0; i<m+n; i++)
cout<<c[i]<”, “;
}
Output is
The merged array is:
1, 2, 2, 3, 4, 4, 5, 6, 7, 12, 15
 

Two dimensional arrays
In computing, row-major order and column-major order describe methods for storing multidimensional
arrays in linear memory. Following standard matrix notation, rows are identified by the first index of a
two-dimensional array and columns by the second index. Array layout is critical for correctly passing
arrays between programs written in different languages. Row-major order is used in C, C++; columnmajor
order is used in Fortran and MATLAB.

Row-major order
In row-major storage, a multidimensional array in linear memory is accessed such that rows are stored one
after the other. When using row-major order, the difference between addresses of array cells in increasing
rows is larger than addresses of cells in increasing columns. For example, consider this 2×3 array:

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science
An array declared in C as
int A[2][3] = { {1, 2, 3}, {4, 5, 6} };
would be laid out contiguously in linear memory as:


1 2 3 4 5 6

To traverse this array in the order in which it is laid out in memory, one would use the following nested
loop:
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
cout<<A[i][j];
The difference in offset from one column to the next is 1*sizeof(type) and from one row to the next is
3*sizeof(type). The linear offset from the beginning of the array to any given element A[row][column]
can then be computed as:
offset = row*NUMCOLS + column
Address of element A[row][column] can be computed as:
Address of A[row][column]=base address of A + (row*NUMCOLS + column)* sizeof (type)
Where NUMCOLS is the number of columns in the array.
The above formula only works when using the C, C++ convention of labeling the first element 0. In other
words, row 1, column 2 in matrix A, would be represented as A[0][1]
Note that this technique generalizes, so a 2×2×2 array looks like:
int A[2][2][2] = {{{1,2}, {3,4}}, {{5,6}, {7,8}}};
and the array would be laid out in linear memory as:


1 2 3 4 5 6 7 8
 

Example 1.
For a given array A[10][20] is stored in the memory along the row with each of its elements occupying 4
bytes. Calculate address of A[3][5] if the base address of array A is 5000.
Solution:
For given array A[M][N] where M=Number of rows, N =Number of Columns present in the array
address of A[I][J]= base address+(I * N + J)*sizeof(type)
here M=10, N=20, I=3, J=5, sizeof(type)=4 bytes
address of A[3][5] = 5000 + (3 * 20 + 5) * 4
= 5000 + 65*4=5000+260=5260

Example 2.
An array A[50][20] is stored in the memory along the row with each of its elements occupying 8 bytes.
Find out the location of A[5][10], if A[4][5] is stored at 4000.
Solution:
Calculate base address of A i.e. address of A[0][0]
For given array A[M][N] where M=Number of rows, N =Number of Columns present in the array
address of A[I][J]= base address+(I * N + J)*sizeof(type)
here M=50, N=20, sizeof(type)=8, I=4, J=5
address of A[4][5] = base address + (4*20 +5)*8
4000 = base address + 85*8
Base address= 4000-85*8= 4000-680=3320
Now to find address of A[5][10]
here M=50, N=20, sizeof(type)=8, I=5, J=10
Address of A[5][10] = base address +(5*20 + 10)*8
=3320 + 110*8 = 3320+880 = 4200
As C, C++ supports n dimensional arrays along the row, the address calculation formula can be
generalized for n dimensional array as:
For 3 dimentional array A[m][n][p], find address of a[i][j][k]:
Address of a[i][j][k] = base address + ( (I * n + j ) * p + k ) * sizeof(type)
For 4 dimentional array A[m][n][p][q], find address of a[i][j][k][l]:
Address of a[i][j][k][l] = base address + ( ( (I * n + j ) * p + k ) * p + l ) * sizeof(type)
Column-major order is a similar method of flattening arrays onto linear memory, but the columns are
listed in sequence. The programming languages Fortran, MATLAB, use column-major ordering. The
array

Chapter 5 - DATA Structures, Chapter Notes, Class 12, Computer Science

if stored contiguously in linear memory with column-major order would look like the following:


1 4 2 5 3 6


The memory offset could then be computed as:
offset = row + column*NUMROWS
 

Address of element A[row][column] can be computed as:
 

Address of A[row][column]=base address of A + (column*NUMROWS +rows)* sizeof (type)

Where NUMROWS represents the number of rows in the array in this case, 2.
Treating a row-major array as a column-major array is the same as transposing it. Because performing a
transpose requires data movement, and is quite difficult to do in-place for non-square matrices, such
transpositions are rarely performed explicitly. For example, software libraries for linear algebra, such as
the BLAS, typically provide options to specify that certain matrices are to be interpreted in transposed
order to avoid the necessity of data movement

Example1.
For a given array A[10][20] is stored in the memory along the column with each of its elements occupying
4 bytes. Calculate address of A[3][5] if the base address of array A is 5000.
Solution:
For given array A[M][N] where M=Number of rows, N =Number of Columns present in the array
Address of A[I][J]= base address + (J * M + I)*sizeof(type)
here M=10, N=20, I=3, J=5, sizeof(type)=4 bytes
Address of A[3][5] = 5000 + (5 * 10 + 3) * 4
= 5000 + 53*4 = 5000+215 =5215

Example2.
An array A[50][20] is stored in the memory along the column with each of its elements occupying 8 bytes.
Find out the location of A[5][10], if A[4][5] is stored at 4000.
Solution:
Calculate base address of A i.e. address of A[0][0]
For given array A[M][N] where M=Number of rows, N =Number of Columns present in the array
address of A[I][J]= base address+(J * M + I)*sizeof(type)
here M=50, N=20, sizeof(type)=8, I=4, J=5
address of A[4][5] = base address + (5 * 50 +4)*8
4000 = base address + 254*8
Base address= 4000-55*8= 4000-2032=1968
Now to find address of A[5][10]
here M=50, N=20, sizeof(type)=8, I =5, J=10
Address of A[5][10] = base address +(10*50 + 10)*8
=1968 + 510*8 = 1968+4080 = 6048

Read More

Chapter 4: Pointers | NCERT Solution for class 12th COMPUTER SCIENCE

NCERT Solutions for Class 12 Computer Science (C++) – Pointers

Very Short Answer Type Questions    [1 mark each]

Question 1:
Write the definition of a function FixPay (float Pay[ ], int N) in C+ + , which should modify each element of the array Pay having N elements, as per the following rules :

Existing Salary ValueRequired Modification in Value
If less than 1,00,000Add 25% in the existing value
If >=1,00,000 and <20,000Add 20% in the existing value
If >=2,00,000Add 15% in the existing value

Аnswer:

Void FixPay(float Pay[],int N)
{
for(int i=0;i<N;i++)
{
if(Pay[i]<100000)
Pay[i]+= Pay[i]*0.25;
else if(Pay[i]<200000)
Pay[i]+= Pay[i]*0.20; 
else
Pay[i]+= Pay[i]*0.15 ;
 }
}

Question 2:
Write the definition of a member function INSERT() for a class QUEUE in C+ +, to remove a product from a dynamically allocated Queue of items considering the following code is already written as a part of the program.

Struct ITEM 
{
int INO; char INAME[20];
ITEM*Link;
};
class QUEUE 
{
ITEM *R,*F;
Public:
QUEUE(){R=NULL; F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};

Аnswer:

Void QUEUE::INSER()
{
ITEM*newitem = new ITEM; 
Cout<<"enter item number";
cin>>newitem → INO;
Cout<<"Enter item name";  
gets(newitem → INAME); 
newitem → Link = NULL; 
if (R==NULL)
R=F=newitem;
else
{
 R → Link=newitem; 
 R = newitem;
}

Short Answer Type Questions-I

Question 1:
Write the output from the following C+ + program code :

#include<iostream.h>
#include<ctype.h> 
void strcon(char s[])
{
for(int i=0,l=0;s[i]!='\0';i++,l++); 
fortint j=0;j<l;j++)
{
if(isupper(s[j]))
s[j]=tolower(s[j])+2; 
else if( islower(s[j])) 
s[j]=toupper(s[j])-2; 
else
s[j] ='@';
 }
}
void main()
{
char *c="Romeo Joliet"; 
strcon(c);
cout<<"Text="<<c<<endl; 
c=c+3;
cout<<"New Text="<<c<<endl; 
c=c+5-2 ;
cout<<"last Text= "<<c;
 }

Аnswer:
Text = tMKCM@lMJGCR
New Text = KCM@1MJGCR
Last Text = 1MJGCR

Question 2:
Obtain the output of the following C+ + program as expected to appear on the screen after its execution.
Important Note :
All the desired header files are already included in the code, which are required to run the code.

void main()
{
char *Text="AJANTA"; int *P, Num[]={l,5,7,9}
P=Num;
cout <<*p<< Text <<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}

Аnswer:
1AJANTA
5JANTA

Question 3:
Obtain the output from the following C+ + program as expected to appear on the screen after its execution.
Important Note :
• Adi the desired header files are already included in the code, which are required to run the code.

void main()
{
char *String="SARGAM"; 
int *Ptr, a[]={1,5,7,9}; 
ptr=a;
cout<<*ptr<<String<<endl;
String++; 
ptr+=3;
cout<<*ptr<<String<<endl;
}

Аnswer:
1 SARGAM
9ARGAM

Question 4:
Give the output of the following program segment: (Assuming all desired header file(s) are already included)

void main()
{
float *Ptr, Points[] = {20,50,30,40,10};
Ptr = points; 
cout<<*Ptr<<endl;
Ptr+=2;
Points[2]+=2.5; 
cout<<*Ptr<<endl;
Ptr++;
(*Ptr)+=2.5; 
cout<<Points[3]<<endl;
}

Аnswer:
20.00 32.5
42.50

Question 5:
Find the output of the following code :
Important Note :
All the header files are already included in the code, which are required to run the code.

void main()
{
char *String="SHAKTI";
int*Point,Value[]={10,15,70,19};
Point=Value;
cout<<*Point<<String<<endl;
String++;
Point++;
cout<<*Point<<String<<endl;
}

Аnswer:
10SHAKTI
15HAKTI

Question 6:
Write the output of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

void change(int*s)
{
for(int i=0;i<4;i++)
{
if(*s<40)
{
if(*s%2==0)
*s=*s+10; 
else
*s=*s+ll; 
}
else
 {
if(*s%2==0)
*S=*S-10; 
else
*s=*s-ll;
}
cout<<*s<<" ";
s++;
}
}
void main()
{
int score[]={25,60,35,53 }; 
change(score);
}

Аnswer:
36 50 46 42

Short Answer Type Question-II

Question 1:
Find the output of the following program :

#include<iostream.h>
void in(int x,int y,int &z)
{
x+=y; 
y--;
z*=(x-y);
}
void out(int z,int y,int &x)
{
x*=y;
y++;
z/=(x+y);
}
void main()
{
int a=20, b=30, c=10;
out(a,c,b);
cout<<a<<"#"<<b<<"#"<<c<<"#"<<endl; 
in(b,c, a) ;
cout<<a<<"®"<<b<<"@"<<c<<"@"<<endl; 
out(a,b,c);
cout<<a<<"$"<<b<<"$"<<c<<"$"<<endl;
}

Аnswer:
20#300#10#
620@300@10@
620$300$3000$

Long Answer Type Questions

Question 1:
Find the output of the following code:

#include<iostream.h> 
void main()
{
int *Striker;
int Track[]={10,25,30,55}; 
Striker=Track; 
Track[1]+=30;
cout<<"Striker"<<*Striker<<endl; 
*Striker=-10;
Striker++;
cout<<"Next@"<<*Striker<<endl; 
Striker+=2;
cout<<"Last@"<<*Striker<<endl;
cout<<"Rest To"<<*Track[0]<<endl;
}

Аnswer:
Striker 10
Next@55
Last@55
Rest To 0

Question 2:
Find the output of the following code :

#include<iostream.h> 
void main()
{ 
int *Queen;
Moves[]={ll,22,33,44};
Queen=Moves;
Moves[2]+=22;
cout<<"Queen@"<<*Queen<<endl; 
*Queen-=ll;
Queen+=2;
cout<<”Now@"<<*Queen<<endl; 
Queen++;
cout<<"Finally@"<<*Queen<<endl;
cout<<"NewOrigin@"<<*Moves[0]<<endl; 
}

Аnswer:
Queen@11
Now@55
Finally@44
NewOrigin@0

Read More

Chapter 3: Data File Handling | NCERT Solution for class 12th COMPUTER SCIENCE

NCERT Solutions for Class 12 Computer Science (C++) – Data File Handling

TOPIC-1

Data File Handling :

Short Answer Type Questions-I[2 marks each]

Question 1.
Write a user defined function word_count() in C+ + to count how many words are present in a text file named “opinion.txt”. For Example, if the file opinion.txt contains following text:

Co-education system is necessary for a balanced society. With co-education system. Girls and Boys may develop a feeling of mutual respect towards each other.

The function should display the following :
Total number of words present in the text file are:24
Answer:

void word_count ()
 {
 ifstream i;char ch[20];int c=0;
 i.open("opinion.txt"); while(!i.eof())
 {
 i>>ch;
 C=C+1;
 }
 cout<<"Total number of words present in the text file are: "<<c;
 }

Question 2.
Write a function in C + + to count and display the no of three letter words in the file “VOWEL.TXT”.
Example :
If the file contains :
A boy is playing there. I love to eat pizza. A plane is in the sky.
Then the output should be : 4
Answer:

#include
 #include
 void wordcount()
 { char word[80];
 int cnt=0;
 ifstream fl;
 f1.open("VOWEL.TXT");
 while (fl>>word)
 {
 if (strlen(word) == 3)
 {
 cnt++;
 cout<<word<<endl;
 }
 }
 cout<<" number of three letter words = ”<<cnt;
 f1.close();
 }

Question 3.
Write a function AECount() in C++, which should read each character of a text file NOTES. TXT, should count and display the occurrence of alphabets A and E (including small cases a and e too).
Example :
If the file content is as follow :
CBSE enhanced its CCE guidelines further.
The AECount() function should display the output as
A:1
E:7
Answer:

Void AECount ()
 {
 Fstream obj;
 Obj.open ("NOTES.TXT", ios :: in) ;
 char x;
 int i=o, Sum A=0, Sum E=0,
 while (obj.get (ch)!=0)
 {
 obj . get (x) ;
 if (x=="A"||? x=="a")
 SumA =SumA+l;
 if(x=="E"|| x =="e")
 SumE=sumE+l;
 }
 cout<<"A:"<<sumA<<endl;
 Cout<<"E:"<< SumE;
 }

Question 4.
Write a function Countaroma() to count and display the number of times “Aroma” occurs in a text file “Cook.txt”.
Note : Only complete word “Aroma” should be counted. Words like “Aromatic” should not be counted.
Answer:

Void Countword ()
 {
 fstream tfile;
 clrscr();
 tfile.open ("Cook.txt", ios::in);
 char arr[80];
 char ch;
 int i=0;sum=0;n=0;
 while(tfile)
 {
 tfile.get (ch)
 arr[i] = ch;
 i++ ;
 if (strcpy(ch, "Aroma"))
 {
 i--;
 sum = sum+i;
 n++;
 }
 }
 Cout<<"Total number of Aroma:" <<n;
 }

Question 5.
Write a function EUCount ( ) in C++, which should read each character of a text file IMP TXT, should count and display the occurrence of alphabets E and U (including small cases e and u too).
Example:
If the file content is as follows ;
Updated information is simplified by official websites.
The EUCount() function should display the
output as
E:4
U:1
Answer:

void EUCount ()
 {
 fstream obj;
 obj. open("IMP.TXT");
 char ch;
 int i = 0 , sumE=0, sumU=0 ;
 while (obj. get (ch)! =0)
 {obj. get (ch);
 if(ch=="E"||ch=="e")
 SumE=sumE+l;
 if(ch=="U" ??ch =="u")
 SumU=SumU+l;
 } cout << "E : " «sum E<<endl;
 cout<<"U:"<<sumU<<endl;
 }

Question 6.
Write a function CountDig() in C++ which reads the content of a text file story.txt and displays the number of digits in it
For example if the file contains:
Amrapali was a queen of Gareware Kingdom in the year 1911. She had 2 daughters.
Her palace had 200 rooms.
Then the output on the screen should be :
Number of digits in Story: 8
Answer:

void CountDig ()
 {
 ifstream fin ("STORY.TXT");
 char ch;
 int count=0;
 while(!fin.eof ())
 {fin>>ch;
 if(isdigit(ch))
 count++;
 }
 cout<<"Number of digit in Story: "<<count;
 fin:close();
 }

Question 7.
Write a function in C + + to count the number of lines starting with a digit in a text file “Diary.Txt”.
Answer:

int countNum ()
 {
 ifstream fin("Diary.Txt");
 char ch[80];
 int count = 0;
 while (!fin.eof())
 {
 fin.getline (ch, 80);
 if (isdigit (ch[0])
 count ++;
 }
 fin.close( );
 return count;
 }

Question 8.
Write a function in C+ + to read the content of a text file “DELHI.TXT” and display all those lines on the screen, which are either starting with ‘D’ or starting with ‘M’.
Answer:

void disp ()
 {
 ifstream FILE("DELHI.TXT");
 int CA= 0;
 char LINE [80];
 while(FILE.getline(LINE,80))
 if(LINE [0]=='D' | | LINE[0]= 'M')
 puts(LINE);
 FILE.close();
 }

Question 9.
Write a function in C++ to read the content of a text file “PLACES.TXT” and display all those lines on screen, which are either starting with ‘P’ or starting with ‘S’.
Answer:

void disp ()
 {
 ifstream FILE("PLACES.TXT");
 int CA=0;
 char LINE [80];
 while(FILE.getline(LINE,80))
 if(LINE[0]=='P' | | LINE[0]=='S')
 puts(LINE);
 FILE.close();
 }

Question 10.
Write a function CountYouMe ( ) in C+ + which reads the contents of a text file story.txt and counts the words You and Me (not case sensitive).
For example, if the file contains:
You are my best friend.
You and me make a good team.
The function should display the output as:
Count for you : 2
Count for Me : 1
Answer:

void countyoume ( )
 {
 ifstream fil("story.txt");
 char word [80];
 int WC = 0, WM = 0;
 while (! fil.eof())
 {
 fil>>word;
 if ((strcmp WC++ ; (word, "You") = = 0)
 if (strcmp (word, "Me") = = 0) )
 WM++ ;
 }
 cout <<"count for you" << WC;
 cout <<"count for me" << WM;
 fil. close ( ) ;}

Question 11.
Write a function in C + + to count the number of lines present in a text file “STORY.TXT”.
Answer:

void CountLine ()
 {
 ifstream FIL("STORY.TXT");
 int LINES=0;
 char STR[80]; while {FIL.getline(STR, 80);
 LINES++;}
 cout<<"No. of Lines:"<<LINES;
 f.close();
 }

TOPIC-2

Data File Handling : binary file

Very Short Answer Type Questions[1 mark each]

Question 1.
Write the command to place the file pointer at the 10th and 4th record starting position using seekp() or seekg() command. File object is “file”? and record name is “STUDENT”.
Answer:
file.seekp( 9 * sizeof(STUDENT), ios::beg);
file.seekp( 3 * sizeof(STUDENT), ios::beg);

Question 2.
Find the output of the following C++ code considering that the binary file sp.dat already exists on the hard disk with 2 records in it.

class sports
 {
 int id;
 char sname[20];
 char coach[20];
 public:
 void entry();
 void show();
 void writing();
 void reading();
 }s;
 void sports::reading()
 {
 ifstream i;
 i.open("sp.dat");
 while(1)
 {
 i.read((char*)&s.size of (s));
 if(i.eof())
 break;
 else
 cout<<"\n"<<i.tellg();
 }
 i.close () ;
 }
 void main()
 {
 s.reading();
 }

Answer:
42
84

Question 3.
A binary file “games.dat” contains data of 10 games where each game’s data is an object of the following class :

class game
 {
 int gameno;
 char game_name[20];
 public :
 void enterdetails(){cin>>gameno;
 gets(game_name);}
 void enterdetails()
 {cout<<gameno<<endl<< game_name;}
 };
 With reference to this information, write C++ statement in the blank given below 
to move the file pointer to the end of file, ifstream ifile; game G;
 ifile.open("games.dat",ios::binary| ios::in);
 cout<<ifile.tellg();

Answer:

ifile.seekg(0,ios::end);

Question 4.
Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with appropriate functions for the required task,

class Agency {
 int ANo; //Agent Code
 char AName [20]; //Agent Name
 char Mobile [12]; //Agent Mobile
 public:
 void Enter (); /*Function to
 enter details of agent*/
 void Disp (); /‘Function to
 display details of agent*/
 int RAno () {return ANo; }
 void UpdateMobile() /‘Function to update Mobile*/
 {
 cout<<"Updated Mobile:";
 gets(Mobile);
 };
 void AgentUpdate ()
 {
 fstream F;
 F. open ("AGENT.DAT", ios:: binary |ios:: in | ios:: out);
 int Updt=0;
 int UAno;
 cout<<"Ano (Agent No - to update Mobile):"; cin>> UAno;
 Agency A;
 while (!Updt && F.read ((char*) &A, sizeof (A)))
 {
 if (A. RAno ()==UAno)
 {
 //Statement 1: To call the function to Update Mobile No.
 //Statement 2: To reposition file pointer to re-write the updated object back in the file
F. Write ((char*)&A, sizeof (A));
Updt++;
 }
 }
 if (Updt)
 cout<<"Mobile Updated for Agent" <<UAno<<endl;
 else
 cout<< "Agent not in the Agency"<<endl;
 F. close ();
 }

Answer:
Statement 1:
A. Update Mobile ();
Statement 2:
F. seekg (-l*size of (A),ios:: (cur);

Question 5.
Fill in the blanks marked as Statement 1 and Statements 2, in the program segment given below with appropriate functions for the required task.

class Medical
 {
 int RNo; //Representative Code
 char Name [20];
 //Representative Name
 char Mobile [12];
 //Representative Mobile
 public :
 void Input (); // Function to enter all details
 void Show (); //Function to display all details
 int RRno () {return RNo;}
 void Change Mobile () //Function to change Mobile
 {
 cout<<"Changed Mobile:";
 gets (mobile);
 }
 };
 void RepUpdate ()
 {
 fstream F;
 F. open ("REP. DAT", ios : : binaryl ios:: in| ios:: out):
 int Change=0;
 int URno;
 cout<<"Rno (Rep No-to update Mobile) :"; cin>>URno;
 Medical M;
 while (! Change && F.read((char*) &M, sizeof (M))
 {
 if (M. RRno()==URno)
 {
 //Statement 1: To call the function to change Mobile No.
 //Statement 2: To reposition file pointer to re-write
 //the updated object back in the file ;
 F. write ((char*) &M, Sizeof (M)) ;
 Change++;
 }
 }
 if (change)
 cout <<"Mobile Changed for Rep" <<URno<<endl;
 else
 cout <<"Rep not in the Medical"< F. close ();
 }

Answer:
Statement 1:
M. Change Mobile ();
Statement 2:
F. seekp (-1* sizeof (M), ios :: (ur);

Question 6.
Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with appropriate functions for the required task.

class Agent
 {
 long ACode; //Agent Code
 char AName [2 0] ; //Agent Name
 int Commission;
 public:
 void Enter (); //Function to enter details of Agent
 void Display (); //Function to display details of Agent
 void Update (int c) //Function to modify commission
 {
 Commission = C;
 }
 int GetComm(){return Commission;}
 long GetAcodeO {return Acode;}
 };
 void ChangeCommission (long AC, int CM)
 //AC " Agent Code, whose commission needs to change
 //CM " New Commission
 {
 fstream F;
 F. open ("AGENT.DAT", ios : :
 binary |ios : : in|ios : : out);
 char Changed='N';
 Agent A;
 while (Changed=='N'&& F. read ((char*) &A, size of (A)))
 { if (A. GetAcode ()==AC)
 {
 Changed = 'Y';
 A. Update (CM);
 //Statement 1: To place file pointer to the required position
------------------------;
 //Statement 2: To write the object A on to the binary file
 -------------------------;
 }
 }
 if (Changed=='N')
 cout <<"Agent not registered.";
 F. close ();

Answer:
Statement 1:
F. seekg (position);
Statement 2:
F. write ((char *) & A, size of (A));

Question 7.
Fill in the blanks marked as Statement 1 and Statement 2, in the program segment given below with appropriate functions for the required task.

class Customer {
 long int CNo; //Customer Number
 char CName[20]; //Customer Name
 char Email[30]; //Email of Customer
 public :
 void Allocate(); //Function to allocate a member
 void Show(); //Function to show customer data
 void ModifyEmail() //Function to modify Email ,
 { cout<<"Enter Modified Email:";
 gets(Email);
 }
 long int GetCno( ) {return CNo;}
 };
 void ChangeData( )
 {
 fstream File;
 File.open ("CUST.DAT", ios: :.binary | ios: :in|ios: :out);
 int Change=0, Location; long int ChangeCno;
 cout<<"Cno - whose email required to be modified:"; cin>>ChangeCno;
 Customer CU;
 while(Modify && File,read((char*)&CU, sizeof(CU)))
 {
 if (CU.GetCno()==ChangeCno)
 {
 CU.ModifyEmail ();
 Location=File.tellg()- sizeof(CU);
 //Statement 1: To place file pointer to the required position
 //Statement 2: To write the object CU on to the binary file
 Change ++;
 }
 }
 if (Change)
 cout<<"Email Modified... "<<endl;
 else
 cout <<"Customer not found... "<<endl;
 File. close();
 }

Answer:
Statement 1:
File.seekp (-l*size of (CU), ios ::cur);
Statement 2:
File.write ((char*)&CU, sizeof (CU));

Question 8.
A binary file “Students.dat” contains data of 10 students where each student’s data is an object of the following class:

class Student
 {
 int Rno; char Name [20] ;
 public:
 void EnterDataO {cin>>Rno; cin. getline (Name, 20)}
 void showData( ) {cout<<Rno<<”- <<Name<< endl;}
 };

With reference to this information, write output of the following program segment:

 ifstream file; Student S;
 File.open ("Students.dat", ios::binary |ios::in);
 File.seekg (0, ios::end);
 Cout<<File.tellg();

Answer:
A1
B2
C3

Question 9.
Observe the program segment given below carefully and answer the questions that follow:

class Stock
 {
 int Ino,Qty; char Item[20];
 public:
 void Enter( ){cin>>Ino;
 gets(Item); cin>>Qty;}
 void Issue (int Q) {Qty+=Q;}
 void Purchase (int Q) {Qty- =Q;)
 int GetlnoO {return Ino;}
 } ;
 void Purchaseltem (int Pino, int PQty)
 {
 fstream File;
 File.open ("STOCK.DAT", ios:: binary |ios: : in|ios : : out);
 Stock S;
 int Success=0;
 while (Success==0 && File . read ((char*) &S, sizeof (S)))
 {
 if (Pino==S. Getlno ())
 {
 S. Purchase (PQty);
 //Statement 1
 //Statement 2
 Success++ ;
 }
 }
 if (Success==l)
 cout<<" Purchase Updated" <<endl;
 else
 cout<<"Wrong Item No"<<endl;
 File . close ( ) ;
 }

(i)Write statement 1 to position the file pointer to the appropriate place, so that the data updation is done for the, required item.
(ii)Write statement 2 to perform the write operation so that the updation is done in the binary file.
Answer:
(i) file.seekp(-sizeof(Qty), ios::cur);
(ii) file.write((char*)&S, sizeof (stock));

Question 10.
Observe the program segment given below carefully and answer the questions that follow:

class Inventory
 { int Ano, Qty; char Article [20];
 public:
 void Input () (cin>>Ano; gets(Article); cin>>Qty;}
 void Issue (int Q) {Qty+=Q;}
 void Procure (int Q) {Qty-=Q;}
 int GetAno () {return Ano;}
 };
 void ProcureArticle (int TAno, int TQty)
 {
 fstream File;
 File.open("STOCK.DAT", ios :: binary|ios :: in|ios :: out);
 Inventory I;
 int Found=0;
 while (Found==0 && File, read((char*)&I. sizeof(I)))
 if (TAno=|S.GetAno())
 {
 I. Procure (TQty);
 //Statement 1
 //Statement 2
 Found++;
 }
 }
 if (Found==l)
 {
 cout<<" Procurement Updated" << endl ;
 else
 cout<<"Wrong Article No"<<endl; 
 File.close ( ) ;}

(i) Write statement 1 to position the file pointer to the appropriate place, so that the data updation is done for the required term.
(ii) Write statement 2 to perform the write operation so that the updation is done in the binary file.

Answer:
(i) file.seekp(sizeof (qty), ios :: cur);
(ii) file.write((char*)& |, sizeof(|));

Short Answer Type Questions-I[2 marks each]

Question 1.
Consider a file F containing objects E of class Emp. [Delhi, 2015]
(i) Write statement to position the file pointer to the end of the file.
(ii) Write statement to return the number of bytes from the begining of the file to the current position of the file pointer.
Answer:
(i) F. seekg (0,ios::end);
(ii) F.tellg();

Question 2.
Write a function RevText() to read a text file “Input.txt” and Print only word starting with ‘I’in reverse order. [Delhi, 2015]
Example : If value in text file is : INDIA IS MY COUNTRY v
Output will be : AIDNI SI MY COUNTRY
Answer:

void RevText ()
 {ifstream in ("Input.txt");
 char word[25];
 while(in)
 { in >>word;
 if (word[0] = = 'I' )
 cout<<strrev(word);
 else
 cout<<word;
 }

Question 3.
Write a function in C++ to search display details, where destination is “Chandigarh” from binary file “Flight.Dat”. Assuming the binary file is containing the objects of the following class :

 class FLIGHT
 { int Fno; // Flight Number
 char From [20]; // Flight Starting Point
 char To [20]; //Flight Destination
 public :
 char * GetFrom (); { return from;}
 char * GetTo(); { return To; }
 void input()
 {cin>>Fno>>; gets(From); get (To);}
 void show()
 {cout<<Fno<<":"<<From<<":"<<To<<endl; }
 };

Answer:

void Dispdetails ()
 {ifstream fin ("Flight.Dat");
 Flight F;
 while (fin)
 {fin.read((char*)&F,sizeof(F))
 if (strcmp(F.GetTo0, "Chandigarh"))
 F.show();
 }
 }

Question 4.
Write function definition for TOWER () in C++ to read content of a text file WRITEUE TXT. Count the presence of word TOWER and display the number of occurrences of this word.
Note:
— The word TOWER should be an independent word
— Ignore type cases (i.e. lower/upper case) Example:
If the content of the file WRITEUETXT is as follows:

Tower of hanoi is an interesting problem. Mobile phone tower is away from here. 
Views from EIFFEL TOWER are amazing.

The function TOWER() should display the following:
3
Answer:

void TOWER ()
{
int count = 0;
ifstream f (“WRITEUP.TXT”);
char s [20];
while (! f . eof () )
{
f >>S;
if (strcmpi (s, “TOWER”) = =0)
count ++;
}
cout<<count; f.close () ;
}

OR
Any other correct function defintion

Question 5.
Write a definition for function COSTLY() In C++ to read each record of a binary file GIFTS. DAT, find and display those items, which are priced more than 2000. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:

class GIFTS
 {
 int CODE; char ITEM [20] ; float PRICE;
 public :
 void procure ()
 {
 cin>>CODE; gets (ITEM); cin>>PRICE;
 }
 void View ()
 {
 cout<<CODE<<":"<<ITEM<<":"< }
 float GetPrice () {return PRICE;
 }.

Answer:

void COSTLY ()
 {
 GIFTS G;
 ifstream fin ("GIFTS.DAT" , ios : : binary);
 while (fin.read( (char *)&G, sizeof (G)))
 {
 if (G.GetPrlce () >2000)
 G.View ();
 }
 fin. close ();

OR
Any other correct equivalent function definition

Question 6.
Find the output of the following C++ code considering that the binary file MEMBER. DAT exists on the hard disk with records of 100 members:

class MEMBER
 {
 int Mno; char Name [20];
 public :
 void In (); void out ();
 };
 void main ()
 {
 fstream MF;
 MF.open (:MEMBER.DAT", ios :: binary |ios :: in);
 MEMBER M;
 MF.read ((char*) &M, sizeof (M)) ;
 MF.read ((char*)) &M, sizeof (M));
 MF.read ((char*) &M, sizeof (M));
 int POSITION = MF. tellg () / sizeof (M) ;
 Cout<<"PRESENT REOCRD :"< MF.close () ;
 }

Answer:
PRESENT RECORD : 3

Question 7.
Write function definition for SUCCESS () in C + + to read the content of a text file STORY.TXT, count the presence of word STORY and display the number of occurrence of this word.
Note:
— The word STORY should be an independent word
— Ignore type cases (i.e. lower/upper case)
Example:
If the content of the file STORY.TXT is as follows

Success shows others that we can do it. It is possible to achieve success with hard work.
 Lot of money does not mean SUCCESS.

The function SUCCESS() should display the following:
3
Answer:

void SUCCESS ()
 {
 int count = 0 ;
 ifstream f ("STORY.TXT") ;
 char s [20] ;
 while (! f. eof () )
 {
 f >>S;
 if (strcmpi (s, "STORY") = = 0)
 //OR if (strcmpi (s, "SUCCESS")==0)
 count++;
 }
 cout<<count;
 f.close () ;

OR
Any other correct function definition

Question 8.
Write a definition for function Economic ( ) in C++ to read each record of a binary file ITEMS.DAT, find and display those items, which costs less than 2500. Assume that the file ITEMS. DAT is created with the help of objects of class ITEMS, which is defined below :

class ITEMS
 {
 int ID; char GIFT [20] ; float cost ;
 public :
 void Get ()
 {
 cin>>CODE,-gets (GIFT) ;
 cin>>cost;
 }
 void See ()
 {
 COUt < }
 float GetCost 0 {return Cost;}.
 } ;

Answer:

void Economic ()
 {
 ITEMS I;
 ifstream fin (" ITEMS.DAT",ios:: binary);
 while (fin.read ((char *)&I,sizeof (I)))
 {
 if (I.GetCost ()<2500)
 I. See ();
 }
 fin. close ();
 }

OR
Any other correct equivalent function definition

Question 9.
Find the output of the following C++ code considering that the binary file CLIENTS. DAT exists on the hard disk with records of 100 members.

class CLIENTS
 {
 int Cno; char Name [20];
 public :
 void In (); void out () ;
 } ;
 void main ( )
 {
 fstream CF;
 CF.open "CLIENTS.DAT", ios :: binary | ios :: in);
 CLIENTS C ;
 CF.read ((char*) &C, sizeof (C));
 CF.read ((char*) &C, sizeof (C));
 CF.read ((char*) &C, sizeof (C));
 int POS = CF. tellg ()/sizeof (C) ;
 cout < <"PRESENT RECORD :"< < POS < <endl;
 CF.close ();
 }

Answer:
PRESENT RECORD : 3

Question 10.
Write function definition for WORDABSTART () in C++ to read the content of a text file, JOY. TXT, and display all those words, which are starting with either ‘A’, ‘a’ or ‘B’, ‘b’.
Example:
If the content of the file JOY.TXT is as follows :
I love to eat apples and bananas. I was travelling to Ahmedabad to buy some clothes.
The function WORDABSTART() should display the following:
apples bananas Ahmedabad buy

Answer:

void WORDABSTART ()
 {
 ifstream fil; fi1.open ("JOY.TXT");
 char W[20];
 fi1> >W;
 while(!fil.eof())//OR While(fil)
 {
 if(strlen(w)==4) cout<<W<<" "; fi1> >W;
 }
 fil.close ();//Ignore
 }

Question 11.
Write a definition for function OFFER() in C+ + to read each object of a binary file OFFER.DAT, find and display details of those ITEMS, which has status as “ON OFFER”. Assume that the file OFFER.DAT is created with the help of objects of class ITEMS, which is defined below:

class ITEMS
 {
 int ID;char Item[20];Status[20]; float Price;
 public:
 void GetonstockO
 {
 cin>>ID;gets(Item);gets(Status);
 cin>>Price;
 }
 void view()
 {
 cout<<ID<<":"<<Item<<":"< }
 char*IStatus(){return Status}.
 };

Answer:

void OFFER ()
 {
 ITEMS;
 ifstream fin;
 fin.open("OFFER.DAT",ios::binary);
 while(fin.read(char*)&G size of(G))
 {
 if strcmp (G.Get status(),"ON OFFER")==0)
 G.view();
 }
 fin.close()///Ignore
}

Short Answer Type Questions-II[3 marks each]

Question 1.
Given the binary file CAR.Dat, containing . records of the following class CAR type:

class CAR
 {
 int C_No;
 char C_Name[20];
 float Mileage;
 public :
 void enter( )
 {
 cin>> C_No ; gets(C_Name) ; cin >>Mileage;
 }
 void display( )
 {
 cout<<C_No; cout<<C_Name;
 cout<<Mileage;
 }
 int RETURN_Mileage( )
 {
 return Mileage;
 }
 };

Write a function in C++, that would read contents from the file CAR.DAT and display the details of car with mileage between 100 to 150.
Answer:

void CARSearch ()
 {
 fstream FIL;
 FIL.open("CAR.DAT" , ios::binary|ios::in);
 CAR C;
 int Found = 0;
 while(FIL.read((char*)&C,sizeof(C)))
 {
 if ((C.RETURN_Mileage( )>100) &&
 (C.RETURN_Mileage( ) < 150) )
 {
 C.display();
 Found++;
 }
 }
 if (Found==0)
 cout<<"Sorry! No car found with mileage between 100 to 150";
 FIL.close () ;
 }

Question 2.
Given a binary file “SPORTS.DAT” containing records of the following class :

class Player
 { char PNO[10]; //player number
 char Name[20]; //Name of player
 int rank; //rank of the player
 public :
 void EnterData()
 {
 gets (PNO) ;gets (Name);cin>>rank;
 }
 void DisplayData()
 { cout<<setw(12)<<PNO;
 cout<<setw(32)<<Name;
 cout<<setw(3)<<rank<<endl;
 }
 int Ret_rank() {return rank;}
 } ;

Write a function in C++ that would read contents of the file “SPORTS.DAT” and display the
details of those jolayers whose rank is above 500.
Answer:

Void show()
 {
 fstream file;
 file.open( ("SPORTS. DAT"),ios::binary:ios::in));
 player P;
 while (file.read((char*)&P,sizeof(P)))
 if(P.rank>500)
 { Pi
 P.DisplayData () ;
 P.close();
 }
 }

Question 3.
Assuming the Class WORKER as declared below, write a function in C++ to read the objects of WORKER from binary file named WORKER. DAT and display those records of workers, whose Wage is less then 300.

class WORKER
 {
 int WNO;
 char WName [30] ; float Wage;
 public:
 void Enter() {cin>>WNo; gets (WName); cin>>wage;}
 void DISPO {Cout<<ENo<<'*'< float GetWage () {return Wage,-}
 };

Answer:

void Display()
 {
 ifstream fin;
 fin.open("WORKER.DAT",ios::in | ios:: binary) ;
 WORKER W;
 while (! fin. eof () )
 {
 fin.read((char*)&W,sizeof(W) ) ;
 if W. GetWage() <300)
 W. DISP ();
 }
 fin. close ();
 }

Question 4.
Assuming the class TOYS as declared below, write a function in C++ to read the objects of TOYS from binary file TOYS. DAT and display those details of those TOYS, which are meant for children of AgeRange “5 to 8”.

class TOYS 
{
 int ToyCode;
 char ToyName[10];
 char AgeRange;
 public:
 void Enter()
 {
 cin>>ToyCode;
 gets (ToyName);
 gets(AgeRange);
 }
 void Display()
 {
 cout<<ToyCode
 ToyName<<endl;
 cout<<AgeRange<<endl;
 }
 char*WhatAge() {returnAgeRange;}
 };

Answer:

void READTOYS()
 { fstream obj;
 obj.open ("TOYS.DAT",ios::binary);
 TOYS T;
 while (obj.read ((char*)&T, Sizeof(T)))
 if(T. WhatAge()>=5&&T.whatAge<=8)
 T. Display();
 obj. Close();
 }

Question 5.
Assuming the class GAMES as declared below, write a functions in C++ to read the objects of GAMES from binary file GAMES.DAT and display those details of those GAMES, which are meant for children of AgeRange “8 to 13”.

class GAMES
 {
 int GameCode; char GameName [10];
 char AgeRange;
 public:
 void Enter()
 {
 cin>>GameCode;
 gets(GameName);
 gets (AgeRange);
 }
 void Display()
 {
 cout<<GameCode<<":"GameName<<endl;
 cout<<AgeRange<<ehdl;
 }
 char* AgeR() {return AgeRange};
 };

Answer:

Void READGAMES ()
 { fstream obj ;obj. open ("GAMES.DAT",ios::binary);
 Games T;
 while (obj. read ((char*)&T,size of(T) ) )
 if (T. AgeR()>=8&& T. What Age <=13) T. Display ();
 obj. closet)
 }

Question 6.
Assuming the class ANTIQUE as declared below, write a function in C++ to read the objects of Antique from binary file ANTIQUE. DAT and display those antique items, which are priced between 10000 and 15000.

class ANTIQUE
 {
 int ANO;
 char Aname [10] ;
 float price;
 public :
 void BUY() {cin>>ANO;gets(Aname); cin>> price;}
 void SHOW ( )
 {
 cout<<ANO<<endl;
 cout < cout<<Price<<endl;
 }
 float Get Price ( ) {return Price;}
 };

Answer:

void Disp( )
 {
 ifstream fin;
 fin.open ("ANTIQUE.DAT", ios:: in |ios : : out | ios : : binary);
 Antique A;
 while (!fin.eof( ))
 { -
 fin.read ((char*) &A, sizeof(A));
 if (A.GetPrice ( )> 10000 & A.GetPrice( )<15000)
 A.SHOW( );
 }
 fin.close( ) ;
 }

Question 7.
Assuming the class VINTAGE as declared below, write a function in C++ to read the objects of VINTAGE from binary file VINTAGE.DAT and display those vintage vehicles, which are priced between 200000 and 250000.

class VINTAGE {
 int VNO; //Vehicle Number
 char VDesc[10]; //Vehicle Description
 float price;
 public:
 void GET( ) {cin>>VNO;gets(VDesc); cin>>Price;}
 void VIEW( )
 {
 cout<<VNO<<endl;
 cout<<VDesc<<endl;
 cout<<Price<<endl;
 }
 float ReturnPrice ( ) {return Price;}
 };

Answer:

void Disp( )
 {
 ifstream fin;
 fin.open ("VINTAGE.DAT", ios ::in| ios : : binary);
 vintage V; while (Ifin.eof())
 {
 fin.read ((char*)&V, sizeof(V));
 if (V.ReturnPrice( )> 200000 & &V.ReturnPrice( )<250000)
 V.VIEW ( );
 }
 fin.close ( );
 }

Question 8.
Write a function display () in C + + to display all the students who have got a distinction (scored percentage more than or equal to 75) from a binary file “stud.dat”, assuming the binary file is containing the objects of the following class:

class Student
 {
 int rno;
 char sname [20];
 int percent
 public;
 int retpercent()
 {
 return percent;
 }
 void getdetails()
 {
 cin>>rno;
 gets(sname);
 cin>>percent;
 }
 void showdetails()
 {
 cout<<rno;
 puts(sname);
 cout<<percent;
 }
 };

Answer:

void display()
 {
 student s;
 ifstream i("stud.dat");
 while(i.read(char*)&s,sizeof(s)))
 {
 if(s.retpercent()>=75)
 S.showdetails();
 }
 i.close();
 }

Question 9.
Write a function in C++ to search for the details (Phone no. and Calls) of those phones, which have more than 800 calls from a binary file “phones.dat”. Assuming that this binary file contains records/objects of class phone, which is defined below.

class Phone
 {
 char Phoneno[10]; int Calls;
 public:
 void Get() {gets (Phoneno); cin>>Calls;}
 void Billing!){cout<<Phoneno<<"#"< int GetCalls(){return Calls;}
 };

Answer:

void Search ()
 {
 ifstream infile;
 infile, open ("phones.dat");
 if(! infile)
 {
 cout<<"can't open the'file"; exit(); } while(! infile.eof()) } { infile, read (Char #) & P, 
size of (P); if (P. GetCalls()>800)
 P. Billing ();
 }
 infile.close ();
 }

Question 10.
Write a function in C++ to search for the details (Number and Calls) of those Mobile phones, which have more than 100 calls from a binary file “mobile.dat”. Assuming that this binary file contains records/objects of class Mobile, which is defined below:

class Mobile
 {
 char Number [10]; int Calls;
 public:
 void Enter () {gets (Number); cin>>Calls;}
 void Billing () {cout<<Number<<"#"< int GetCalls() {return Calls;}
 } ;

Answer:

void Search ( )
 {
 Mobile m;
 ifstream f;
 f.open ("mobile.dat");
 while (!f.eof())
 {
 f.read ((char*)&m, sizeof (m));
 if (m.GetCalls0>100)
 m.Billing ();
 }
 }

Question 11.
Write a function in C++ to search for a camera from a binary file “CAMERA.DAT” containing the objects of class CAMERA (as defined below). The user should enter the model no and the function should search and display the details of the camera,

class CAMERA {
 long ModelNo;
 float Megapixel; int Zoom;
 char Details[120];
 public:
 void Enter(){cin>>ModelNo>>Megapixel >> Zoom;
 gets (Details);}
 void Display( )
 {cout< <ModelNo< <MegaPixel<<Zoom< long GetModelNo(){return ModelNo;}
 };

Answer:

void cameraSearch ()
 {
 fstreamFIL;
 FIL.openCCAMERA.DAT", ios::binary|ios :: in );
 CAMERA B;
 long bn; int Found = 0;
 cout<<"Enter the Model Number"; cin >> bn;
 while (FIL.read((char*)&B, sizeof (B)))
 {
 if (FIL.GetModelNo() = = bn)
 {
 B.Display();
 Found ++;
 }}
 if(Found = = 0)
 cout<<"Sorry ! Camera not found"<<endl;
 FIL.close( );
 }

Long Answer Type Questions[4 marks each]

Question 1.
Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TXT. and display all those words, which have four characters in it.
Example:
If the content of the file FUN.TXT is as follows :

When I was a small child, I used to play in the garden with my grand mom.
Those days were amazingly funful and I remember all the moments of that time.

The function WORD4CHAR() should display the following:

When used play with days were that time.

Answer:

Void WORD4CHAR ()
 {
 ifstream f("FUN.TXT");
 char ch[20] ;
 while (!f.eof())
 {
 f >>ch;
 if(strlen(ch)==4)
 cout<<ch,
 }
 f close(),
 }

Question 2.
Write a definition for function ONOFFER()in C++ to read each object of a binary file TOYS. DAT, find and display details of those toys, which have status as “ON OFFER”. Assume that the file Toys.DAT is created with the help of objects of class TOYS, which is defined below:

Class TOYS
 {
 int TID; char Toy[20], Status[20];
 float MRP;
 Public:
 void Getinstock()
 {
 cin>>TID;gets (Toy) ; gets (Status) ; cin»MRP:}
 void View()
 {
 Cout<<TID<<":"<<Toy<<":"<<MRP<< "":"<<Status<<endl;
 }
 Char *SeeOffer() {Return Status;}
 } ;

Answer:

Void ONOFFER ()
 {
 TOYS T;
 Ifstream fin;
 fin.open("TOYS.DAT", ios ::binary) ;
 while(fin.read((char*)&T,size (T) ))
 {
 if (strcmp(T.see offer(),"ON OFFER")= = 0)
 T.view();
 }
 fin.close();//Ignore
 }

Question 3.
Find the output of the following C++ code considering that the binary file CLIENT.DAT exists on the hard disk with a data of 1000 clients :

Class CLIENT
 {
 int Ccode;char CName[20];
 public:
 void Register();void Display();
 };
 void main()
 {
 fstream CFile;
 CFile.Open ( "CLIENT. DAT",ios::binary|ios::in); CLIENT C;
 CFile. read ( (char*) & C , sizeof(C)) ;
 cout<< "Rec: "<<CFile.tellg()/ sizeof(C)<<endl;
 CFile. read ( (char*) & C , sizeof*(C));
 CFile . read ( (char*) & C , sizeof(C));
 cout<<"Rec:"<<CFile.tellg()/ sizeof(C)<<endl;
 CFile.close () ;
 }

Answer:
Rec: 1
Rec: 3

Read More

Chapter 2: Basic Concepts of OOP Classes & Objects | NCERT Solution for class 12th COMPUTER SCIENCE solution

NCERT Solutions for Class 12 Computer Science (C++) – Implementation of OOP Concepts in C++

TOPIC-1 Classes

Short Answer Type Questions-I    [2 marks each]

Question 1:
Observe the following C++ code and answer the question (i) and (ii):    [Delhi, 2015]

class Traveller
 {
 long PNR;
 char TName [20];
 public :
 Traveller ( ) //Function 1
 {cout<<"Ready"<<endl;}
 void Book (long P, char N [ ])
 //Function 2
 {PNR = P, strcpy (TName, N);} void print ()    //Function 3
 {cout<<PNR << TName <<endl;} ~Traveller ( )    //Function 4
 {cout<<"Booking cancelled!"<<endl;
 } ;

(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code: void main ( )
{
Traveller T;
___________    //Line 1
___________    //Line 2
}//Stops here
Answer:
T. Book (1234567, “Ravi”);
//Line 1
T. Print ();
//Line 2
(1/2 Mark for writing each correct Function)
[ICBSE Marking Scheme 2015]
(ii) Which function will be executed at }//Stops here ? What is this function referred as ?
Function 4
OR
~ Traveller ( )
It is a destructor function.
(1/2 Mark for writing Function 4 or- Traveller ())
(1/2 Mark for referring Destructor)
[CBSE Marking Scheme 2015]

Question 2:
Write the definition of a class PIC in C++ with following description :    [Delhi, 2015]
Private Members
— Pno // Data member for Picture Number (an integer)
— Category // Data member for picture category (a string)
— Location // Data member for Exhibition Location (a string)
— FixLocation // A member function to assign // Exhibition Location as per category // as

CategoryLocation
ClassicAmina
ModernJim Plaq
AntiqueUstad Khan

Public Members
shown in the following table
— Enter ( ) // A function to allow user to enter values
// Pno, category and call FixLocation () function
— SeeAll ( ) // A function to display all the data members.
Answer:

class PIC
{
 int Pno;
 char Category [20] ; 
char Location [20]; 
void FixLocation ( ); 
public :
 void Enter ( ) ; 
void SeeAll ( );
 };
 void PIC : FixLocation ( ) 
 {
 if (strucmpi (category, "Classic”)
 = = 0)
 strcpy (Location, "Amina") ;
 else  if (strcmpi (category,'' / "Modern") = = 0)
 strcpy (Location, "Jim Plaq") ; else if strcmpi (category, "Antique") = = 0) 
strcpy (Location, "Ustad khan");
void PIC : : Enter ( )
 {
 cin>>Pno; gets (Category) ; 
FixLocation ( );
}
 void PIC :    SeeAll ( )
 {
 cout<<Pho<<Category<<Location<<endl;
 }

(1/2 Mark for correct syntax for class header)
(1/2 Mark for correct declaration of data members)
(1 Mark for correct definition of FixLocation ( ))
(1 Mark for correct definition of Enter ()
with proper invocation of FixLocation () function)

(1 Mark for correct definition of See All( ))
NOTE:
•  Deduct % Mark if FixLocation ( ) is not invoked properly inside Enter ( ) function
•  No marks to be deducted for defining Member Functions inside the class
•  strcmp () strcmpi () acceptable [CBSE Marking Scheme 2015]

Question 3:
What is the difference between the members in private visibility mode and the members in protected visibility mode inside a class ? Also, give a suitable C++ code to illustrate both. [O.D, 2012]
Answer:
Private:
This type of member can only be accessed by code in the same class.    [1]
Protected:
This type of member can only be accessed by code in the same class, or in a derived class. [1]

//C++ code : class Me
{
public :
int a, b;
protected :
int c, d;  //protected Member
private :
int e, f;  //Private Member
}

Short Answer Type Questions-II [3 marks each]

Question 1:
Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included.    [O.D, 2016]

class BOOK
 {
 long Code;
char Title[20];
float Price; 
Public:
 BOOK ( )
 //Member Function 1
 {
 cout < <"Bought"< < endl;
 Code=10;strcpy(Title,"NoTitle")
;Price=100;
 }
 BOOK(int C, char T[], float P) //Member Function 2
 {
 Code=C;
 strcpy(Title,T);
 Price=P;
 }
 void Update(float P)
 //Member Function 3
 {
 Price+=P;
 }
 void Display ( )
 //Member Function 4
 {
 cout<<Code<<":"<<Title<<":"<<Pr ice<<endl;
 }
 -BOOK()
 //Member Function 5
 {
 cout<<"Book Discarded!"<<endl;
 }
 } ;
 void main()
 //Line 1
 {
 //Line 2
 BOOK B, C(101,"Truth",350);
 //Line 3
 for (int I=0;I<4;I++)
 //Line 4
 {
 //Line 5
 B.Update(50);C.Update(20);
 //Line 6
 B.Display 0 ;C.Display() ;
 //Line 7
 }
 //Line 8
 }
 //Line 9

(i) Which specific concept of object oriented programming out of the following is illustrated by Member Function 1 and Member Function 2 combined together ?
> Data Encapsulation
> Polymorphism
> Inheritance
> Data Hiding
(ii) How many times the message “Book Discarded!” will be displayed after executing the above C+ + code ? Out of Line 1 to Line 9, which line is responsible to display the message “Book Discarded!”?
Answer:
(i) Polymorphism
(1 Mark for mentioning the correct concept name)
(ii) 2 times
Line 9.
(1/2 Mark for writing correct number of times)
OR
(1/2 Mark for writing – “No execution due to wrong syntax in Line 3”)
OR
Any other equivalent answer conveying similar meaning
(1/2 Mark for writing correct line number)
[CBSE Marking Scheme 2016]

Question 2:
Write the definition of a class CITY in C + + with following description :    [O.D, 2016]
Private Members

-    CCode    //Data member for
 City Code (an integer)
 -    CName    //Data    member    for
 City Name    (a string)
 -    Pop    //Data    member    for
 Population (a long int)
 -    KM    //Data    member    for
 Area Coverage (a float)
 -    Density    //Data    member    for
 Population Density (a float)
 -    DenCalO    //A member function
 to calculate............... 
 //Density as Pop/KM 
Public Members
 -    Record 0    //A function to
 allow user to enter values of //Acode, Name, pop, KM and call DenCalO function
 -    view    //A function to
 display all the data members 
//also display a message "Highly Populated City" 
//if the Density is more than 10000

Answer:

Class City
 {
 int Ccode;
 Char CName [2 0] ; 
long int Pop; 
float KM; 
float Density; 
void Dencal (); 
Public :
 void Record(); 
void View();
 };
 void CITY :: 
Record ( )
 {
 cin>>ccode; 
gets(C Name);
 cin>>pop; 
cin»KM; 
Dencal () ;
 }
 void CITY :: view()
 {
 Cout < < code < < CName <<Pop<<KM<< Density;
 if (Density>10000)
 cout<<"Highly populated city";
 }
 void CITY :: Dencal()
 {
 Density=Pop/KM;
 }

Question 3:
Write the definition of a class METROPOLIS in C+ + with following description :    [Delhi, 2016]

Private Members
 -    MCode    //Data member for
 Code (an integer)
 -    MName    //Data member for
 Name (a string)
 -    MPop    //Data member for
 Population (a long int)
 -    Area    //Data member for
 Area Coverage (a float)
 -    PopDens    //Data member for
 Population Density (a float)
 -    CaldenO    //A member function
 to calculate.........
 //Density as PopDens/Area
Public Members
 -    Ender ()    //A function to
 allow    user to  enter values  of
 //MCode, MName, MPop, Area and call claDen () //function
 -    viewall    //A function    to
 display all the data members 
//also display a message "Highly Populated Area" 
//if the Density is more than 12000

Answer:

class METROPOLIS
 {
 int MCode; 
char MName[2 0] ; 
long int MPop; 
float Area; 
float PopDens; 
void CalDen() 
public:
 Void Enter(); 
void veiw ALL();
 } ;
 void METROPOLIS::Enter()
 {
 cin>>Mcode; 
gets(MName);
 Cin>>Mpop;
 Cin>>Area;
 CalDen();
 }
 void METROPOLIS::viewALL ( )
 {
 cout < <Mcode< <Mname< <Area< < "Popens",
 if (Pop Dens > 12000) cont<<"Highly Populated Area";
 }
 void METROPOLIS::call Den()
 {
 PopDens =Mpop/Area
 }    [3]

Question 4:
Answer the questions (i) to (iv) based on the following:    [Delhi, 2016]

class PRODUCT
 {
 int Code; 
char Item[20]; 
protected: 
float Qty; 
public:
 PRODUCT();
 void Getln(); 
void show();
 {
 int WCode;
 Protected :
 char Manager[20]; 
public:
 WHOLE SALER(); 
void Enter(); 
void Display();
 }
 class SHOWROOM :    public PRODUCT,
 private WHOLE SALER
 {
 Char Name [20], 
public :
 SHOWROOM(); 
void Input(); 
void View();
 } ;

(i) Which type of Inheritance out of the following is illustrated in the above example ?
–    Single Level Inheritance
–    Multi Level Inheritance
–    Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class SHOWROOM.
(iii) Write the names of all the member functions, which are directly accessible by an object of class SHOWROOM.
(iv) What will be the order of execution of the constructors, when an object of class SHOWROOM is declared ?
Answer:

(i) Multiple
(ii) Name, City, Manager, Qty
(iii) Input (), View (), Getln (), Show ()
(iv) PRODUCT (), WHOLESALER () , SHOWROOM ()

[CBSE Marking Scheme 2016]

Question 5:
Write the definition of a function Fixpay (float Pay[], int N) in C+ +, which should modify each element of the array Salary pay N elements, as per the following rules :    [O.D, 2016]

Existing Pay ValueRequired Modification in Value
If less than 1,00,000Add 35% in the existing value
If >=1,00,000 and <20,000Add 30% in the existing value
If >=2,00,000Add 20% in the existing value

Answer:

Void Fixpay (float pay[],int N)
 {
for(int i=0; i<N; i++)
 {
 if(pay[i] < 100000)
 pay[i]+ = pay[i]*0.35; 
else if (pay[i] < 200000) 
pay[i]+ = pay[i]*0.30; else
 pay[i]+ = pay[i]*0.20;
 }
 }

Long Answer Type Questions  [4 marks each]

Question 1:
Define a class Candidate in C++ with the following specification :    [Delhi, 2015]
Private Mumbers:
A data members Rno (Registration Number) type long
A data member Cname of type string
A data members Agg_marks (Aggregate Marks) of type float
A data members Grade of type char
A member function setGrade() to find the grade as per the aggregate marks obtained by the student. Equivalent aggregate marks range and the respective grade as shown below.

Aggregate Marks                      Grade
> = 80                                          A
Less than 80 and >    =    65     B
Less than 65 and >    =    50     C
Less than 50                               D
Public members:
A constructor to assign default values to data members:
Rno = 0, Cname “N.A”, Age_marks = 0.0
A function Getdata ( ) to allow users to enter values for Rno. Cname, Agg_marks and call function setGrade () to find the grade.
A function dispResult () to allow user to view the content of all the data members.
Answer:

class Candidate 
{ long Rno;
 char Cname [20]; 
float Agg_marks; 
char Grade; 
void setGrade ()
 { if (Agg_marks>= 80)
 Grade = 'A';
 else if (Agg_marks<80 && Agg_ marks>=65)
 Grade = 'B' ;
 else if (Agg_marks<65 && Agg_ marks>=50)
 Grade = 'C'; 
else
 Grade = 'D' ;
 }
 public;
 Candidate ( )
 {
 Rno=0;
 Strcpy (Cname, ''N.A.''); 
Agg_marks=0.0;
 }
 void Getdata ()
 {
 cout<<''Registration No''; 
cin>>Rno; 
cout<<"Name''; 
cin>>Cname;
 cout<<Aggregate Marks''; 
cin>>Agg_marks; 
set Grade ();
 }
 void dispResult ()
 {
 cout<<"Registration No''<<Rno;
cout<<"Name''<<Cname;
 cout<<"Aggregate Marks''<<Agg_
 marks;
 }

(1/2 mark for correct syntax for class header]
(1/2 marks for correct declaration of data members]
(1/2 mark for correct definition of the constructor Candidate ()]
[1 mark for correct definition of setGrade ()]
[1 mark for correct definition of Getdata of Getdata () with proper invocation of setGrade ()]
(1/2 mark for correct definition of dispresult]

Question 2:
Define a class Customer with the following specifications.    [CBSE SQP 2015]
Private Members:
Customer_no integer
Customerjname char (20)
Qty integer
Price, TotalPrice, Discount, Netprice float
Member Functions:
Public members:

  1. A constructer to assign initial values of Customer_no as 111, Customer_name as “Leena”, Quantity as 0 and Price, Discount and Netprice as 0.
  2. Input() – to read data members (Customer_ no, Customer_name, Quantity and Price) call Caldiscount().
  3. Caldiscount ( ) – To calculate Discount according to TotalPrice and NetPrice
    TotalPrice = Price*Qty
    TotalPrice > =50000 – Discount 25% of TotalPrice TotalPrice >=25000 and TotalPrice <50000 – Discount 15% of TotalPrice TotalPrice <25000 – Discount 10% of TotalPrice Netprice = TotalPrice-Discount Show() – to display Customer details.

Answer:

class Customer
 {
 int Customer_no; 
char Customer_name; 
int Qty;
 float Price, TotalPrice, Discount, Netprice; 
public:
 Customer ( )    [1]
 {
 Customer_no = 111;
 strcpy( Customer_name, "Leena");
 Qty=0 ;
 Price =0, Discount=0, Netprice=0;
 }
 void Input ()    [1]
{
 cin>>Custome r_no; 
gets( Customer_name); 
cin>>Qty>>TotalPrice;
 Caldiscount();
 }
 void Caldiscount()    [1]
 {
 TotalPrice = Price*Qty; 
if ( TotalPrice >= 50000)
 Discount = 0.25 * TotalPrice;
 else if (TotalPrice >= 2 5000) 
Discount = 0.15 * TotalPrice; 
else
 Discount = 0.10 * TotalPrice; 
Netprice = TotalPrice - Discount;
 }
 void Show ( )    [1]
 {
 cout<<Customer_no<<" name <<"    "<<Qty<" "<<TotalPrice <<" "<<Netprice;
 }
 };

Question 3:
Define a class CONTEST folowing description:
Private Data Members

Eventno               integer
Description         char(30)
Score                    integer
Qualified             char

Public Member functions
• A constructor to assign initial values Evento as 11, Description’s “School level”, Score as 100, Qualified as ‘N’
• Input()-To take the input for Eventno, Description and Score.
• Award (int cutoffscore) – To assign Qualified as ‘Y’, If score is more than the cutoffscore that is passed as argument to the function, else assign Qualified as ‘N’.
• Displaydata()-to display all the data members.
Answer:

class CONTEST
 {
 private :
 int Eventno;
 char ‘Description [30];
 public :
 Contest () ;
 void Input () ;
 void Award (int cutoffscore);    [1]
 void Display ();
 };
 Contest : : contest()
 {
 Evento =11 ;
 Description = "school level" ;
 Score = 100;
 Qualified = 'N' ;
 }    [1]
 void Contest : : Input ( )
 {
 cin >> Eventno;
 gets (Description);
 cin >> Score ;
 }    [1]
 void CONTEST : :    Award (in cut of
 score)
 {
 int K = cutoffscore ;
 (Score > K)
 Qualified = 'Y' ;
 else
 Qualified = 'N' ;
 }
 void CONTEST ()
 {
 cout << Event No : << Eventno << endl ;
 cout << Description :    <<
 Description << endl;
 cout << Score : << Score << Endl
 cout << Qualified : << Qualified << endl;
 } [1]

Question 4:
Consider the following class state:

class State 
{
 protected :
 int tp; //no. of tourist places 
public :
 State()
 {
 tp = 0 ;
 }
 void inctp ( )
 {
 tp++ ;
 }
 int gettp ( ) 
{
 return tp;
 }
 };

Write a code in C+ + to publically derive another

class ‘District’ with the following additional members derived in the Public visibility mode.
Data Members
distname – char (50)
population – long
Member functions:
• dinput ( ) – To enter distname and population.
• doutput ( ) – To display distname and population on screen.
Answer:

class District ; public state
 { [1]
 private :
 char *distname [50]; 
long population; 
pubilc :    [1]
 void dinput ()  [1]
 {
 gets (distname); 
cin ... population ;    [1]
 }
 void doutput ()
 {
puts (distname) ;
 cout >> population ;    [1]
 }
 }

Question 5:
Define a class CABS in C++ with the following specification:
Data Members
• CNo – to store Cab No
• Type – to store a character ‘A’, ‘B’ or ‘C’ as City Type
• PKM – to store Kilo Meter charges
• Dist – to store Distance travelled (in KM)
Member Functions
• A constructor function to initialize Type as ‘A’ and CNo as ‘1111’
• A function ChargesQ to assign PKM as per
the following table:

TypePerKM
A25
B20
C15

• A function Register() to allow administrator to enter the values for CNo and Type. Also, this function should call Charges() to assign PKM Charges.
• A function ShowCab() to allow user to enter the value of Distance and display CNo, Type, PKM, PKM “‘Distance (as Amount) on screen    [Delhi, 2014]
Answer:

class CABS
 {
 int CNo; 
char Type; 
int PKM; 
float Dist;
 CABS
 {
 Type='A';
 CNo=llll;    [1]
 }
 void Charges()
 {
 if (Type=='A')
 PKM=25;
 if(Type=='B')
 PKM=20;
 if(Type=='C')
 PKM=15; PKM= 0;
 }    [1]
 void Register ( )
 {
 cin>>CNo>>Type;
 PKM=Charges ()    ;    [1]
 }
 void ShowCab()
 {
 cin>>Dist;
 cout<<CNo<<Type<<PKM<<PKM*Dist;
 }
 };    [1]

Question 6:
Define a class Tourist    in C + + with the following specification:
Data Members
• CNo – to store Cab No
• CType – to store a character ‘A’, ‘B’, or ‘C’ as City Type
• PerKM – to store per Kilo Meter charges
• Distance – to store Distance travelled (in KM) Member Functions
• A constructor function to initialize CType as ‘A’ and CNo as ‘0000’
• A function CityCharges() to assign PerKM as per the following table:

CTypePerKM
A20
B18
C15

• A function RegisterCab() to allow administrator to enter the values for CNo and CType. Also, this function should call CityCharges() to assign PerKM charges.
• A function Display() to allow user to enter the value of Distance and display CNo, CType, PerKM, PerKM*Distance (as Amount) on screen.    [O.D, 2014]
Answer:

Class Tourist
 {
 int CNo; 
char CType; 
int PerKM; 
float Distance;
 Tourist()
 {
 CType='A';
 CNo=0000;
 }
 void CityCharges ()    [1]
 {
 if(CType=='A')
 PerKm=20;
 if(CType=='B')
 PerKM=18;
 if(CType=='C')
 PerKM=15;
 }    [1]
 void RegisterCab()
 {
 cin>>CNo>>CType;
 CityCharges();
 }
 void Display ()    [1]
 {
 cin>>Distance; 
cout<<CNo<<CType<<PerKM<< PerKM*Distance;
 } [1]

Question 7:
Define a class Seminar with the following specification:
private members
Seminarld               long
Topic                         string of 20 characters
VenueLocation     string of 20 characters
Fee                             float

CalcFee() function to calculate Fee depending on VenueLocation

VenueLocationFee
Outdoor5000
Indoor Non-AC6500
Indoor AC7500

Public members
Register() function to accept values for SeminarlD, Topic, VenueLocation and call CalcFee() to calculate Fee
ViewSeminar() function to display all the data members on the screen [CBSE Comptt., 2013]
Answer:

class Seminar
 {
 private:
 long Seminarld; 
char Topic [20] ; 
char VenueLocation[20]; 
float Fee;
 void CalcFeeO    [1]
 {
 if    (strcmp    (VenueLocation, ''Outdoor'')==0)
 Fee=5000;
 else {if (strcmp (VenueLocation, ''Indoor Non-AC" ) = = 0)
 Fee=6500;
 else {if (strcmp (VenueLocation, ''Indoor AC'')==0)
 Fee = 7500;    [1]
 }
 public:
 void Register ()
 {
 cin>>seminarld; 
gets (Topic) ; 
gets (VenueLocation); 
cin>>Fee;
 CalcFee () ;
 } [1]
 Void ViewSeminar ()
 {
 cout<<SeminarId; 
puts (Topic); 
puts (VenueLocation); 
cout<<Fee;
 }
 }; [1]

Question 8:
Define a class Bus in C++ with the following specifications:
Data Members
•  Busno—to store Bus No
•  From—to store Place name of origin
•  To—to store Place name of destination
•  Type—to store Bus Type such as ‘O’ for ordinary
•  Distance—to store the Distance in Kilometers
•  Fare—to store the Bus Fare
Member Functions
• A constructor function to initialize Type as ‘O’ and Freight as 500
• A function CalcFare( ) to calculate Fare as per the following criteria
Type        Fare
‘O’            15*Distance
‘E’            20*Distance
‘L’            24*Distance
• A function Allocate() to allow user to enter values for BusNo, From, To, Type and Distance.    [O.D, 2013]
Answer:

class Bus
 {
 int Busno; 
char From [20]; 
charTo[20]; 
char Type; 
float Distance;
 float Fare, ;    [1]
 BUS ( )
 {
 Type='O';
 Fare=500;
 }
 void CalcFare( )    [1]
 {
 if(Type=='O')
 Fare = 15*Distance;  
if (Type=='E')
 Fare = 20* Distance;
 if(Type=='L')
 Fare = 24*Distance;
 void Allocate( ) [1]
 {
 cout<<''Enter  Bus Number"; cin>>Busno; 
cout<<''Enter Source:"; gets(From);
 cout<<''Enter  Destination"; gets(To); 
cout<<''Enter Type:"; cin>>Type; 
cout<<''Enter Distance (in kms)"; cin>>Distance;
 }
 }; [1]

Question 9:
Define a class Tourist in C + + with the following specifications:
Data Members
•  Carno—to store Bus No
•  Origin—to store Place name of origin
•  Destination—to store Place name
•  Type—to store Car Type such as ‘E’ for Economy
•  Distance—-to    store the Distance in Kilometers
•    Charge—to store the Car Fare
Member Functions
• A constructor function to initialize Type as ‘E’ and Freight as 250
• A function CalcCharges () to calculate Fare as per the following criteria
Type              Fare
‘E’             16* Distance
‘K’             22* Distance
T’              30*Distance

• A function Enter( ) to allow user to enter values for CarNo, Origin, Destination, Type and Distance. Also, this function should call CalcCharges () to calculate fare.
• A function Show() to display contents of all data members on the screen. [Delhi, 2013]
Answer:

class Tourist
 {
 int Carno; char Origin[20]; 
char Destination[20]; 
char Type; 
float Distance;
 float Charges;
 Tourist ( )    [1]
{
 Type='E';
 int charges=250;
 }
 void CalcCharges( )
 {
 if(Types=='E')
 Charges = 16*Distance; if(Type=='A')
 Charges = 22‘Distance; if(Type=='L')
 Charges = 30*Distance;
 }
 void Enter( )
 {
 cout<<''Enter Car Number"; cin>>Carno;
 cout<<''Enter Source:"; gets(Origin);
 cout<<''Enter Destination"; gets(Destination);
 cout<<''Enter Type:"; cin>>Type;
 cout<<''Enter Distance (in
 kms) " ;    [1]
 cin>>Distance;
 CalcCharges( );
 }
 void Show( )
{
 cout<< "Car Number:"<<Carno;
 cout<< "Origin:";
 puts(Origin);
 cout<< "Destination:";
 puts(Destination);
 cout<<"Fare:"<<Charges;
 }
 };    [1]

Question 10:
Define a class Hand set in C++ with the following description : Private members :
Make—of type string
Model—of type string
Price—of type long int
Rating—of type char
Public members:
Function Read_Data to read an object of Handset type.
Function Display( ) to display the details of an object of type Handset type.
Function RetPrice() to return the value of Price of an object of Handset type. [CBSE SQP, 2013]
Answer:

class Handset
 {
 private: 
char Make[20] ; 
char Model[20] ; 
long int Price;
 char Rating;    [1]
 public :
 void Read_Data( )
 {
 gets(Make); 
gets(Model);
 cin>>Price;  [1]
 cin>>Rating;
 }
 void Display()
 {
 puts (Make);    [1]
 puts(Model) ; 
cout<<Price; 
cout<<Rating;
 }
 long int RetPrice( )
 {
 return(Price);
 }
 };    [1]

Question 11:
Find the output of the following program :

#include<iostream.h> 
class METRO 
{
 int Mno, TripNo, PassengerCount; public: METRO(int Tmno=l)
 {
Mno=Tmno;
 TripNo=0;
 PassengerCount=0;
 }
 void Trip(int PC=20)
 {
 TripNo++;
 PassengerCount+=PC;
 }
 void StatusShow( )
 {
 c o u t < < M n o < < "  :  " <  <  T  r  i  p N o < < "  : " 
< < P a s s e n g e r C o u n t < < e n d l ;
 } ;
 void main( )
 {
 METRO M(5),T;
 M.Trip( ) ;
 T.Trip(50) ;
 M.StatusShow( ) ;
 M.Trip(30) ;
 T.StatusShow( );
 M.StatusShow( );
 }    [O.D, 2012]

Answer:

5:1:20
1:1:50
5:2:50    [4]

Question 12:
Define a Class RESTRA in C++ with following description:
Private members
• Food Code of type int
• Food of type string
• FType of type String
• Sticker of type String
• A Member function GetSticker( ) to assign the following values for Food Sticker as per the given FType:
FType                        Sticker
Vegetarian                GREEN
Contains egg            YELLOW
Non-Vegetarian       RED
Public Members
• A function GetFood() to allow user to enter values for FoodCode, Food, FType and call function GetSticker() to assign Sticker.
• A function ShowFood( ) to allow user to view the content of all the data members. [O.D, 2012]
Answer:

class RESTRA
 { 
char FoodCode;
 charFood[20] ,FType [20] ,Stick er[20];
 void GetSticker()
 {
 if (strcmp (FType, ' 'Vegetari an")==0)
 {
 strcpy(Sticker,"GREEN");
 }    [ ]
 if    (strcmp(FType,''ContainsEgg")==0)
 {
 strcpy(Sticker, "YELLOW");
 }
 if    (strcmp(FType,''Non-Vegetarian") ==0)
 strcpy(Sticker,''RED");
 }
 public:    [1]
 void GetFood()
 {
 cout<<"Enter    FoodCode,    Food,
 Food Type";
 cin>>FoodCode; 
gets(Food); 
gets(FType);
 GetSticker( );
 }    [1]
 void ShowFood( )
 {
 cout<<''Enter    Food    Code,    Food,
 FoodType, Sticker:";
 cout < < FoodCode;
 puts(Food);    
puts(FType);
 puts(Sticker);
 > ,
 };    [1]

Question 13:
Find the output of the following program :

#include<iostream.h> 
class TRAIN {
 int Tno, TripNo, PersonCount, T, N; 
public:
 Train(int Tmno=l)
 { Tno=Tmno; TripNo=0; PersonCount = 0; }
 void Trip (int TC =100)
 {TripNo++; PersonCount =TC;}
 void    show()    {cout<<Tno<<'' :  ''<<TripNo<<''    :
 "<<PersonCoun<<endl;}
 } ;
 void main( )
 {
Train T(10), N;
 N.Trip();
 T.show();
 N.Trip(70) ;
 N.Trip(4 0) ;
 N.show( );
 T.show( );
 }    [Delhi, 2012]

Answer:

10:0:0
1:2:140
10:1:70    [4]

Question 14:
Define a class Candidate in C++ with the
following description:
Private members
• A data member RNo(Registration Number) of type long
• A data member Name of type String
• A data member Score of type float
• A data member Remarks of type String
•  A member function AssignRem() to assign the remarks as per the score obtained by the candidate.
•   Scor6 range and the respective remarks are shown as follow:
Score           Remarks
>=50           Selected
<50             Not Selected
Public members
• A function ENTERQ to allow user to enter values for RNo, Names, Score and call function AssignRem() to assign the remarks.
• A function display() to allow user to view the content of all data members. [Delhi, 2012]
Answer:

class Candidate
 {
 long RNo; 
char Name[40]; 
float Score;
 [1]
 char Remarks[20] 
void AssignRem()
 if (Score>=50)    [1]
 strcpy(Remarks, "Selected"); else
 strcpy(Remarks,''Not Selected");
 }
 public: 
void Enter()
 { [1]
 cout<<''Enter the values for RNo, Name, Score";
 cin>>RNo;
 gets(Name);
cin>>Score;
 AssignRem( );    [1]
 }
 void Display( )
 {
 cout<<RNo<<Score;
 puts(Name); puts(Remarks);
 }
 }; [1]

Question 15:
Define a class Applicant in C++ with the following description:
Private members
•  A data member ANo(Admission Number) of type long
•  A data member Name of type String
•  data member Agg(Aggregate Marks) of type float
•  A data member Grade of type char
•  A member function GradeMe() to assign the grades as per the aggregate obtained by the candidate.
•  Score range and the respective remarks are shown as follow:
Aggregate                   Grade
>=80                               A
less than 80 and > = 65     B
less than 65 and > = 50     C
less than 50                         D
Public members
• A function ENTER( ) to allow user to enter values for ANo, Names, Aggregate and call function GradeMe () to assign grade.
• A function RESULT( ) to allow user to view the content of all data members. [O.D, 2012]
Answer:

class Applicant
 {
 long ANo; 
char Name[40]; 
float Agg; 
char Grade;
 void GradeMe ( )    [1]
 {
 if (Agg>80)
 Grade='A';
 if (Agg<80 && Agg>=65)
 Grade='B';
 if (Agg<65 && Agg>=50)
 Grade='C'; if(Agg<50)
 Grade='D';
 }
 public: 
void Enter ( )
{
 cout<<''Enter the values for Ano, Name, Agg" ; 
cin>>ANo; 
gets(Name);
 cin>>Agg;    [1]
 GradeMe( );
 }
 void Result( )
 {
 cout<<ANo<<Agg;
 puts(Name); puts(Grade);
 }
 };    [1]

Question 16:
Define a class ITEM in C++ with the following description:
Private Members
• Code of type integer (Item Code)
• Iname of type string (Item Name)
• Price of type float (Price of each item)
• Qty of type integer (Quantity of item in stock)
• Offer of type float (Offer percentage on the item)
• A member function GetOffer( ) to calculate Offer percentage as per the following rule :
If Qty < = 50 Offer is 0
If 50 < Qty < = 100 Offer is 5
If Qty >100 Offer is 10
Public Members
• A function GetStock() to allow user to enter values for Code, Iname, Price, Qty and call function GetOffer() to calculate the offer.
• A function ShowItem( ) to allow user to view the content of all the data members.
Answer:

class Item
 {
 int Code; 
char Iname [20]; 
float Price; 
int Qty; 
float Offer; 
void GetOffer( ) ; 
public:
 void GetStock ()
 {
 cin>>Code;
 gets (Iname) ;    // OR cin.
 getline (Iname, 80); Or cin>>Iname;
 cin>>Price>>Qty;
 GetOfferO ;
 }
 void Showltem ()
 {
 cout<<Code<<Iname<<Price<<Qty<<Offer;
 };
 void Item : GetOffer ()
 {
 if (Qty < =50)
 Offer = 0;
 else if (Qty <= 100)
 Offer = 5; //OR Offer = 0.05; 
else
 Offer = 10; //OR Offer = 0.1;
 }

(1/2 Mark for correct syntax for class header)
(1/2 Mark for correct declaration of data members) (1 Mark for correct definition of Get OfferQ)
(1 Mark for correct definition of Get Stock () with proper invocation of Get Offer () function)
(1 Mark for correct definition of ShowltemO)
Note : Deduct 1/2 Mark if Get Offer () is not invoked properly inside Stock Ofunction.

Question 17:
Define a class Stock in C++ with following description;
Private Memebrs
•  ICode of type integer (Item Code)
•  Item of type string (Item Name)
•  Price of type float (Price of each item)
•  Qty of type integer (Quantity in stock)
•  Discount of type float (Discount percentage on the item)
•  A member function FindDisc() to calculate discount as per the following rule :
If Qty< =50              Discount is 0
If 50<Qty,=100       Discountis 5
If Qty >100              Discount is 10
Public Members
• A function buy () to allow use to entervalue for ICode, Item, Price, Qty and call function Find Disc () to calculate the discount.
• A function Show All() to allow user to view the content of all the data members.
Answer:

class Stock
 {
 int ICode, Qty ; 
char Item[20]    ;
 float Price, Discount; 
void FindDisc ()    ;
 public :
 void Buy ()    ;
 void ShowAll ()    ;
 };
 void Stock :    : Buy ( )
{
cin>>ICode ; 
gets (Item) ; 
cin >> Price ; 
cin >> Qty ;
 Find Disc () ;
 }
 void Stock : : FindDisc ()
 {
 If (Qty < = 50)
 Discount = 0 ; 
else if (Qty < = 100)
 Discount =5;    // = 0.05 ;
 else
 Discount = 10 ;    // =0.1;
}
 void Stock :    : ShowAll ()
 {
c o u t < < I C o d e < < ' \ t ' < < l t e m < < 1 \ 
t1<<Price<<'\t'                                 <<Qty<<'\
t1<<Discount<<endl ;
 }

(1/2 Mark for correct syntax for class header)
(1/2Mark for correct declaration of data members)
(1 Mark for correct definition of FindDiscO)
(1 Mark for correct definition of Buy() with proper invocation of Find Disc() function)
(1 Mark for correct definition of Show All())
Note : Deduct 1/2 Mark if Find Disc() is not invoked properly inside Buy() function.

TOPIC-2 Objects

Short Answer Type Questions-1    [2 marks each]

Question 1:
Answer the questions (i) and (ii) after going through the following class :

class Hospital
{
int Pno, Dno;
 class Hospital    
public :
Hospital (int    PN);             //Function  1
Hospital ();                      //Function  2
Hospital (Hospital &H);           //Function  3
void In ();                       //Function  4
void Disp ();                     //Function  5
 } ;
 void main()
 {
 Hospital H(20);                  //Statement 1
 }

(i) Which of the functions out of Function 1, 2, 3, 4 or 5 will get executed when the Statement 1 is executed in the above code?
(ii) Write a Statement to declare a new object G
with reference to already existing object H using Function 3.    [O.D, 2014]
Answer:
(i) Function 1 will get executed.    [1]
(ii) Hospital G(H);    [1]

Question 2:
Answer the questions (i) and (ii) after going through the following class :

class Health
 {
 int PId, Did; public:
Health (int PPID);            //Function 1
Health ();                    //Function 2
Health (Health &H);           //Function 3
void Entry ();                //Function 4
void Display ();              //Function 5
 };
void main ( )
 {
 Health H(20);               //Statement 1
 }

(i)  Which of the Function out of Function 1, 2, 3, 4 or 5 will get executed when the Statement 1 is executed in the above code ?
(ii)  Write a statement to declare a new object G
with reference to already existing object H using Function 3.    [Delhi, 2014]
Answer:
(i) Function 1 will get executed.    [1]
(ii) Hospital G (H);    [1]

Question 3:
What is the relationship between a class and an object? Illustrate with a suitable example. [CBSE Comptt., 2013]

Answer:
A class is a collection of objects. Each object represents the behaviour and functions, which the class members can performs. In other words, an object is an instance of a class.    [1]
For Example:
A Class Box will have characteristics as length, breadth and height:

class Box
 { int length, breadth, height; 
void Display (int length, int breadth, int height) 
{cout<<length<<breadth<<height;}
 };
 void main()
 {Box a=new Box();
 a. Display(10,20,30);
 // a is the object of class Box [1]
 }

NCERT Solutions for Class 12 Computer Science (C++) – Object Oriented Programming in C++

TOPIC – 1

Object Oriented Programming : Introduction

Short Answer Type Questions-I    [2 marks each]

Question 1:
Differentiate between data abstraction and data hiding.    [Delhi, 2015]
Answer:
Data hiding can be defined as the mechanism of hiding the data of a class from the outside world. This is done to protect the data from any accidental or intentional access. Data hiding is achieved by making the members of the class private.
Data abstraction refers to, providing only essential information to’ the outside world and hiding their background details.
Members defined with a public label are accessible to all parts of the program. The data abstraction view of a type is defined by its public members.

https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7398766921532682&output=html&h=280&slotname=8094000682&adk=2916952469&adf=4000517792&pi=t.ma~as.8094000682&w=750&fwrn=4&fwrnh=100&lmt=1670952986&rafmt=1&format=750×280&url=https%3A%2F%2Fwww.cbsetuts.com%2Fncert-solutions-class-12-computer-science-c-object-oriented-programming-c%2F&fwr=0&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiNi4wLjAiLCJ4ODYiLCIiLCIxMDguMC41MzU5LjEyNSIsW10sZmFsc2UsbnVsbCwiNjQiLFtbIk5vdD9BX0JyYW5kIiwiOC4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDguMC41MzU5LjEyNSJdLFsiR29vZ2xlIENocm9tZSIsIjEwOC4wLjUzNTkuMTI1Il1dLGZhbHNlXQ..&dt=1672668060665&bpp=1&bdt=1913&idt=167&shv=r20221207&mjsv=m202212060101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Dabbbd049660c1ef5-2201b28402d90024%3AT%3D1671719836%3ART%3D1671719836%3AS%3DALNI_MazhTIzYkzGHXl260j5g4NFTSeuqQ&gpic=UID%3D00000b960889abfa%3AT%3D1671719836%3ART%3D1672666984%3AS%3DALNI_MZitKfGKipH7BopsZPzcTHmvXnt4Q&prev_fmts=0x0&nras=1&correlator=7214502721993&frm=20&pv=1&ga_vid=1762681568.1671719837&ga_sid=1672668061&ga_hid=1428470902&ga_fc=1&u_tz=330&u_his=4&u_h=864&u_w=1536&u_ah=824&u_aw=1536&u_cd=24&u_sd=1.25&dmc=4&adx=190&ady=938&biw=1519&bih=754&scr_x=0&scr_y=0&eid=44759876%2C44759927%2C44759837%2C44777506%2C31071220%2C44780792&oid=2&pvsid=4316515859347442&tmod=908382715&uas=0&nvt=1&ref=https%3A%2F%2Fwww.learncbse.in%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C824%2C1536%2C754&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&cms=2&fu=128&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=JwsBddRira&p=https%3A//www.cbsetuts.com&dtd=182

Question 2:
How encapsulation and abstraction are implemented in C++ language ? Explain with an example.    [CBSE SQP 2015]
Answer:
Abstraction refers to the act of representing essential features without including the back-ground details or explanations.
Encapsulation is wrapping up of data and function together in a single unit.
We can say that encapsulation is way of achieving abstraction. Both these concepts are implemented in C++ in the form of a class. In a class data and function members are wrapped together. Only essential features are shown to the outside world in the form of member functions with public mode of accessibility. [1]
Example:     [1]

class Rectangle
 {
 int L, B;
 public: void Input() 
 {
      cin>>L>>B; 
 }
 void Output()
 {
 Cout<<L<<B;
 }
 };

In this example:
Data and member functions are together encapsulated
Only Input ( ) and Output ( ) functions are visible outside the class which can only can be accessed outside the class using objects of the same class – Abstraction

Question 3:
Explain data hiding with an example. [CBSE Comptt., 2014]
Answer:
Data Hiding
Data Hiding is the mechanism where the details of the class are hidden from the user.
The user can perform only a restricted set of operations in the hidden member of the class For example,
In order to make the design and maintenance of a car reasonable the complexity of equipment is divided into modules with particular interfaces hiding design decisions.
General Form:

class classname
 {
 private:
datatype data;
    public:
       Member functions,-'
 };
 main()
 {
 classname objectnamel, objectname2
.........;
 {
 Example :
class Square
{
 private
 int Num;
 public:
 void Get() {
 cout<<"Enter Number:";
 cin>>Num;
 }
 void Display!) { cout<<"Square Is:"<<Num*Num;
 }
 };
 void main()
 {
 Square Obj;
 Obj.Get();
 Obj.Display ();    [1]
 getch()
 }

Question 4:
What do you understand by data encapsulation and Data hiding ?
Also, give a suitable C++ code to illustrate both.    [CBSE SQP 2013]
Answer:
Data hiding is a property of OOP by which the crucial data of an object is made hidden from the rest of the program or outside the world. [1]
Encapsulation refers to the wrapping of data and associated functions together under a unit class. [1]

// Program for hiding & Encapsulation 
#include <iostream.h> 
class Adder {    // Encapsulation
 public :
 Adder (int i = 0)
 { total = i;}
 void addNum (int Number)
 { total + = Number;
 }
 int getTotal ( )
 { return total;
 }
 private : int total ;
 //Data Hiding
};
int main ( )
{
Adder a;
a . addNum (10);
a . addNum (20);
a . addNum (30);
cout << "Total :<<a.getTotal (
) < < endl;
return 0 ;
}

Question 5:
Write the output of the following C++ program code:    [Delhi, 2015]

class Eval
{
char Level; 
int Point;
Public :
Eval () {
Level = 'E' ; Point = 0;
}
void Sink (int L)
{
Level - = L;
}
void Float (int L)
{
Level + = L;
Point ++;
}
void Show ( )
{
cout<<Level<<"#"<<Point<<endl;
}
};
void main ( )
{
Eval E;
E. Sink (3) ;
E. Show ( );
E. Float (7);
E. Show ( );
E. Sink (2) ;
E. Show ( );
}

Answer:
B#0
I#1
G#1
(1 Mark for each correct line of output)
Note:
•  Deduct 1/2 Mark for not considering any or all end/(s) at proper place(s)
•  Deduct 1/2 Mark for not writing any for all symbol(s) [CBSE Marking Scheme 2015]

Question 6:
Observe the following program carefully and attempt the given questions :

#include<iostream.h>
#include<cono.h>
#include<stdlib,h>
void main()
clrscr();
randomize();
char courses![ ] [10]={“M.Tech”.”MCA”, “MBA”,”B.Tech”};
int ch;
for(int i= l;i<=3;i++)
{
ch=random(i)+1;
cout<<courses[ch]<<“\t;
}
getch () ;
}

(i) Out of all the four courses stored in the variable courses, which course will never be displayed in the output and which course will always be displayed at first in the output ?
(ii) Mention the minimum and the maximum value assigned to the variable ch ? [CBSE SQP 2016]
Answer:
(i) M. Tech will never be displayed in the output.
MCA will always be displayed at first in the output.
(ii) Minimum value of ch=l
Maximum value of ch=3
(1 Mark for each correct answer)
Note:
• Deduct 1/2  Mark for writing any additional option. [CBSE Marking Scheme 2016]

Question 7:
Study the following program and select the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable VAL.
Note:
— Assume all required header files are already being included in the program.
— random(n) function generates an integer between 0 and n -1.    [O.D, 2015]

void main ()
 {
 randomize ()    ;
 int VAL;
 VAL = random (3) + 2;
 chart GUESS [    ]    = "ABCDEFGHIJK"
 ;    for (int I = 1; I < = VAL;
 I ++)
 {
 for (int J = VAL; J < = 7; J ++)
 Cout<<GUESS [J] ;
 cout<<endl;
 }

NCERT Solutions for Class 12 Computer Science (C++) - Object Oriented Programming in C++-1
Answer:
(ii) and (iii)
Min Value of VAL = 2
Max Value of VAL. = 4
(1/2 CA Mark for writing option (ii))
(1/2 Mark for writing option (iii))
Note:
• Deduct 1/2 mark for ivriting each additional option along with both correct options:
(1/2 Mark for writing correct Minimum value of VAL)
(1/2 Mark for writing correct Maximum value of VAL) [CBSE Marking Scheme 2015]

Question 8:
Rewrite the following program after removing the syntax errors (if any). Under line each correction.    [O.D, 2012]

#include <iostream.h>
Class Item
{
long IId, Qty; 
public :
void Purchase {cin>>IId>>Qty;} 
void sale ()
{
cout<<setw (5)<< IId<<" Old :"<Qty 
<<endl;
cout<<"New :" <<Qty<<endl;
}
};
void main ()
{
Item I;
Purchase ();
I. Sale () ;
I. Sale ()
}

Answer:

#include<iostream.h>
#include<iomanip.h> 
class Item 
{
long IId, Qty; 
public :
void purchase() 
{cin>>IId>>Qty;} 
void sale()
{
cout<<setw(5)<<IId<<"Old"<<Qty<<endl; 
cout<< "New    Qty<<endl;
}
};
void main( )
{
Item I ;
I. purchase( ); // Object missing 
I. sale ( ) ;
I. sale( ); //; is missing
}
(1/4 mark for each correction)

Question 9:
Rewrite the following program after removing the syntax errors (if any). Underline each correction.    [Delhi, 2012]

# include <iostream.h> 
class book {
long Bid, Qty; 
public :
void purchase () {cin>>BID>>Qty;} 
void sale ( )
{
cout<<setw<<BId<<"Old:"<<Qty<<en 
dl;
cout<<"New; "<<—Qty<<endl;
}
};
void main ()
{
Book B;
B. Purchase(); 
sale ();
B. Sale ()
}

Answer:

#include<iomanip.h>
#include<iostream.h> 
class Book
 {
long Bid, Qty; 
public:
void purchase()(cin>>Bld>>Qty;) 
void sale( )
{
cout < < setw(5) < < Bld < < "0ld " < < Qty < < e n
dl;
cout<"New:"<<—Qty<<endl;
}
} ;
void main ()
{
Book B;
B. purchase ();
B. sale();
}
(1/2 mark for each correction) [CBSE Marking Scheme 2012]

Question 10:
Answer the questions (i) and (ii) after going through the following class:    [O. D, 2012]

class Travel
{
int PlaceCode; char Place [20] ; 
float Charges; 
public :
Travel ( )    //Function 1
{
PlaceCode = 1; strcpy (Place,
"DELHI"); Charges =1000;
}
void TravelPlan (float C)
//Function 2
{
cout<<PlaceCode<< ":" <<Place<<
":" <<Charges<<endl;
} 
- Travel ( )   //Function 3
{
cout<<"Travel Plan Cancelled"<<
endl;
}
Travel (int PC, char P [], float C)
                         // Function 4
{
PlaceCode = PC; strcpy (Place, P);
Charges = C;
}
} ;

(i) In Object Oriented Programming, what are Function 1 and Function 4 combinely referred to as ?
(ii) In Object Oriented Programming which concept is illustrated by Function 3? When is this function called/invoked ?
Answer:
The concept demonstrated is constructor over-loading:
(i)  Function 1 and Function 4 are called overloaded Constructor of the Class Travel.
(ii) Function 3 is Destructor of Class Travel.
The destructors are called automatically
when the objects are destroyed.    [2]

Short Answer Type Questions-II (3 marks each)

Question 1:
Write any four important characteristics of object Oriented Programming ? Give example of any one of the characteristics using C++. [O.D, 2016]
Answer:

NCERT Solutions for Class 12 Computer Science (C++) - Object Oriented Programming in C++-2

Question 2:
Find the output of the following C++ program [CBSE SQP 2015]

#include<iostream.h>
#include<conio.h>
#include<ctype.h> 
class Class 
{
int Cno,total; 
char section; public:
Class(int no=l)
{
Cno=no; 
section='A'; 
total=30;
}
void admission(int c=20)
{
section++;
total+=c;
}
void ClassShow ()
{
cout<<Cno<<":"<<section<<":"<<total<
endl;
}
};
void main ()
{
Class C1 (5),C2;
Cl.admission(25)
Cl.ClassShow();
C2.admission() ;
Cl.admission(30)
C2.ClassShow();
Cl.ClassShow();
}

Answer:
5 : B : 55 [1]
1: B : 50 [1]
5 : C : 85 [1]

Question 3:
Obtain the output of the following C+ + program, which will appear on the screen after its execution.
Important Note:
• All the desired header files are already included in the code, which are required to run the code,

class Game 
{
int Level, Score; 
char Type; 
public:
Game (char GType='p')
{Level=1; Score=0; Type= GType;} 
void Play (int GS); 
void Change (); 
void Show()
{
cout<<Type<<"@"<<Level<<endl; 
cout<<Score<<endl;
}
} ;
void main () 
{
Game A ('G'), B;
B. Show ();
A. Play (11);
A. Change ();
B. Play (25);
A. Show ();
B. Show ();
}
void Game:    : Change()
{
Type=(Type== 'P')?'G' :'P';
}
void Game: :Play(int GS)
{
Score+=GS; 
if(Score>=30)
Level=3;
else if (Score>=20)
Level=2; 
else
Level=l;
}        [O.D, 2014]

Answer:

P@1
0
P@1
11
P@2
25
(1/2 mark for each correct line)

Question 4:
Obtain the output of the following C+ + program, which will appear on the screen after its execution.
Important Note:
• All the desired header files are already included in the code, which are required to run the code,

class Player 
{
int Score, Level; 
char Game;
public:
Player (char GGame='A')
{Score=0; Level=1; Game =GGame;} 
void Start (int SC); 
void Next (); 
void Disp ()
{
cout <<Game<<"@"<<Level <<endl; 
cout <<Score<<endl;
}
};
void main ()
{
Player P,Q ('B');
P. Disp ();
Q. Start (75);
Q. Next ();
P. Start (120);
Q. DispO ;
P.Disp ();
}
void Player : : Next ()
{
Game = (Game =='A')?'B':'A' ;
}
void Player : : Start (int SC)
{
Score+=SC;
If (Score>=100)
Level=3;
else if (Score>=50)
Level=2; 
else
Level=1;
}    [O.D, 2014]

Answer:

A@1 0
A@2
75
A@3
120    [3]

Question 5:
Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution of it.

#include <iostream.h> 
class Mausam 
{
int city, Temp, Humidity; 
public :
Mausam (int C = 1) {City = C; Temp = 
10; Humidity = 63;}; 
void Sun (int T) {Temp + = T;}; 
void Rain (int H) {Humidity +=H;}; 
void Checkout ( )
{
cout<<City<<":"<<Temp<< "&" <<Humidity 
<<"%"<<endl;
}
} ;
void main ( )
{
Mausam M, N(2);
M. Sun (5);
M. Checkout ( );
N.  Rain (10);
N.Sun (2)    ;
N.Checkout ( );
M.Rain (15)    ;
M.Checkout ( ) ;
}    [O.D, 2013]

Answer:
Output:
1:1:15% [1]
2:2:12% [1]
3:1:15%  [1]

Question 6:
Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution of it.

# include <iostream.h> 
class Aroundus
 {
 int Place, Humidity, Temp; public:
 Aroundus(int p = 2) {
 Place = P; Humidity = 60; Temp = 20;
 }
 void Hot (int T) {
 Temp+=T ;
 };
 void Humid (int H) {
 Humidity+=H ;
 };
 void JustSee ( )
 {
 cout<<Place<<":"<<Temp<<"&"<<Humidity <<"%"<<endl;
 }
 };
 int main()
 {
 Aroundus A, B (5) ;
 A. Hot (10)    ;
 A. JustSee ( )    ;
 B. Humid (15)    ;
 B. Hot (2)    ;
 B. JustSee ( )    ;
 A. Humid (5)    ;
 A. Justsee ( ) ;    [Delhi, 2013]

Answer:
Output:

2 : 30 & 60%    [1]
5 : 22 & 75%    [1]
2 : 30 & 65%    [1]

Question 7:
Find the output of the following program : [O.D., 2012]

#include <iostream.h> 
class METRO 
{
 int Mno, TripNo, PassengerCount; 
public :
METRO (int Tmno=l)
 {
 Mno=Tmno;
 TripNo=0;
 PassengerCount=0;
 }
 void Trip (int PC = 20)
 { TripNo++; PassengerCount+=PC;} 
void StatusShow ()
 {cout<<Mno<<" : "<<TripNo<<":"
 <<PassengerCount<<endl;}
 } ;
 int main ()
 {
 METRO M (5), T;
 M.Trip () ;
 T.Trip (50) ;
 M.StatusShow ();
 M.Trip (30)    ;
 T.StatusShow ();
 M.StatusShow ();
 }

Answer:
Output:

5 :1: 20
1 :1 : 50
5 : 2 : 50
(1 mark for each line of output)

Question 8:
Find the output of the following program: [Delhi, 2012]

#include<iostream.h> 
class TRAIN 
{
 int Tno, TripNo, PersonCount; 
public :
 TRAIN (int Tmno=l) {Tno=Tno; TripNo=0; PersonCount = 0;}
 void Trip    (int TC=100)
 {TripNo++; PersonCount+=TC;} 
void Show ()
 {cout<<Tno<<" : "<<Trip’No<<" : "<<Person Count <<endl;}
 };
 void main ()
 {
 TRAIN T    (10), N.    
N. Trip () ;
 T.  Show  () ;
 T.  Trip (70)
 N.  Trip (40)
 N.  Show () ;
 T.  Show  () ;
}

Answer:
Output:
1202 : 0:0
950 : 2 :140
1202 :1: 70
(1 mark for each line of output)

Question 9:
Write the output of the following C++ progam code:
Note : Assume all required header files are already being included in the program,

class seminar 
{
char topic [30]; 
int charges; 
public:
{
strcpy(topic,"Registration"); 
charges=5000;
}
seminar(char t [ ] )
{
strcpy (topic,t) 
charges = 5000;
}
seminar (intc)
{
strcpy(topic,"Registration    with
Discount") ;
charges=5000-c;
}
void regis(char t [ ], int c)
{
strcpy(topic, t); 
charges=charges+c;
}
void regis(int c=2000)
{
charges=charges+c;
}
void subject(char t [ ],int c)
{
strcpy(topic,t); 
charges=charges+c;
}
void show ( )
{
cout<<topic<<"@<<charges<<endl;
}
};
void main ( )
{
seminar s1,s2(1000),s3("Genetic Mutation") , s4; 
s1.show ( ); 
s2.show ( );
s1.subject("ICT",2000) ; 
s1.show ( );
s2.regis("Cyber Crime",2500); 
s2.show ( );
s3.regis ( ) ; 
s3.show(); 
s4=s2; 
s4.show(); 
getch();
}    [CBSE SQP, 2016]

Answer:

Registration@5000
Registration with Discount@4000 
ICT@7000
Cyber Crime@6500 
Genetic Mutation@7000 
Cyber Crime@6500

(1/2 mark for each correct output)
Note:
Deduct 1/2 Mark for not considering any “@” symbol [CBSE Marking Scheme, 2016]

Question 10:
Find and write the output of the following C+ + program code:
Note : Assume all required header files are already being included in the program,

class product 
{
 int PID' 
float price; 
int Qty;
 public:
 Product ( ) {PID=100;Price=20;Qty=100;} 
void Add(int I, float p)
 {
 ID=I ;
 Price=P;
 }
 void Alter(int Change,int TQ)
 {
 Price+=Change;
 Qty+=TQ;
 }
 void Display ( )
 {
 cout<<"PID:"<<PID<<endl; 
cout<<Qty<<"@"<<Price<<endl;
 }
 };
 void main ( )
 {
 Product P,Q,R;
 P. Add(104,50);
 Q. Add(201,30) ;
 R. Alter(-10,25) ;
 P. Display();
 Q. Display();
 R. Display();
 }

Answer:

PID: 100 
104@150 
PID:29 201
@130 PID:25 
100@10

(1/2 mark for each correct line of output)
Note:
• Deduct only 1/2 Mark for not writing any or all.
• Deduct 1/2 Mark for not considering any or all

TOPIC-2

Function Overloading

Short Answer Type Questions-1    [2 marks each]

Question 1:
Answer the questions (i) and (ii) after going through the following class :

class Motor 
{
int MotorNo. Track; 
public :
Motor ( );    //Function 1
Motor (int MN) ; //Function 2 
Motor (Motor &M); //Function 3 
void Allocate ( ) ///Function 4 
void Move ( ); //Function 5
} ;
void main ( )
{
Motor M;
}

(i) Out of the following, which of the option is correct for calling Function 2?
Option 1 – Motor N (M);
Option 2 – Motor P (10);
(ii) Name the feature of Object Oriented
Programming, which is illustrated by Function 1, Function 2 and Function 3 combined together.    [Delhi, 2013]
Answer:
(i) Option 2 is correct for calling Function 2. [1]
(ii) Function overloading, i.e., Polymorphism. [1]

Question 2:
Answer the questions (i) and (ii) after going through the following class :

class Race 
{
int CarNo, Track; 
public:
Race ( ) ; //Function 1
Race (int CN) ; //Function 2
Race (Race &R);  //Function 3
void Register ( ); //Function 4
void Drive ( ); //Function 5
};
void main ( )
{
Race R ;
:
}

(i) Out of the following, which of the option is correct for calling Function 2?
Option 1 – Race T (30);
Option 2 – Race U (R);
(ii)  Name the feature of Object Oriented
Programming, which is illustrated by Function 1, Function 2 and Function 3 combined together.    [O.D, 2013]
Answer:
(i) Option 1 – Race T (30); is correct since the parameter to T is integer.    [1]
(ii) When Functions – Function 1, Function 2 and Function 3 are combined together, it is referred as constructor overloading, i.e., Polymorphism.    [1]

Question 3:
What is function overloading ? Write an example using C++ to illustrate the concept of function overloading.
Answer:
Function Overloading

In C++, we can declare different functions with same name. This property is called function overloading. Function overloading implements polymorphism.
Example:
# include <iostream.h >
#include < stdlib.h>
#include < conio.h>
#define pi 3.14

class fn    [1]
{
public:
void area(int); //circle 
void area(int,int); //rectangle
};
void fn : : area(int a)
{
cout <<"Area of Circle:"<<pi*a*a;
}
void fn::area (int a, int b)
{
cout <<"Area of rectangle:"<<a*b;
}
void main ( )
{
int ch; 
int a, b, r; 
fn obj;
cout<<''\nl.Area    of Circle\
n2.Area of Rectangle\ n3.Exit\n:"; 
cout<<''Enter your Choice:"; 
cin>>ch; 
switch(ch)
{
case 1: 
cin>>r; 
obj.area(r);
break;    [1]
case 2:
'cin>>a>>b;
obj.area(a,b); 
break; 
case 3:
exit (0);
}
getch ( );
}

Question 4:
Write the output of the following C++ code. Also, write the name of feature of Objects Oriented Programming used in the following program jointly illustrated by the functions [I] to [IV]

include<iostream.h>
void Line ( )    //Function[I]
{
for(int L=1;L<=80;L++)
Cout<<"-";
cout<<endl;
}
void Line(int N)    //Function[II]
{
for (int L=1;L<=N;L++)
Cout<<"*";
cout<<endl;
}
void Line (char C, Int N) //Function[III]
{
for(int L=1;L<=N;L++) 
Cout<<C;
cout<<endl;
}
Void Line (int M, int, N)  //Function [IV]
{
for (int L = 1;L<=N;L++)
cout<<M*L;
cout<<endl;
}
void main ( )
{
int A=9, B=4 C=3;
char K = "#" ;
Line (K, B);
Line (A,C);
}

Answer:
####
91827
Function Overloading
(1/2 Mark for writing each correct output)
(1 Mark for writing the feature, name correctly)

Question 5:
Answer the question (i) and (ii) after going through the following class :

class Test 
{
int Regno, Max, Min, Score; 
public :
Test ( )    //Function 1
{
Regno =101; Max = 100;    Min=40;
Score=75 ;
}
Test (int Pregno, int Pscore) //Function 2
{
Regno=Pregno;Max=100;Min=40; 
Score=Pscore;
}
~Test()    //Function 3
{
cout<<"Test Over"<<endl;
}
void Display ( )    //Function 4
{
cout<<Regno<<":"<<Max<<":"<<Min<< endl ;
cout<<" [Score]"<<Score<<endl ;
}
} ;

(i) As per object oriented programming which concept is illustrated by function 1 and function 2 together ?
Answer:
Polymorphism
OR
Function Overloading
OR
Constructor Overloading
(1 Mark for naming the concept correctly)
(ii) What is Function 3 specially referred as ? When do you think, Function 3 will be invoked/called ?
Answer:
Destructor is invoked or called when scope of an Object gets over.
(1/2 Mark of naming Destructor correctly)
(1/2 Mark for mentioning correctly when it is invoked)

Question 6:
Answer the questions (i) and (ii) after going through the following class :

class Exam 
{
int Rno, Maxmarks, MinMarks, marks; 
pubic :
Exam () //Module 1
{
Rno=101;MaxMarks=100;MinMarks=40; Marks =75 ;
}
Exam (int Prno, int Pmarks) / / Module 2
{
Rno = Prno;MaxMarks = l0 0;MinMar ks=40;
Marks=Pmarks; 
}
-Exam ()    //Module 3
{
cout<<"Exam Over" <<Endl ;
}
void show ( )    //module 4
{
cout<<Rno<<" : "< <MaxMarks < <":"<< MinMarks <<endl;
cout<<"[Marks Got]" <<Marks<<endl;
}
};

(i) As per Object Oriented Programming, which concept is illustrated by Module 1 and Module 2 together ?
Answer:
Polymorphism
Or
Constructor Overloading
OR
Function Overloading
(1 Mark for mentioning the correct concept)
(ii) What is Module 3 referred as ? When do you think, Module 3 will be invoked/called ?
Answer:
Destructor. It is invoked as soon as the scope of the object gets over.
(1/2 Mark for indentifying it as Destructor)
(1/2 Mark for mentioning correctly when it be called/invoked)

Question 7:
What do you understand by Function overloading or functional polymorphism? Explain with suitable example.
Answer:
Function overloading is a method of using the same function or method to work using different sets of input. It is one of the example of polymorphism, where more than one function carrying similar name behaves differently with different set of parameters passed to them,

void show ()
 {
 cout<<"\n Hello World!";
 }
 void show(char na [ ])
 {
 cout<<"\n Hello Word! Its"<<na;
Read More

Chapter 1: Overview of CPP | NCERT Solution for class 12th COMPUTER SCIENCE solution

TOPIC-1
Basics of C++

Very Short Answer Type Questions 1markeach

Question 1:
Write the related library function name based upon the given information in C++.

  1. Get single character using keyboard. This function is available in stdio.h file.
  2. To check whether given character is alpha numeric character or not. This function is available in
    ctype.h file.

Answer:

  1. getchar( )
  2. isalnum( )

Question 2:
Observe the following program very carefully and write the names of those header file(s),
which essentially needed to compile and execute the following program successfully :

typedef char TEXT[80]; void main() { TEXT Str[] = "Peace is supreme";  int Index = 0; while(Str[Index]! = "") if(isupper(Str[Index]" Str[Index ++] = ? "#"; else str[Index ++] = "*"; puts(Str); }

Answer:
<ctype.h>, <stdio.h>

Question 3:
Name the header files that shall be needed for ‘ successful compilation of the following C+ + code :

void main() { char str[20],str[20]; gets(str); strcpy(str1,str);  strrev(str);  puts(str);  puts(str1); }

Answer:
#include<stdio.h>
#include<string.h>

Question 4:
Observe the following C++ code and write the name(s) of the header file(s), which will be essentially
required to run it in a C + + compiler :

void main() { char CH, STR[20]; cin>>STR; CH=toupper(STR[0]); cout<<STR<<"starts with"<<CH<<endl; }

Answer:
#include<iostream.h>
#include<ctype.h>

Question 5:
Observe the following C++ code and write the name(s) of the header file(s), which will be essentially
required to rim it in a C++ compiler :

void main() { char Text[20],C; cin>>Text; C=tolower(Text[0]);  cout<<C<<"is the first char of"<<Text<<endl; }

Answer:
#include<iostream.h>
#include<ctype.h>

Question 6:
Name the header file(s), which are essentially required to run the following program segment :

void main() { char A="K",B;  if(islower(A)) B=toupper(A); else B= "*"; cout<<A<<"turned to"<<B<<endl; }

Answer:
#include<iostream.h>
#include<ctype.h>

Question 7:
Observe the following C+ + code and write the name(s) of header files, which will be essentially
required to run it in a C + + compiler

void main() { float Area, Side; cin>>Area; Side = sqrt(Area); cout<<"one side of the square<<side<<end1; }

Answer:
Header files required:

  1.  math.h
  2.  iostream.h

Question 8:
Write the names of header files used :

void main() { int number;  cin>>number; if(abs(number) == number)  cout<<"Positive"<<endl; }

Answer:
iostream.h, math.h

Question 9:
Write the names of header files, which are NOT NECESSARY to run the following program :

#include<iostream.h> #include<stdio.h> #include<string.h> #include<math.h>  void main() { char STR[80];  gets(STR);  puts(strrev(STR)); }

Answer:
Header files not required are :
iostream.h,math.h.

Question 10:
Which C++ header file(s) are essentially required to be included to run/execute the following
C++ source code ?

void main() { char TEXT[] = "Something";  cout<<"Remaining SMS Chars :"<<160- strlen(TEXT)<<endl; }

Answer:

  1. <string.h>
  2. <iostream.h>

Question 11:
Which C++ header file(s) are essentially required to be included to run/execute the following
C++ source code (Note : Do not include any header file, which is/are not required) ?

void main() { char STRING[] = "SomeThing"; cout<<"Balance Characters:"<<160- strlen(STRING)<<endl; }

Answer:
<iostream.h>,<string.h>

Question 12:
Ahmed has started learning C++ and has typed the following program. When he compiled the
following code written by him, he discovered that he needs to include some header files to
successfully compile and execute it. Write the names of those header files, which are required
to be included in the code.

void main() { float Radians,Value;  cin>>Radians; Value=sin(radians);  cout<<Value<<endl; }

Answer:
iostream.h
string.h

Question 13:
Which C++ header file(s) are essentially required to be included to run/execute the following C++ code:

void main() { char*word1="Hello".word2="Friends";  strcat(word1,word2);  cout<<word1; }

Answer:
iostream.h
string.h

Short Answer Type Questions-I

Question 1:
Define Macro with suitable example.
Answer:
Macro are preprocessor directive created using # define that serve as symbolic constants.
They are created to simplify and reduce the amount of repetitive coding.
For instance,
#define max (a, b) a > b ? a : b
Define the macro max, taking two arguments a and b. This macro may be called like any
C function with similar syntax. Therefore, after preprocessing.
A = max (x, y);
BecomesA = x>y ?x:y;

Question 2:
Write the output of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

class Calc { char Grade; int Bonus;  public: Calc (){Grade = "E"; Bonus = 0;}  void Down(int G) { Grade(-) = G; } void Up(int G) {  Grade += G; Bonus ++; } void Show() { cout<<Grade<<"#"<<Bonus<<endl  } }; void main() { Calc c; C.Down(2); C.Show(); C.Up(7); C.Show(); C.Down(2); C.Show(); }

Answer:
C#0
J#1
H#1

Question 3:
Rewrite the following program after removing any syntactical errors. Underline each correction made.

#include <isotream.h> void main() int A[10]; A = [3, 2, 5, 4, 7, 9, 10];  for(p = 0; p <= 6; p++) {  if(A[p]%2=0) int S = S + A[p]]; } cout<<S;   }

Answer:

#include<iostream.h>  void main() {  int A[10] = {3, 2, 5, 4, 7, 9, 10};  int S = 0, p; for(p = 0; p <= 6; p++) {  if(A[p]%2 == 0) S = S + A[p];  }  cout<<S; }

Question 4:
Observe following C++ code very carefully and rewrite it after removing any/all syntactical
errors with each correction underlined.
Note : Assume all required header files are already being included in the porgram.

#Define float Max = 70.0; Void main) { int Speed  char Stop = "N";  cin >> Speed;  if Speed > Max  Stop = "Y" ;  cout <<stop<<end; }

Answer:

#define float Max 70.0 //Error 1,2,3  void main()      //Error 4 { int Speed;          //Error 5 char Stop = "N"; cin>>Speed;  if(Speed>Max)      //Error 6 Stop = "Y"; cout<<Stop<<endl;  //Error 7 }

Question 5:
Write the output of the following C+ + program – code :
Note : Assume all required header files are already being included in the program.

void Position(int & C1, int C2 = 3) { C1+ = 2; C2+ = Y;  void main() int P1 = 20, P2 = 4;  position(P1);  cout<<P1<<","<<P2<<endl;  position(P2, P1);  cout<<P1<<","<<P2<<endl; }

Answer:
22,4
22,6

Question 6:
Study the following program and select the posssible output(s) from the options (i) to (iv) following it.
Also, write the maximum and the minimum. values that can be assigned to the variable NUM.
Note :
— Assume all required header files are already being included in the prorgram.
— random(n) function generates an integer between 0 and n -1.

void main() { randomize();  int NUM; NUM = random(3)+2; char TEXT[] = "ABCDEFGHIJK"; for(int I=1; I <= NUM; I++) { for(int J = NUM; J <= 7;J++)  cout<<TEXT[J];  cout<<endl; } } (i)FGHI     FGHI      FGHI   FGHI (ii)BCDEFGH BCDEFGH (iii)EFGH EFGH EFGH EFGH (iv)CDEFGH

Answer:
(iii) and (iv)
Minimum value of NUM = 2
Maximum value of NUM = 4

Question 7:
Rewrite the following C++ program after removing all the syntactical errors (if any),
underlining each correction :

includeciostream.h> #define PI=3.14 void main() {  float r,a; cout<<"enter any radius";  cin>>r; a=PI*pow(r,2);  cout<<"Area="<<a; }

Answer:

#include<iostream.h> // Error 1: Declaration Sytax error  #include<math.h> #define PI=3.14      // Error 2: Macro declaration does not allow assignment  void main() { float r,a;     // Error 3:Undefined Symbol a cout<<"enter any radius";     //Error 4 : Character Constant
must be one or two characters long  cin>>r; a=PI*pow(r,2)   //Error 5 : Expression Syntax cout<<"Area="<<a; }

Question 8:
Rewrite the following C++ code after removing all the syntax error(s), if presents in the code. Make sure that you underline each correction done by you in the code.
Important Note:

  • Assume that all the required header files are already included, which are essential to run this code.
  • The corrections made by you do not change the logic of the program.
typedef char STR[80];  void main() { STR Txt;  cin (Txt);  cout<<Txt<<endline; }

Answer:

typedef char STR[80];  void main() { STR Txt;  gets(Txt);  cout<<Txt<<endl; }

Question 9:
Rewrite the following C+ + code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code.

Important Note :

  • Assume that all the required header files are already included, which are essential to run this code.
  • The corrections made by you do not change the logic of the program.l
typedef char STRING[50];  void main() { City STRING; cin (City); cout<<City<<endline ; }

Answer:

typedef char STRING[50];  void main() { STRING City; gets(City);                cout<<City<<endl; }

Question 10:
Out of the following, find those identifiers, which cannot be used for naming Variable,
Constants or Functions in a C + + program : Total*Tax, double, case, My Name, New switch, Column31, _Amount
Answer:
Total * Tax, double, case, My name, New switch

Question 11:
Ronica Jose has started learning C++ and has typed the following program. When she compiled the
following code written by her, she discovered that she needs to include some header files to successfully
compile and execute it. Write the names of those header files, which are required to be included in the code.

void main() { double X,Times,Result;  cin>>X>>Times; Result=pow(X,Times)  cout<<Result<<endl; }

Answer:

<iostream.h>for cout and cin
<math.h>for pow()

Question 12:
Rewrite the following C+ + code after removing any/all syntactical error with each correction underlined.
Note : Assume all required header files are already being included in the program.

#define Formula(a,b)= 2*a+b void main() { float x=3.2; Y=4.1; Z=Formula(X,Y); cout<<"Result="<<Z<<endl; }

Answer:

# define Formula(a.b)2*a+b  void main() { float X=3.2, y=4.1; float Z = Formula(X,Y); cout<<"Result="<<Z<<endl; }

Question 13:
Find and write the output of the following C+ + program code :
Note ; Assume all required header files are already included in the program.

typedef char TexT[80];  void JumbleUp(TexT T) { int L=strlen(T); for(int C=0;C<L-1;C+=2) { char CT=T[C]; T[C] = T[C+l]; T[C+l]=CT; } for(C=l;C<L;C+=2) if(T[C]>="M"&& T[C]<="U") T[C] = "@"; void main() { TEXT Str = "HARMONIOUS";  JumbleUp(Str);  cout<<Str<<endl; }

Answer:
AHM@N@OIS@

Question 14:
Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it.
Also, write the maximum and the minimum values that can be assigned to the variable PICKER.
Note :

  • Assume all the required header files are already being included in the code.
  • The function random(n) generates an integer between 0 and n -1
void main() { randomize();  int PICKER; PICKER=random(3); char COLOUR[][5]={"BLUE","PINK","GREEN","RED"};  for(int 1=0;I<=PICKER;I++) { for(int J=0;J<=I;J++)  cout<<COLOR[J]; cout<<endl; } } 
ncert-solutions-class-12-computer-science-c-crevision-tour-(10-1)

Answer:
Maximum value : 3
Min value : 1

Question 15:
Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C + + program : _Cost, Price*Qty, float, Switch, Address one, Delete, Numberl2, do
Answer:
Price* Qty, float, Address one, do

Question 16:
Jayapriya has started learning C+ + and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

void main() { float A, Number, Outcome;  cin>>A>>Numbers; Outcome = pow(A, Number);  cout<<outcome<<endl; }

Answer:
<iostream. h> for cout and cin
<math. h> for Pow()

Question 17:
Rewrite the following C+ + code after removing any/all syntactical error with each correction underlined.
Note : Assume all required header files are already being included in the program.

#define Equation(p,q)=p+2*q  void main() { float A=3.2;B=4.1; C=Equation (A,B); cout<<’Output="<<C<<endl; }

Answer:

#define Equation(p,q)g+2*q  void main()   {  float A=3.2,B=4.1;  float C=Equation(A,B); Cout<<"Output"<<C<<endl;   }

Question 18:
Find and write the output of the following C++ program code:
Note : Assume all required header files are included in the program,

typedef char STRING[80];  void MIXITNOW(STRING S) { int Size=strlen(S);  for(int 1=0;I<Size-l;I+=2) { char WS=S[I]; S[I]=S[I+1]; S[1+1]=WS; } for(1=1;I<Size;I+=2) If(S[I]>="M1&&S[I]<="U") S[I]=; void main() { STRING Word = "CRACKAJACK";  MIXITNOW(Word);  cout<<Word<<endl; }

Answer:
RCCAAKAJKC.

Question 19:
Find and write the output of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

class stock  { long int ID;  float Rate;  int Date;   public: Stock() {ID=1001;Rate=200;Date=l;}  void RegCode(long int I, float R) { ID=I; Rate=R; } void Change(int New, int DT) Rate+=New; Date=DT; } void Show() { cout<<"Date:"<<Date<<endl;  cout<<ID<<"#"<<Rate<<endl; } }; void main() { stock A,B,C; A.RegCode(1024,150); B.RegCode(2015,300); B.Change(100,29); C.Change(-20,20); A.Show(); B.show(); C.Show(); }

Answer:
Date:1
1024 # 150
Date : 29
2015 # 400
Date : 20
1001 # 180

Question 20:
Look at the following C+ + code and find the possible output(s) from the options (i) to (iv) following it. Also,
write the maximum and the minimum values that can be assigned to the variable CHANGER.
Note :

  • Assume all the required header files are already being included in the code.
  • The function random(n) generates an integer between 0 and n -1
void main() { randomize();  int CHANGER; CHANGER=random(3); char CITY[][25]={"DELHI","MUMBAI","KOLKATA","CHENNAI"};  for(int 1=0;I<=CHANGER;I++) { for (int J=0;J<=I;J++)  cout<<CITY[J];  cout<<endl; } }
ncert-solutions-class-12-computer-science-c-crevision-tour-(11-1)
ncert-solutions-class-12-computer-science-c-crevision-tour-(12-1)

Answer:
DELHI
DELHIMUMBAI
DELHIMUMBAIKOLKATA
Minimum Value of CHANGER = 0
Maximum Value of CHANGER = 2
Question 21:
Out of the following, find those identifiers, which can not be used for naming Variable,
Constants or Functions in a C + + program :
Days*Rent, For, A+Price, Grand Total
double, 2Members, . Participantl, MyCity
Answer:
Days * Rent
For
Grand Total
double

Question 22:
Rewrite the following C+ + code after removing any/all syntactical errors with each correction underlined.
Note : Assume all required header files are already included in the program.
Days*Rent, For, A+Price, Grand Total
double, 2Members, Participantl, MyCity
Answer:

#define formula (a,b,c)a+2*b+3*c  void main() { int L=1,M=2,N=3; int J=formula(L,M,N);  cout<<"Output="<cj<<endl; }

Question 23:
Look at the following C+ + code and find the possible output(s) from the options (i) to (iv) following it.
Also, write the maximum and the minimum values that can be assigned to the variable P_Holder.
Note :

  • Assume all the required header files are already being included in the code.
  • The funciton random (n) generates and integer between 0 and n-1.
void main() { randomize();  int P_Holder; P_Holder=random(3); char place [][25]={"JAIPUR","PUNA","KOCHI","GOA" }; for(int P=0;P<=P_Holder;P++) { for (int C=0;C<P;C++)  cout<<Place[C]; cout<<endl; } }


Answer:
JAIPUR
JAIPUR PUNA
JAIPUR PUNA KOCHI
MINIMUM VALUE of P_Holder = 0
Maximum Value of P_Holder = 2

Question 24:
Rewrite the following program after removing the syntactical erros (if any). Underline each correction.

#include<conio.h>  #include<iostream.h>  #include<string.h> #include<stdio.h> Class product { int product_code,qty,price;  char name[20];  public:product() { product_code=0;qty=0;price=0;  name=NULL; } void entry() { cout<<"
 Enter code,qty(price";  cin>>product_code>>qty>>price;  gets(name); } void tot_price(){return qty*price;} } void main() { p product;  p.entry();  cot<<tot_price(); }

Answer:

#include<conio.h> #include<string.h> #include<stdio.h>  class product  { int product_code,qty,price;  char name[20];  public;  product() { product_code=0;qty=0;price=0;  strcpy(name.NULL); }  void entry() { cout<<"
 Enter code, qty, price";  cin>>product_code>>qty>>price;  gets(name); } int tot_price(){return qty*price;} }; void main() { product p;  p.entry();  cot<<p.tot price(); }

Question 25:
Explain conditional operator with suitable example ?
Answer:
Conditional operator is also known as ternary operator because it requires three operands and can be used to replace simple if- else code. It is used to check the condition and exucute first expression if condition is true: else execute other. .
Syntax :
Conditional expression ?
Expression 1 : Expression 2 :
Explanation : If the conditional expression is true then expression I executes otherwise expression 2 executes.
Example :
int y = 10, x;
x = y>10? 1:0;
cout<<X;
Output : 0

Short Answer Type Question-II 3marks

Question 1:
Find and write the output of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

class Share { long int Code;  float Rate;  int DD;  public : Share() {Code=1001;Rate=100;DD=1;}  void GetCode(long int C, float R)  { Code=C; Rate=R; } void Update(int Change, int D) {  Rate+=Change;  DD=D ; } void Status() { cout<<"Date:"<<DD<<endl;  cout<<Code<<"#"<<Rate<<endl; } void main() { Share S,T,U; S.GetCode(1324,350); T.GetCode(1435,250); S.Update(50,28); U.Change(-25,26); S.Status(); T.Status(); U.Status(); }

Answer:
Date ; 28
1324 # 400
Date : 1
1435 #250
Date : 26
1000 # 75

TOPIC-2
Flow Control

Short Answer Type Questions-1 2markseach

Question 1:
Find syntax error(s), if any, in the following program : (Assuming all desired header file(s) are already included)

typedef char String[80];  void main  { String S; int L;  for(L=0;L<26;C++) S [L]=L+65;  cout<<S<<endl }

Answer:
The given code has following errors:

  1. Parenthesis () are missing after void main.
  2. In for statement, the update expression should be L+ + but it is written as C + + .

Question 2:
Read the following C++ code carefully and find out, which out of the given options
(i) to (iv) are the expected correct outputs) of it. Also,
write the maximum and minimum value that can be assigned to the variable Taker used in the code:

void main() { int GuessMe[4]= {100,50,200,20};  int Taker = random(2)+2;  for(int Chance=0;Chance<=Taker;Chance++)  cout<<GuessMe[Chance]<<"#"; } (i)100# (ii)50#200# (iii)100#50#200# (iv)100#50

Answer:
(iii) 100#50#200#
Max value : 350
Min value : 170

Question 3:
Read the following C++ code carefully and find out, which out of the given options
(i) to (iv) are the expected correct output(s) of it. Also,
write the maximum and minimum value that can be assigned to the variable Start used in the code :

void main() { int Guess [4]={200,150,20,250};  int Start=random(2)+2;  for (int C=Start;C<4;C++) cout<<Guess[C]<<"#"; } (i) 200#150# (ii) 150#20# (iii) 150#20#250# (iv) 20#250#

Answer:
(iv) 20#250#
Max value : 470
Min value : 420

Question 4:
Which C++ header file (s) will be include to run/execute the following C+ + code ?

void main() {  int Last=26.5698742658;  cout<<setw(5)<<setprecision(9)<<Last;  }

Answer:
iostream.h
iomanip.h

Question 5:
Find the correct identifiers of the following, which can be used for naming, variable,
constants or functions in a C++ program :
For, while, INT, New, delete, IstName, Add + Subtract, namel
Answer:
For, INT, New, namel

Question 6:
Find correct identifiers out of the following, which can be used for naming variable,
constants or function in a C++ program :
For, While, Float, new, 2ndName, A%B, Amount 2, Counter.
Answer:
While, float Amount 2, _Counter.

Question 7:
Find out the expected correct output(s) from the options (i) to (iv) for the following C++ code.
Also, find out the minimum and the maximum value that can be assigned to the variable
Stop used in the code :

void main()  { int Begin=3,Stop; for(int Run=l;Run<4;Run++) { Stop=random(Begin)+6;  cout<<Begin++<<Stop<<"*"; } } (i) 36*46*57* (ii) 37*46*56* (iii) 37*48*57* (iv) 35*45*57*

Answer:
The correct output will be:
(i) 36*46*57*
Maximum Value of Stop=8
Minimum Value of Stop=6

Question 8:
Find the output:
int A 2 3 = {{1,2,3}, {5,6,7}};
for (int i = 1; i<2; i+ +)
for (int j = 0; j<3; j + +)
cout << A i j <<endl;
Answer:
5
6
7

Question 9:
Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include<iostream.h>  typedef char Text(80);  void main() { Text T = "Indian"; int Count = strlen(T); cout<<T<<"has"<<Count<<"characters" <<endl; }

Answer:

#include<iostream.h> #include<string.h>  typedef char Text[80];  void main() { Text T = "Indian";  int Count=strlen(T);  cout<<T<<"has"<<Count<<"characters"<<endl; }

Question 10:
Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include<iostream.h> typedef char[80] String;  void main() { String S = "Peace";  int L=strlen(S); cout<<S<<"has"<<L<<"characters"<<endl; }

Answer:

#include<string.h> #include<<iostream.h>  typedef char String[80];  void main() { String S="Peace"; int L=strlen(S); cout<<S<<"has"<<L<<"characters"<<endl; }

Question 11:
Based on the following C++ code, find out the expected correct output (s) from the options (i) to (iv). Also, find out the minimum and the maximum value that can be assigned to the variable Trick used in the code at the time when value of count is 3 :

void main() { char status[][10]={"EXCEL","GOOD", "OK"}; int Turn = 10, Trick; for(int Count=1;Count<4;Count++) { Trick = random(Count);  cout<<Turn-Trick<<Status[Trick]<<"#"; } } (i) 10EXCEL#EXCEL#8OK# (ii) 10EXCEL#8OK#9GOOD# (in) 10EXCEL#9GOOD#10EXCEL# (iv) 10EXCEL#10GOOD#8OK#

Answer:
None of the given output is correct.
The correct output is
10EXCEL#10EXCEL#9GOOD#
Minimum value = 0
Maximum Value = 3

TOPIC-3
Arrays and Functions

Very Short Answer Type Question

Question 1:
Observe the following program very carefully and write the names of those header file(s). which are essentially needed to compile and execute the following program successfully :

typedef char STRING[80];  void main() { STRING Txt[]="We love peace";  int count=0;  while(Txt[count]! = ’ ") if(isalpha(Txt Count) Txt[count++] = 1@";  else Txt[count++] = "#";  puts(Txt); }

Answer:
<ctype.h>, <stdio.h>

Short Answer Type Questions-I

Question 1:
Explain in brief the purpose of function prototype with the help of a suitable example.
Answer:
The Function prototype serves the following purposes :

  1. It tells the return type of the data that the function will return.
  2. It tells the number of arguments passed to the function.
  3. It tells the data types of each of the passed arguments.
  4. Also it tells the order in which the arguments are passed to the function.
#include<iostream.h> int timesTwo(int num);    // function prototype int main() { int number,response;  cout<<"Please enter a number:";  cin>>number; response = timesTwo(number);    // function call cout<<"The   Answer is"<<response;  return 0; } //timesTwo function  int timesTwo (int num) { int   Answer;    //local variable    Answer = 2*num;  return(  Answer); }

Question 2:
What is the difference between call by reference and call by value with respect to memory allocation ? Give a suitable example to illustrate using C+ + code.
Answer:
Call By Value : In call by value method, the called function creates its own copies of original values sent to it. Any changes that are made, occur on the function’s copy of values are not reflected back to the calling function.
Call By Reference : In call by reference method, the called function accesses and works with the original values using their references. Any changes that occur, takes place on the original values and are reflected back to the calling code.
Example:

//using call by reference #include<iostream.h> void swap(int &, int &); int main() { int a=10,b=20; swap(a,b); cout<<a<<” “<<b; return 0; } void swap(int &c, int &d) { int t; t=c; c=d; d=t; } output : 20 10//using call by value #include<iostream.h> void swap(int, int); int main() { int a=10,b=20; swap(a,b): cout<<a<<” “<<b; return 0; } void swap(int c, int d) { int t; t=C; C=d; d=t; } output: 10 20

Question 3:
What is the difference between Actual Parameter & Formal Parameter ? Give a suitable example to
illustrate both in a C++ code.
Answer:

Formal ParametersActual Parameters
1. These parameters
appear in function
definition.
2. Example:
void set(int a, int b)
{
int c=a-b;
cout<<c;
}
Here, a and b are formal
parameters.
1. These parameters
appear in function
call statement.
2. Example:
void main()
{
inta=10,b=20;
swap(a,b);
}
Here, a and b are
actual parameters.

Question 4:
Deepa has just started working as a programmer in STAR SOFTWARE company. In the company she has got her first assignment to be done using a C++ function to find the smallest number out of a given set of «numbers stored in a one-dimensional array. But she has committed some logical mistakes while writing the code and is not getting the desired result. Rewrite the correct code underlining the corrections done. Do not add any additional statements in the corrected code.

int find(int a[],int n) { int s=a[0] ; for(int x=l;x<n,-x++) if(a[x]>s) a[x]=s;   return(s); }

Answer:

int find(int a[],int n) { int s=a[0]; for(int x=l;x<n;x++) { if(a[x]<=s)   s=a[x];    } return(s);

Question 5:
What is the benefit of using default parameter/ argument in a function ? Give a suitable example to
illustrate it using C++ code.
Answer:
The benefit of using default arguments is that whenever there is no value supplied to the parameter
within the program, its default value can be used.
Example :

#include<iostream.h>  #include<conio.h> int main() {  int a,b=20,c;  a=change(c,b);     return a ; } int change(int a=10,b) { int temp;  temp=a;  a=b; return temp;  } In the above example, change () assigns a value 10 to a because it is defined by default.

Question 6:
What is the benefit of using function prototype for a function? Give a suitable example to illustrate it using
C++ code. 
Answer:
The benefit of using a function prototype is to have a clear representation of the type of value
that the function would return and type of argument the function needs.
Example :
int function (int a, int b);
The above is a prototype for a function named ‘function’ that has two integer arguments a & b which returns as integer value.

Question 7:
Write a prototype of a function named percent, which takes an integer as value parameter & return a float type value. The parameter should have default value of 10.
Answer:
float percent(int a=10) ;

Question 8:
Observe the following C++ code carefully and write the same after removing syntax errors.

#define change(A,B)2*A+B; void main() { float X,Y,F;  cin>>X>>Y; F=Change(X,Y); cout<<"result:<<F<<endline; }

Answer:
The corrected code is :

#define change(A,B)2*A B;  void main() { float X,Y,F;  cin>>X>>Y; F=change(X,Y);   cout<<"result:<<F<<endl; }

Question 9:
Write a function in C++ to accept two integers as parameters and returns the greater of these numbers.
Answer:

int max (int a, int b) { if(a>b)return a;  else return b;   }

Question 10:
Write the output from the following C+ + program code :

#include<iostream.h>  includecctype.h>  void strcon(char s[]) { for(int  i=0,1= 0;s[i]! = "" ;i++,1++) ;  for(int j=0;j<l;j++) {  if (isupper(s[j]))  s[j]=tolower(s[j])+2;  else if(islower(s[j]))  s[j]=toupper(s[j])-2;     else  s[j]="@";  } } void main()   { char *c="Romeo Joliet";  strcon(c); cout<<"Text= "<<c<<endl;  c=c+3; cout<<"New Text= "<<c<<endl;  c=c+5-2; cout<<"last Text= "<<c }

Answer:

Text = @tMKCM@lMJGCR
New Text = <KCM@1MJGCR
Last Text = @1MJGCR

Question 11:
Study the following C++ program and select the possible output(s) from it : Find the maximum and minimum
value of L.

#include<stdlib.h> #include<iostream.h> #include<string.h>  void main() { randomize(); char P[]="C++PROGRAM"; long L; for(int 1=0;P[I]!="R";I++) { L=random(sizeof(L))+5;  cout<<P[L]<<"; } } (i) R-P-O-R    (ii) P-0-R-+- (iii) O-R-A-G (iv) A-G-R-M- 

Answer:

c++PROGRAM
0123456789

Possible Values:
Possible Output is (iii) O-R-A-G
Minimum value of L = 5
Maximum Value of L = 8

Question 12:
Write a user defined function DIVTQ which takes an integer as parameter and returns whether
it is divisible by 13 or not. The function should return 1 if it is divisible by 13, otherwise it should return 0.

int DIVT(int x) { int f; if(x%13 == 0)  f=1;  else f=0; Return f; }

Question 13:
Find output of the following program segment :

#include<iostream.h> #include<ctype.h> void Mycode(char Msg[],char CH) { for(int cnt=0;Msg[cnt]!="";cnt++) {  if(Msg[cnt]>="B"&& Msg [cnt]<="G") Msg[cnt] =tolower(Msg[cnt]); else if(Msg[cnt]=="N"?Msg[cnt]=="n"?Msg[c nt]==" ") Msg[cnt]=CH;  else if(cnt%2==0) Msg[cnt]=toupper(Msg[cnt]);  else Msg[cnt]=Msg[cnt-1]; }  } void main() { char MyText[]="Input Raw"; Mycode(MyText,"@");  cout<<"NEW TEXT:"<<MyText<<endl; }

Answer:
I@PPT@RRW

Question 14:
Observe the following program and find out, which output(s) out of (i) to (iv) will not expected from the program ? What will be the minimum and the maximum value assigned to the variable chance ?

#include<iostream.h> #include<stdib.h>  void main() { randomize() int Game[]=(10,16),P;  int Turns=random(2)+5;  for(int T=0;T<=2;T++) { P=random(2); Cout<<Game[P]+Turn<<"*";  }  } (i) 15*22*   (ii) 22*16*  (iii) 16*21* (iv) 21*22*

Answer:
Option 1:
None of the outputs are correct Variable named chance does not exist in the program, hence no minimum and maximum values for it.
OR
Option 2 :
Error in Question OR
Option 3: Assuming
Cout<<GameP+Turn<<“#”; in place of cout << GameP + Turn <<“*”;


Since out of the above possible outputs only option (ii) is correct, hence The outputs not ! expected from the program are (i) (iii) and (iv)

Question 15:
Observe the following program and find out which output (s) out if (i) to (iv) will not be f expected from the program ? What will be the minimum and the maximum value assigned to the variable Chance ?

#include<iostream.h> #include<stdlib.h> void main() { randomize() ; int Arr[]={9, 6},N; int Chance = random(2)+10;  for(int C=0;C<2;C++) { N=random(2); cout<<Arr[N]+Chance<"#"; } } (i) 9#6# (ii) 19#17# (iii) 19#16# (iv) 20#16#

Answer:
The outputs not expected from the program are (i), (ii) and (iv)
Minimum Value of Chance = 10
Maximum Value of Chance = 11

Question 16:
Find and write the output of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

typedef char WORD(80];  void CODEWORD(WORD W) { int LEN=strlen (W);  for(int 1=0;I<LEN-1;I+=2) { char SW=W[I]; W[I]=W[I+1]; W[1+1]=SW;  } for(1=1;I<LEN;I+=2) if(W[I]>=1M1&&W[I]<="U’) W[I)="#"; } void main() { WORD Wrd="EDITORIALS";  codeword(Wrd);  cout<<Wrd<<endl; }

Answer:
DETIROAISL

Question 17:
Correct the following code and rewrite

#define convert(P,Q)P+2*Q;  void main() { float A,B,Result; cin>>A>>B; result=Convert[A,B]; cout<<"output"<<Result<<;  endline; }

Answer:

#define convert(P,Q)P+2*Q  void main() { float A,B,Result;  cin>>A>>B; Result=convert(A,B);   cout<<"Output"<<Result<<endl; }

Short Answer Type Questions-ll

Question 1:
Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underline.
Note : Assume all required header files are already being included in the program.

#Define float MaxSpeed =60.5;  void main() } int MySpeed char Alert = "N";  cin>>MySpeed;  if MySpeed>MaxSpeed  Alert = "Y";  cout<<Alert<<endiline; }

Answer:

#define float MaxSpeed_60.5; //Error 1, 2, 3 void main() {  int MySpeed;   //Error 4 char Alert="N";  cin>>MySpeed; if(MySpeed>MaxSpeed)    //Error 5 Alert="Y"; cout<<Alert<<endl;    //Error 6

Question 2:
Write the ouputs of the following C+ + program code :
Note : Assume all required header files are already being included in the program.

void Location(int &X, int Y=4) { Y+=2;  X+=Y; } void main() { int PX=10, PY=2;  Location(PY):  cout<<PX<<","<<PY<<endl;  Location (PX,PY);  cout<<PX<<","<<PY<<end; }

Answer:
10,8
20,8

Question 3:
Find the output of the following program :

#include<iostream.h>  void in(int x, int y, int &z) { x+=y; y--; z*=(x-y); }  void out(int z,int y, int &x) { x*=y;  y++; z/=(x+y); } void main() { int a=20, b=30, c=10;  out(a,c,b); cout<<a<<"#"<<b<<"#"<<c<<"#"<<endl;  in(b,c,a); cout<<a<<"@"<<b<<"@"<<c<<"@"<<endl;  out(a,b,c); cout<<a<<"$"<<b<<"$"<<c<<"$"<<endl; }

Answer:
20#300#10#
620@300@10@
6203003000$

Question 4:
Find the output of the following program segment :

int a = 3 ; void demo(int x, int y, int &z) { a+= x+y; z=a+y; y+=X; cout<<x<<"*"<<y<<"*"<<z<<endl; } void main() { int a=2,b=5; demo( : : a, a, b):     demo( : : a, a, b);     }

Answer:
3 * 5 * 10
8 * 10 * 20

TOPIC-4
Structures

Short Answer Type Questions-ll 3markseach

Question 1:
Find the output of the following program :

#include<iostream.h> void ChangeArray(int number, int ARR[], int Size) { for(int L=0;L<Size;L++)  if(L<number) ARR[L]+=L; else ARR[L]*=L; } void Show (int ARR[], int Size) { for(int L=0;L<Size;L++)  (L%2==0)?  cout<<ARR[Ll<<"#": cout<< ARR[L]<<endl; } void main() { int Array[]={30,20,40,10,60,50}; ChangeArray(3,Array,6); Show(Array,6); }

Answer:
Output:
30#21
42# 30
240#250

Question 2:
Find the output of the following program :

#include<iostream.h> void Switchover(int A[], int N, int split) {  for(int K=0;K<N K++)  if(K<split) A[K]+=K;  else A[K]*=K; } void Display(int A[], int N) { for(int K=0;K<N;K++) (K%2==0)?cout<<A[K]<<"%" : cout<< A[K]<<endl; } void main() { int H[]={30,40,50,20,10,5}; Switchover(H,6,3); Display(H,6); }

Answer:
Output:
30%41
52%60
40% 25

Question 3:
Find the output of the following program :

#include<iostream.h> struct GAME {  Int Score, Bonus, }; void Play(GAME &g, int N=100) {  g.score ++;  g.Bonus+=N; }  void main() {GAME G={110,50}; Play(G,10); cout<<G.Score<<":"<<G.Bonus<<endl;  Play(G); cout<<G.Score<<":"<<G.Bonus<<endl, Play(G,15); cout<<G.Score<<":"<<G.Bonus<<endl; }

Answer:
Output:
111 : 60
112:160
113:175

Question 4:
Rewrite the following program after removing the syntax errors (if any). Underline each correction.

#include<iostream.h>  struct Pixels {int Color<<Style;}  void ShowPoint(Pixels P) { cout<<P.Color<<P.Style<<endl;  void main() { Pixels Pointl={5,3}; Show Point(Pointl);  Pixels Point2=Point1; Color.Point1+=2; Show Point(Point2) ;  }

Answer:

#include<iostream.h>  struct Pixels {int Color, Style};  void ShowPoint(Pixels P) {  cout<<P.Color<<P.Style<<endl;)    // In cascading of Cout,<<to be used  void main() { Pixels Point1={5,3);    //{} to be used to initialise of members of the object ShowPoint(Point1); Pixels Point2=Point1; Point 1.Color+=2; ShowPoint(Point2); }

Question 5:
Find the output of the following program :

#include<iostream. h>    struct POINT  {int X, Y, Z ;}; void Stepln(POINT &P, int Step=1) { P.X+=Step; P.Y-=Step; P.Z+=Step; void Stepout(POINT&P, int Step=1) P.X-=Step; P.Y+=Step; P.Z-=Step; } void main() { POINT Pl={15,25,5}, P2={10,30,20} ; Stepln(P1); StepOut(P2,4); cout<<Pl.X<<","<<Pl.Y<<","<<Pl.Z<<endl; cout<<P2.X<<","<<P2.Y<<","<<P2.Z<<endl; Stepln(P2,12); cout<<P2.X<<","<<P2.Y<<","<<P2.Z<<endl; }

Answer:
Output:
16,24,6
6, 34,16
18,22,28

Question 6:
Find the output of the following program :

#include<iostream.h>  struct Score  { int Year;  float Topper; }; void Change(Score*S, int x=20) {S -> Topper = (S->Topper+25)-x; S->Year++;}  void main() { Score Arr[]={ {2007, 100}, {2008, 95}}; Score * Point = Arr; Change(Point,50);  cout<<Arr[0].Year<<"#"<<Arr[0].Topper<<endl; Change(++Point);  cout<<Point->Year<<"#"<<Point->Topper<<endl; }

Answer:
Output:
2008 # 75
2009 # 100

Question 7:
Find the output of the following program :

#include<iostream.h>  struct THREE_D{int X,Y,Z;}; void Moveln(THREE_D & T, int Step=1) { T.X+=Step; T.Y-=Step; T.Z+=Step; } Void MoveOut(THREE_D & T, int Step = 1) { T.X-=Step ; T.Y+=Step ; T.Z-=Step ; } Void main() { THREE_D T1={10,20,5},  T2 ={30,10,40}; Moveln(Tl); MoveOut(T2,5); Cout<<Tl.X<<11,"<<T1.Y<<","<<T1.Z<<endl; Cout<<T2.X<<","<<T2.Y<<","<<T2.Z<<endl; Moveln(T2,10); COUt<<T2.X<<","<<T2.Y<<","<<T2.Z<<endl; }

Answer:
11,19,6
25,15,35
35, 5,45

Read More

परियोजना | class 12th | Hindi श्रवण एवं वाचन, परियोजना ncert solution

Class 12 Hindi परियोजना

परियोजना कार्य-1

कोई युवा पुरुष अपने घर से बाहर निकलकर बाहरी संसार में अपनी स्थिति जमाता है, तब पहली कठिनता उसे मित्र चुनने में पड़ती है। यदि उसकी स्थिति बिलकुल एकांत और निराली नहीं रहती तो उसकी जान-पहचान के लोग धड़ाधड़ बढ़ते जाते हैं और थोड़े ही दिनों में कुछ लोगों से उसका हेल-मेल हो जाता है। यही हेल-मेल बढ़ते-बढ़ते मित्रता के रूप में परिणत हो जाता है। मित्रों के चुनाव की उपयुक्तता पर उसके जीवन की सफलता निर्भर हो जाती है, क्योंकि संगति का गुप्त प्रभाव हमारे आचरण पर बड़ा भारी होता है।

हम लोग ऐसे समय में समाज में प्रवेश करके अपना कार्य आरंभ करते हैं, जबकि हमारा चित्त कोमल और हर तरह का संस्कार ग्रहण करने के लिए रहता है। हमारे भाव अपरिमार्जित और हमारी प्रवृत्ति अपरिपक्व रहती है। हम लोग कच्ची मिट्टी की मूर्ति के समान रहते हैं, जिसे जो जिस रूप में चाहे, उस रूप में ढाले-चाहे राक्षस बनाए, चाहे देवता। ऐसे लोगों का साथ करना हमारे लिए बुरा है, जो हमसे अधिक दृढ़ संकल्प के हैं, क्योंकि हमें उनकी हर बात बिना विरोध के मान लेनी पड़ती है।

पर ऐसे लोगों का साथ करना और भी बुरा है, जो हमारी ही बात को ऊपर रखते हैं, क्योंकि ऐसी दशा में न तो हमारे ऊपर कोई नियंत्रण रहता है और न हमारे लिए कोई सहारा रहता है। दोनों अवस्थाओं में जिस बात का भय रहता है, उसका पता युवकों को प्रायः बहुत कम रहता है। यदि विवेक से काम लिया जाए तो यह भय नहीं रहता, पर युवा पुरुष प्रायः विवेक से कम काम लेते हैं। कैसे आश्चर्य की बात है कि लोग एक घोड़ा लेते हैं तो उसके सौ गुण-दोष को परख कर लेते हैं, पर किसी को मित्र बनाने में उसके पूर्व आचरण और स्वभाव आदि का कुछ भी विचार और अनुसंधान नहीं करते।

वे उसमें सब बातें अच्छी-ही-अच्छी मानकर अपना पूरा विश्वास जमा देते हैं। हँसमुख चेहरा, बातचीत का ढंग, थोड़ी चतुराई या साहस – ये ही दो-चार बात किसी में देखकर लोग चटपट उसे अपना बना लेते हैं। हम लोग यह नहीं सोचते कि मैत्री का उद्देश्य क्या है, क्या जीवन के व्यवहार में उसका कुछ मूल्य भी है। यह बात हमें नहीं सूझती कि यह ऐसा साधन है, जिससे आत्मशिक्षा का कार्य बहुत सुगम हो जाता है। एक प्राचीन विद्वान का वचन है, “विश्वासपात्र मित्र से बड़ी भारी रक्षा रहती है।

जिसे ऐसा मित्र मिल जाए उसे समझना चाहिए कि खज़ाना मिल गया।” विश्वासपात्र मित्र जीवन की एक औषध है। हमें अपने मित्रों से यह आशा रखनी चाहिए कि वे उत्तम संकल्पों से हमें दृढ़ करेंगे, दोषों और त्रुटियों से हमें बचाएँगे, हमारे सत्य, पवित्रता और मर्यादा के प्रेम को पुष्ट करेंगे, जब हम कुमार्ग पर पैर रखेंगे, तब वे हमें सचेत करेंगे, जब हम हतोत्साहित होंगे, तब हमें उत्साहित करेंगे। सारांश यह है हमें उत्तमतापूर्वक जीवन-निर्वाह करने में हर तरह से सहायता देंगे।

सच्ची मित्रता में उत्तम वैद्य की-सी निपुणता और परख होती है, अच्छी-से-अच्छी माता का-सा धैर्य और कोमलता होती है। ऐसी ही सहायता करने का प्रयत्न प्रत्येक व्यक्ति को करना चाहिए। छात्रावस्था में मित्रता की धुन सवार रहती है। मित्रता हृदय से उमड़ी रहती है। पीछे के जो स्नेह-बंधन होते हैं, उनमें न तो उतनी उमंग रहती है न उतनी खिन्नता। बाल-मैत्री में जो मग्न करनेवाला आनंद होता है, वह और कहाँ? कैसी मधुरता और कैसी अनुरक्ति होती है, कैसा अपार संवास होता है!

हृदय से कैसे-कैसे उद्गार निकलते हैं! भविष्य के संबंध में कैसी लुभानेवाली कल्पनाएँ मन में रहती हैं। कितनी बातें लगती हैं और कितनी जल्दी मानना है। ‘सहपाठी की मित्रता’ इस उक्ति में हृदय के कितने भारी उथल-पुथल का भाव भरा हुआ है। किंतु जिस प्रकार युवा पुरुष की मित्रता स्कूल के एक की मित्रता से दृढ, शांत और गंभीर होती है, उसी प्रकार हमारी अवस्था के मित्र बाल्यावस्था के मित्रों से कई बातों में भिन्न होते हैं। मैं जानता हूँ कि मित्र चाहते हुए बहुत-से लोग मित्र के आदर्श की कल्पना करते होंगे।

पर इस कल्पित आदर्श से तो हमारा काम जीवन में चलता नहीं। सुंदर प्रतिभा, मनभावनी चाल और स्वच्छंद प्रकृति, दो-चार बातें देखकर मित्रता की जाती है, पर जीवन-संग्राम में साथ चले मित्रों में इनसे कुछ अधिक बातें चाहिए। मित्र केवल उसे नहीं कहो, जिसके गुणों की तो हम प्रशंसा करें, पर जिससे हम स्नेह न कर सकें, जिससे अपने छोटे-छोटे काम ही हम निकालते जाएँ, पर भीतर-ही-भीतर घृणा करते रहें। मित्र सच्चे पथ-प्रदर्शक के समान होना चाहिए, जिस पर हम पूरा विश्वास कर सकें।

मित्र भाई के समान होना चाहिए, जिसे हम अपना प्रीति-पात्र बना सकें। हमारे और हमारे मित्र के बीच सच्ची सहानुभूति होनी चाहिए। ऐसी सहानुभूति जिससे एक के हानि-लाभ को दूसरा अपना हानि-लाभ समझे।। मित्र का कर्तव्य इस प्रकार बताया गया है, “उच्च और महान कार्यों में इस प्रकार सहायता देना, मन बढ़ाना और साहस दिलाना कि तुम अपनी-अपनी सामर्थ्य से बाहर काम कर जाओ।” यह कर्तव्य उसी से पूरा होगा, जो दृढ़ चित्त और सत्य-संकल्प का हो।

इससे हमें ऐसे ही मित्रों की खोज में रहना चाहिए जिनमें हमसे अधिक आत्मबल हो। हमें उनका पल्ला उसी तरह पकड़ना चाहिए, जिस तरह सुग्रीव ने राम का पल्ला पकड़ा था। मित्र हों तो प्रतिष्ठित और शुद्ध हृदय के हों, मृदुल और पुरुषार्थी हों, शिष्ट और सत्यनिष्ठ हों, जिससे हम अपने को उनके भरोसे पर छोड़ सकें और यह विश्वास कर सकें कि उनसे किसी प्रकार का धोखा न होगा। जो बात ऊपर मित्रों के संबंध में कही गई है, वही जान-पहचानवालों के संबंध में भी ठीक है।

जो हमारे जीवन को उत्तम और आनंदमय बनाने में कुछ सहायता दे सकते हों, यद्यपि उतनी नहीं जितनी गहरे मित्र दे सकते हैं। मनुष्य का जीवन थोडा है, उसमें खोने के लिए समय नहीं। यदि क, ख और ग हमारे लिए कुछ नहीं कर सकते हैं, न कोई बुद्धिमानी या विनोद की बातचीत कर सकते हैं, न कोई अच्छी बात बतला सकते हैं, न सहानुभूति द्वारा हमें ढाढ़स बँधा सकते हैं, न हमारे आनंद में सम्मिलित हो सकते हैं, न हमें कर्तव्य का ध्यान दिला सकते हैं, तो ईश्वर हमें उनसे दूर ही रखे।

आजकल जान-पहचान बढाना कोई बड़ी बात नहीं है। कोई भी युवा पुरुष ऐसे अनेक युवा पुरुषों को पा सकता है, जो उसके साथ थियेटर चले जाएँगे, नाचरंग में जाएँगे, सैर-सपाटे में जाएँगे, भोजन का निमंत्रण स्वीकार करेंगे। यदि ऐसे जान-पहचान के लोगों से कुछ हानि न होगी, तो लाभ भी न होगा। पर यदि हानि होगी तो बड़ी भारी होगी। कुसंग का ज्वर सबसे भयानक होता है। यह केवल नीति और सद्वृत्ति का ही नाश नहीं करता, बल्कि बुद्धि का भी क्षय करता है।

किसी युवा पुरुष की संगति यदि बुरी होगी तो वह उसके पैरों में बँधी चक्की के समान होगी, जो उसे दिन-रात अवनति के गड्ढे में गिराती जाएगी और यदि अच्छी होगी तो सहारा देने वाली बाहु के समान होगी, जो उसे निरंतर प्रगति की ओर उठाती जाएगी। इंग्लैंड के एक विद्वान को युवावस्था में राज-दरबारियों में जगह नहीं मिली। इस पर जिंदगी भर वह अपने भाग्य को सराहता रहा। बहुत-से लोग इसे अपना बड़ा भारी दुर्भाग्य समझते, पर वह अच्छी तरह जानता था कि वहाँ वह बुरे लोगों की संगति में पड़ता जो उसकी आध्यात्मिक उन्नति में बाधक होते।

बहुत-से लोग ऐसे होते हैं, जिनके घड़ी भर के साथ से सद्बुद्धि भ्रष्ट हो जाती है, क्योंकि उनके ही बीच में ऐसी-ऐसी बातें कही जाती हैं जो कानों में न पड़नी चाहिए, चित्त पर ऐसे प्रभाव पड़ते हैं, जिससे उसकी पवित्रता का नाश होती है। बुराई अटल भाव धारण करके बैठती है। बुरी बातें हमारी धारणा में बहुत दिनों तक टिकती हैं। इस बात को प्रायः सभी लोग जानते हैं कि भद्दे व फूहड़ गीत जितनी जल्दी ध्यान में चढ़ते हैं, उतनी जल्दी कोई गंभीर या अच्छी बात नहीं।

एक बार एक मित्र ने मुझसे कहा कि उसने लड़कपन में कहीं से बुरी कहावत सुनी थी, जिसका ध्यान वह लाख चेष्टा करता है कि न आए, पर बार-बार आता है। जिन भावनाओं को हम दूर रखना चाहते हैं, जिन बातों को हम याद करना नहीं चाहते, वे बार-बार हृदय में उठती हैं और बेधती हैं। अतः तुम पूरी चौकसी रखो, ऐसे लोगों को साथी न बनाओ जो अश्लील, अपवित्र और फूहड़ बातों से तुम्हें हँसाना चाहें। सावधान रहो। ऐसा न हो कि पहले-पहल तुम इसे एक बहुत सामान्य बात समझो और सोचो कि एक बार ऐसा हुआ, फिर ऐसा न होगा।

अथवा तुम्हारे चरित्रबल का ऐसा प्रभाव पड़ेगा कि ऐसी बातें बकने वाले आगे चलकर स्वयं ही सुधर जाएँगे। नहीं, ऐसा नहीं होगा। जब एक बार मनुष्य अपना पैर कीचड़ में डाल देता है, तब फिर यह नहीं देखता कि वह कहाँ और कैसी जगह पैर रखता है। धीरे-धीरे उन बुरी बातों में अभ्यस्त होते-होते तुम्हारी घृणा कम हो जाएगी। पीछे तुम्हें उनसे चिढ़ न मालूम होगी, क्योंकि तुम यह सोचने लगोगे कि चिढ़ने की बात ही क्या है।

तुम्हारा विवेक कुंठित हो जाएगा और तुम्हें भले-बुरे की पहचान न रह जाएगी। अंत में होते-होते तुम भी बुराई के भक्त बन जाओगे। अतः हृदय को उज्ज्वल और निष्कलंक रखने का सबसे अच्छा उपाय यही है कि बुरी संगति की छूत से बचो। एक पुरानी कहावत है-
“काजल की कोठरी में कैसो ही सयानो जाय।
एक लीक काजल की लागि है पै लागि है।”

प्रश्नः 1.
बाहरी संसार में उतरने पर नौजवानों के समक्ष पहली कठिनाई क्या आती है?
उत्तरः
जब कोई नौजवान अपने घर से बाहर निकलकर बाहरी संसार में अपनी स्थिति जमाता है तो उसे पहली कठिनाई इस बात की आती है कि वह किसे अपना मित्र बनाए।

प्रश्नः 2.
आजकल कैसे लोगों के साथ सरलता से जान-पहचान हो जाती है?
उत्तरः
आजकल ऐसे लोगों के साथ सरलता से जान-पहचान हो जाती है जो साथ थियेटर देखने जाएँ, नाचरंग में जाएँ, सैर सपाटे में जाएँ, भोजन का निमंत्रण स्वीकार करें।

प्रश्नः 3.
हमसे अधिक दृढ़ संकल्प वाले लोगों का साथ हमारे लिए क्यों बुरा हो सकता है?
उत्तरः
जब हमारे साथ ऐसे व्यक्ति होते हैं जो हमसे अधिक दृढ़ संकल्प वाले होते हैं तो हमें उनकी हर बात बिना विरोध के माननी पड़ती है।

प्रश्नः 4.
छात्रावास और उसके बाद की मित्रता में क्या अंतर होता है?
उत्तरः
छात्रावास की मित्रता में उमंग और आनंद होता है, मधुरता और अनुरिक्त होती है। उसमें जल्दी रूठने और मान जाने प्रवृत्ति होती है। इसके विपरीत बाद की मित्रता में न उतनी उमंग होती है और न उतनी खिन्नता। युवा पुरुष की मित्रता स्कूल के बालक की मित्रता से दृढ़, शांत और गंभीर होती है।

प्रश्नः 5.
अपने से अधिक आत्मबल रखने वाले व्यक्ति को मित्र बनाने से क्या लाभ है?
उत्तरः
अपने से अधिक आत्मबल रखने वाले व्यक्ति को मित्र बनाने से यह लाभ है कि वह उच्च और महान कार्यों में इस प्रकार सहायता देगा कि तुम अपनी सामर्थ्य से बाहर काम कर जाओ।

प्रश्नः 6.
राजदरबार में जगह न मिलने पर इंग्लैंड का एक विद्वान अपने भाग्य को क्यों सराहता रहा?
उत्तरः
जब इंग्लैंड के एक विद्वान को राजदरबार में जगह नहीं मिली तो वह अपने भाग्य को सराहता रहा क्योंकि वह जानता था कि राजदरबार में उसे बुरे लोगों की संगति में पड़ना पड़ता, जिससे उसके आध्यात्मिक विकास में बाधा पड़ती।

प्रश्नः 7.
सच्ची मित्रता में वैद्य की-सी निपुणता और परख और माता का-सा धैर्य और कोमलता होती है-स्पष्ट कीजिए।
उत्तरः
एक निपुण वैद्य की पारखी दृष्टि से कोई भी रोग छिप नहीं पाता और वह उसका उचित उपचार करके रोगी को स्वस्थ कर देता है। अच्छा मित्र भी अपने मित्र की कमियों को बड़ी आसानी से परख लेता है और उन्हें दूर करने का प्रयास करता है। माता भी अपने बच्चे की भलाई का ध्यान रखती है और धैर्य एवं कोमलता के साथ वह बालक को सही मार्ग पर चलाती है। अच्छा मित्र भी वैसे ही करता है।

प्रश्नः 8.
मित्र का चुनाव करते समय हमें किन बातों का ध्यान रखना चाहिए?
उत्तरः
मित्र बनाते समय हमें निम्नलिखित सावधानियाँ रखनी चाहिए

  1. मित्र बनाते समय खूब सोच-विचार लेना चाहिए।
  2. सुंदर प्रतिभा, मनभावनी चाल और स्वच्छंद प्रकृति के लोगों को मित्र नहीं बनाना चाहिए।
  3. परस्पर सच्ची सहानुभूति प्रकट करने वालों को मित्र बनाना चाहिए।
  4. विश्वासपात्र होना चाहिए।
  5. हमें ऐसे मित्र कभी नहीं बनाने चाहिए जो हमारी झूठी प्रशंसा करता हो और मन से घृणा करता हो।
  6. हमें ऐसे मित्रों का परित्याग कर देना चाहिए जो हमें कुमार्ग की ओर ले जाएँ और हमारे दोषों को दूर न करें।
  7. सभी प्रकार के अवगुणों को छिपाने वाले और गुणों को प्रकट करने वाले को मित्र बनाना चाहिए।

परियोजना कार्य-2

आज से करीब डेढ हज़ार साल पहले पाटलिपुत्र नगर नंद, मौर्य और गुप्त सम्राटों की राजधानी था। दूर-दूर तक इस नगर की कीर्ति फैली हुई थी। राजधानी होने के कारण देशभर के प्रतिष्ठित पंडित यहाँ एकत्र होते थे। प्रख्यात नालंदा विश्वविद्यालय में दूसरे देशों के विद्यार्थी भी विशेष अध्ययन के लिए पहुँचते थे। उस समय पाटलिपुत्र नगर ज्योतिष के अध्ययन के लिए मशहूर था। एक दिन सवेरे से ही गंगा, सोन और गंडक नदियों के संगम की ओर लोगों की भीड़ उमड़ पड़ी थी। उस दिन अपराह्न में सूर्य को ग्रहण लगने वाला था।

लोगों में यह प्रचारित था कि “राहु नाम का राक्षस सूर्य को निगल जाता है, तब ग्रहण लगता है। ग्रहण के समय उपवास रखना चाहिए, खूब दान-पुण्य करना चाहिए। तभी इस राक्षस के चंगुल से सूर्य-देवता को जल्दी-से-जल्दी मुक्ति मिलती है।” मगर पाटलिपुत्र नगर से थोड़ी दूर के आश्रम में कुछ दूसरा ही माहौल था। टीले पर बसे उस आश्रम के लंबे-चौड़े आँगन में ताँबे, पीतल और लकड़ी के तरह-तरह के यंत्र रखे हुए थे। उनमें से कुछ यंत्र गोल थे, कुछ कटोरे-जैसे, कुछ वर्तुलाकार और कुछ शंकु की तरह के।

वस्तुतः वह एक वेधशाला थी। वहाँ के ज्योतिषियों ने हिसाब लगाकर पहले से ही भविष्यवाणी की थी कि ठीक किस समय ग्रहण लगेगा, कहाँ-कहाँ दिखाई देगा और कितने समय तक रहेगा। आज उन्हें देखना था कि उनका हिसाब ठीक निकलता है या नहीं। इसलिए सभी उत्सुकता से ग्रहण के क्षण का इंतज़ार कर रहे थे। मगर वहाँ पर एक तरुण विद्यार्थी जो अपने साथियों को समझा रहा था, “पृथ्वी की बड़ी छाया जब चंद्र पर पड़ती है, तो चंद्र ग्रहण होता है।

इसी प्रकार चंद्र जब पृथ्वी और सूर्य के बीच में आता है और वह सूर्य को ढक लेता है, तब सूर्य ग्रहण होता है। आज भी ऐसा ही होने वाला है, कोई राहु नाम का राक्षस सूर्य को निगल जाता है—यह कथन पुराण की कथा है।” ग्रहणों की वैज्ञानिक व्याख्या करने वाले उस तरुण पंडित का नाम था—आर्यभट। ‘भट’ का मतलब है-योद्धा। सचमुच आर्यभट अज्ञान के विरुद्ध ज्ञान का युद्ध जीवन भर लड़ते रहे। आर्यभट दक्षिणापथ में गोदावरी तट क्षेत्र के अश्मक जनपद में पैदा हुए थे। इसलिए बाद में वे आश्मकाचार्य के नाम से प्रसिद्ध हुए।

गणित एवं ज्योतिष के अध्ययन में उनकी गहरी रुचि थी। आर्यभट अपने विचार बेहिचक प्रस्तुत कर देते थे। ग्रहणों के बारे में ही नहीं, आकाश की दूसरी अनेक घटनाओं के बारे में भी उनके अपने स्वतंत्र विचार थे। उस ज़माने के लोग समझते थे कि हमारी पृथ्वी आकाश में स्थिर है और तारामंडल एवं सूर्य गतिशील। आर्यभट हमारे देश के पहले ज्योतिषी थे जिन्होंने साफ़ शब्दों में कहा है कि पृथ्वी स्थिर नहीं है। यह अपनी धुरी पर चक्कर लगाती है।

तो फिर आकाश के तारे हमें चक्कर लगाते क्यों दिखाई देते हैं? पृथ्वी के चक्कर लगाने का पता हमें क्यों नहीं चलता? आर्यभट का उत्तर था- “समझ लो कि नदी में एक नाव है और वह धारा के साथ तेजी से आगे बढ़ रही है। तब उसमें बैठा हुआ आदमी किनारे की स्थिर वस्तुओं को उलटी दिशा में जाता हुआ अनुभव करता है। उसी तरह आकाश के तारों की बात है। पृथ्वी अपनी धुरी पर पश्चिम से पूर्व की ओर घूमती है और इसके साथ हम भी घूमते रहते हैं, इसलिए आकाश में स्थित तारामंडल हमें पूर्व से पश्चिम की ओर जाता जान पड़ता है।

वस्तुतः तारामंडल स्थिर है और पृथ्वी अपनी धुरी पर चक्कर लगाती है। कोई भी ज्योतिषी इस मत को मानने के लिए तैयार नहीं होता था। यही कारण था कि आर्यभट का मत सही होने पर भी आगे की सदियों तक हमारे देश के बड़े-बड़े ज्योतिषी भी यही मानते रहे कि पृथ्वी स्थिर है। वराहमिहिर और ब्रह्मगुप्त जैसे महान ज्योतिषी भी ऐसे ही थे। आर्यभट की पुस्तक का नाम है – आर्यभटीय। पुस्तक पद्य में है। भाषा संस्कृत है। प्राचीन भारत में गणित और ज्योतिष का अध्ययन साथ-साथ होता था, इसलिए इन दोनों विषयों का विवेचन प्रायः एक ही ग्रंथ में कर दिया जाता था।

पुस्तक के चार भाग हैं-दशगीतिका, गणित, कालक्रिया और गोल। आर्यभटीय में कुल 121 श्लोक हैं। प्रत्येक श्लोक में दो पंक्तियाँ हैं। उस समय तक भारत में गणित और ज्योतिष से संबंधित जितनी महत्त्वपूर्ण बातें खोजी गई थीं, उन सबको आर्यभट ने अत्यंत संक्षेप में अपनी पुस्तक में प्रस्तुत कर दिया है। पुराना ज्ञान ही नहीं, उन्होंने अपनी नई खोजी हुई बातें भी पुस्तक में रखी हैं। आर्यभटीय भारतीय गणित-ज्योतिष का पहला ग्रंथ है जिसमें इसके रचनाकार और रचनाकाल के बारे में स्पष्ट सूचना मिलती है।

ज्ञान-विज्ञान के क्षेत्र में संसार को प्राचीन भारत की सबसे बड़ी देन है-शून्य सहित केवल दस अंक संकेतों से ही संख्याओं को व्यक्त करना। इस दाशमिक स्थानमान अंक-पद्धति की खोज आर्यभट से तीन-चार सदियों पहले हो चुकी थी। आर्यभट इस नई अंक पद्धति से परिचित थे। उन्होंने अपने ग्रंथ के आरंभ में वृंद (1000000000) अर्थात अरब तक ही दशगुणोत्तर संख्या-संज्ञाएँ देकर लिखा है कि इनमें प्रत्येक स्थान पिछले स्थान से दस गुणा है।

प्राचीन भारत में गणित-ज्योतिष के ग्रंथ भी पद्य में लिखे जाते थे, इसलिए उनमें ख (0), पृथ्वी (1), (2), ऋतु (6) जैसे शब्दों से संख्याओं को व्यक्त किया जाता था। इन शब्दांकों को उनके क्रम में लिखने का नियम था; जैसे खचतुष्ट-रदअर्णव (चार शून्यदाँत-सागर) का अर्थ होता था-4320000. आर्यभट अपने ग्रंथ को बहुत छोटा बनाना चाहते थे, वे अपने विचारों को कम-से-कम शब्दों में प्रस्तुत करना चाहते थे।

आर्यभट ने अक्षरों को संख्यामान प्रदान किए। जैसे-क् = 1, ख् = 2, ग् = 3 इत्यादि। अ, इ, उ आदि स्वरों को उन्होंने एक, सौ, दस हज़ार जैसे शतगुणोत्तर मान दिए। इस तरह उन्होंने व्यंजनों और स्वरों के मेलजोल से बड़ी से बड़ी संख्या को संक्षेप में लिखने का एक नया तरीका खोज निकाला। इस नई अक्षरांक पद्धति को अपनाकर आर्यभट बड़ी-बड़ी संख्याओं को छोटे-छोटे शब्दों में प्रस्तुत करने में समर्थ हुए, जैसे-उपर्युक्त संख्या

प्रश्नः 1.
पटना शहर के प्राचीन नाम क्या-क्या थे?
उत्तरः
पटना शहर को पहले पाटलिपुत्र कहा जाता था। यहाँ फूल बहुत अधिक होते थे, अतः इसका नाम कुसुमपुर भी था।

प्रश्नः 2.
प्राचीन काल में पाटलिपुत्र नगर की प्रसिद्धि के क्या कारण थे?
उत्तरः
प्राचीन काल में पाटलिपुत्र नगर नंद, मौर्य और गुप्त सम्राटों की राजधानी रहा था। वह बहुत बड़ा नगर था। राजधानी होने के कारण देशभर के प्रतिष्ठित पंडित यहाँ एकत्र होते थे। प्रसिद्ध नालंदा विश्वविद्यालय भी पटना के समीप ही था।

प्रश्नः 3.
गंगा, सोन और गंडक नदियों के संगम पर लोग क्यों इकट्ठे हुए थे?
उत्तरः
उस दिन अपराहन में सूर्यग्रहण पड़ने वाला था। ग्रहण के अवसर पर नदियों के संगम और ऐसे ही स्थानों पर स्नान करने की मान्यता रही है। इसलिए लोग उन नदियों के संगम पर इकट्ठे हो रहे थे, ताकि ग्रहण के अवसर पर वे वहाँ स्नान कर सकें।

प्रश्नः 4.
लोगों में सूर्यग्रहण के बारे में क्या धारणा थी?
उत्तरः
लोगों में सूर्यग्रहण के बारे यह धारणा थी कि राहु नाम का राक्षस सूर्य को निगल जाता है, तब ग्रहण लगता है। ग्रहण के समय उपवास रखना चाहिए, खूब दान-पुण्य करना चाहिए, तभी इस राक्षस के चंगुल से सूर्य देवता को जल्दी-से-जल्दी मुक्ति मिलती है।

प्रश्नः 5.
पाटलिपुत्र नगर से दूर टीले पर स्थित आश्रम की क्या विशेषता थी?
उत्तरः
पाटलिपुत्र नगर से थोड़ी दूर टीले पर स्थित आश्रम में भी बड़ी चहल-पहल थी। लेकिन वह चहल-पहल कुछ दूसरे प्रकार की थी। यह आश्रम एक वेधशाला थी। टीले पर बसे उस आश्रम के लंबे-चौड़े आँगन में ताँबे, पीतल और लकड़ी के तरह-तरह के यंत्र रखे हुए थे। उनमें से कुछ यंत्र गोल थे, कुछ कटोरे जैसे, कुछ वर्तुलाकार और कुछ शंकु की तरह के थे। यहाँ ज्योतिष अपना अनुमान लगाते हैं।

प्रश्नः 6.
आश्रम की वेधशाला में ज्योतिषी और विद्यार्थी क्यों एकत्र हुए थे?
उत्तरः
आश्रम की वेधशाला में उस दिन यंत्रों के इर्द-गिर्द कई प्रसिद्ध ज्योतिषी और बहुत-से विद्यार्थी एकत्र हुए थे। वहाँ के ज्योतिषियों ने हिसाब लगाकर पहले ही भविष्यवाणी की थी कि ठीक किस समय ग्रहण लगेगा, कहाँ-कहाँ दिखाई देगा और कितने समय तक रहेगा। आज उन्हें देखना था कि उनका हिसाब ठीक निकलता है या नहीं। इसीलिए वहाँ ज्योतिषी और विद्यार्थी एकत्र हुए थे।

प्रश्नः 7.
आर्यभट ने सूर्य और चंद्रग्रहण की क्या वैज्ञानिक व्याख्या प्रस्तुत की?
उत्तरः
आर्यभट ने अपनी वैज्ञानिक व्याख्या प्रस्तुत करते हुए कहा, “पृथ्वी की बड़ी छाया जब चंद्र पर पड़ती है, तो चंद्र ग्रहण होता है। इसी प्रकार चंद्र जब पृथ्वी और सूर्य के बीच में आता है और वह सूर्य को ढक लेता है, तब सूर्यग्रहण होता है। कोई राहु नाम का राक्षस सूर्य को निगल जाता है-यह कथन पुराण की कथा है।”

परियोजना कार्य-3

कुलू प्राचीन हिंदू-सभ्यता का गहवारा है। यहाँ प्रत्येक कस्बे और ग्राम के अपने-अपने देवता हैं, जो अपने-अपने मंदिरों में बैठे हुए लोगों की पूजा पाते हैं और साल में एक बार अपने-अपने रथों में बैठकर कुलू के रघुनाथ मंदिर में प्रतिष्ठित राम की उपासना के लिए जाते हैं। सैकड़ों देवी-देवताओं और उनके मंदिरों के कारण और इस विराट देव-सम्मेलन के कारण ही, कुलू प्रदेश का नाम देवताओं का अंचल (वैली ऑफ दि गॉड्स) पड़ा है। ये सब असंख्य देवी-देवता और ऋषि-मुनि यहाँ के आदिम निवासियों द्वारा पूजे जाते थे।

यहाँ पर दशहरे के दिन विजयी राम का उत्सव होता है, जिसमे आसपास के सब देवी-देवता रथों में बिठाकर लाए जाते हैं। इस विराट उत्सव में, ऐसा सुनने में आता है, हज़ार-हज़ार तक देवता शामिल होते हैं। कुलू-प्रांत में व्यास-कुंड तथा व्यास मुनि, वसिष्ठ आदि ऋषि-मुनियों के स्थान हैं, पांडवों के मंदिर हैं, भीम की पत्नी हिडिंबा ‘देवी’ भी पूजा पाती है; और सबसे बढ़कर महत्त्वपूर्ण बात यह है कि वहाँ पर ‘मनु रिखि’ या मनु भगवान का भी एक मंदिर है।

शायद भारत में एकमात्र स्थान है, जहाँ मानवता का यह स्वयंभू आदिम प्रवर्तक मंदिर में प्रतिष्ठित हो और पूजा पाता हो। दशहरे के अवसर पर यहाँ बड़ा भारी मेला भी लगता है। साल भर का व्यापार प्रायः इस एक दिन में ही हो जाता है-बाहर से आए हुए यात्रियों के लिए बनी हुई देशी-अंग्रेज़ी दुकानों और कुछ होटलों या पंसवारी-हाट की बात अलग है इसलिए यहाँ पर ग्राहक और विक्रेता दोनों ही बड़ी उमंगें लेकर आते हैं।

रंग-बिरंगे कंबल, पट्ट-पट्टियाँ, पश्मीना, ‘चरू’ और अन्य प्रकार की खालें – रीछ की, मृग की, बाघ की, कभी-कभी बर्फ के बाघ (स्नो-लेपर्ड) की; तरह-तरह के जूते, मोज़े, सिली-सिलाई पोशाकें, टोपियाँ, बाँसुरी, बरतन, पीतल और चाँदी के आभूषण, लकड़ी, हड्डी और सींग की कंघियाँ, देशी और विदेशी काँच, बिल्लौर और पत्थर के मनकों के हार-न जाने क्या-क्या चीजें वहाँ आती हैं और देखते-देखते बिक जाती हैं – दिन-भर में हज़ारों की संपत्ति हाथ बदल लेती है… तमाशे होते हैं, नाच होते हैं, गाना-बजाना होता है, जगमग रोशनी होती है।

उस दिन कुलू में दो घंटे ठहरे। भोजन किया और फिर लारी में बैठकर आगे बढ़े। मनाली देवताओं के अंचल का ऊपरी छोर-कुलू 23 मील है। अध-बीच में कटराई की बस्ती है। कटराई से चलकर मोटर कलाथ होती हुई मनाली जा पहुँची। मनाली या मुनाली ने यह नाम मुनाल नामक पक्षी से पाया, जो यहाँ बहुतायत से होता है। फेजेंट जाति का हिमालय का यह पक्षी अत्यंत सुंदर होता है। इसके संबंध में यहाँ के लोगों में कई किंवदंतियाँ भी सुनने में आती हैं, लेकिन मैदानी भाग में रहने वाले लोग मनाली को वहाँ के सेबों के कारण ही जानते हैं।

सेब और नाशपाती के लिए मनाली शायद संसार में बढ़िया स्थान है। मनाली की दो बस्तियाँ हैं – एक तो बाहर से आकर बसे लोगों द्वारा बनाए हुए बँगलों और बाज़ार वाली बस्ती, जो दाना कह और दूसरी उससे करीब मील-भर ऊपर चलकर खास मनाली मोटर दाना तक जाती है। दाना से सड़क फिर व्यास नदी पर रोहतांग की जोत से होकर लाहौल को चली जाती है। इसी मार्ग में से दो मील की दूरी पर वसिष्ठ नाम का गाँव है, जहाँ गरम पानी है और वसिष्ठ मंदिर भी है। कहते हैं कि वसिष्ठ ऋषि यज्ञ करते-करते पाषाण हो गए थे; पाषाण मूर्ति वहाँ पूजी भी जाती है।

यहाँ पानी में गंधक की मात्रा काफ़ी है, और यह स्वास्थ्य के लिए अच्छा है। रोहतांग की जोत पर ही व्यास-कुंड है। यहाँ से कुछ मील हटकर मुनि का स्थान है, जहाँ से व्यास नदी का उद्गम है। रोहतांग का यह स्थान रमणीक है। व्यास नदी के वेग से किस तरह पहाड़ के पहाड़ को वह भी देखने की चीज़ है। कहीं-कहीं तो नदी आठदस फुट में चार-पाँच सौ फुट नीचे जाकर अदृश्य हो गई है, केवल स्वर सुरक्षित है। इसका कारण यह है कि व्यास नदी बहुत तीव्र गति से नीचे गिरती है-अपने मार्ग के पहले पाँच मील में जितना नीचे उतर आती है, अगले पचास मील में नहीं, और उसके बाद में पाँच सौ मील में।

रोहतांग की जोत के दूसरी पार कोकसर पड़ाव है। यहाँ जाते हुए बर्फ के सौंदर्य का जो दृश्य दीखता है, मैंने दूसरा नहीं देखा। उसका न वर्णन हो सकता है, न चित्र खिंच सकता है। कुछ मीलों के दायरे का एक प्याला-सा बना हुआ है, जिसके सब ओर ऊँचीऊँची हिमावृत चोटियाँ, उससे कुछ नीचे पहाड़ों के नंगे काले अंग, और प्याले के बीच में फिर बरफ़ से छाया हुआ मैदान – मानो अभिमानी पर्वत-सरदारों ने अपना शीश और कटि-प्रदेश तो ढक लिया है। लेकिन छाती दर्प से खोल रही है…।

इस स्थान से तीन नदियों का उद्गम है, ऊपर से व्यास, मध्य से चंद्रा और भागा, जो आगे चलकर मिल जाती है। दाना के दूसरी ओर पहाड़ के ढलान पर चीड़ के जंगल में हिडिंबा देवी का मंदिर है। एक चीड़ वृक्ष के तने के आसपास बना हुआ यह लकड़ी का चार-मंजिला मंदिर दर्शनीय है। इसके द्वारों पर नक्काशी का जो काम है, वह कई सौ बरस पुराना है। एक पट्टे पर लेख भी खुदा हुआ है। मंदिर से मनाली की ओर जाते हुए मार्ग दो चट्टानों के बीच होकर गुजरता है, जो अपने आकार के कारण ‘देवी का चूल्हा’ प्रसिद्ध है।

कहते हैं कि हिडिंबा देवी मनुष्य भून-भूनकर तैयार करती थी। मनाली की बस्ती के ऊपरी छोर पर मनु रिखि छोटा है, विशेष सुंदर भी नहीं है। लेकिन मनु का एकमात्र मंदिर होने के कारण विशेष महत्त्व रखता है। मैं मनाली आया तो था स्वास्थ्य-लाभ करने, लेकिन आकांक्षा यह थी कि एकांत में रहकर एक बड़ा-सा उपन्यास लिख डालूँगा। जेल में रहते हुए उसका ढाँचा तैयार हुआ था, अंग्रेज़ी में पूरा लिख भी डाला था; लेकिन जेल के चार वर्ष ने दिखा दिया था कि उसमें अभी लड़कपन बहुत है।

एक बार मैंने एक विद्रोही के पूरे जीवन का चित्र खींचने की कोशिश की और जहाँ तक चित्र का संबंध था वह काफ़ी सच्चा उतरा था। भूमि पर वह खींचा गया था-भारतीय समाज और संस्कृति का ज्ञान मेरा अधूरा ही था और इसलिए चित्र ठीक नहीं था। अब के आधार पर परिवर्तन और परिष्कार करके मैं उसे फिर खींचना चाहता था। उपन्यास को मैं जीवन-दर्शन मानता हूँ और इस दृश्य चीज़ को लिखने के लिए एकांत ज़रूरी था। तभी मैं ‘परिचित सभी बस्ती से अलग मनाली में आ जमा था। मनाली स्थिति के कारण ही नहीं, सौंदर्य के कारण भी अंचल का सुनहला ऊपरी छोर है। दृष्टि-क्षेत्र में सींखचे-ही-सींखचे की आदी मेरी आँखें इस विराट सौंदर्य को पीती जाती थीं और स्वयं पर विश्वास नहीं कर पाती थीं।

प्रश्नः 1.
लारी चार मील की रफ्तार से तेज़ न चले, इसके लिए वहाँ क्या प्रबंध किया गया था?
उत्तरः
लारी चार मील की रफ़्तार से तेज़ न चले, इसके लिए वहाँ यह प्रबंध किया गया था कि पुल का चौकीदार अपनी पीठ पर एक तख्ती टाँगे आगे-आगे चलता था। उस तख्ती पर लिखा था-चार मील रफ़्तार। इस आदमी के पीछे-पीछे इसी की चाल से चलो।’ उस चौकीदार के पीछे लारी चलती थी।

प्रश्नः 2.
मणिकर्ण के गरम पानी के स्रोतों की क्या विशेषता है?
उत्तरः
मणिकर्ण में गरम पानी के कई स्रोत हैं। इन स्रोतों की विशेषता यह है कि हर स्रोत के पानी की उष्णता में अंतर है। किसी का पानी इतना गरम है कि उसमें नहाया जा सकता है तो किसी का इतना गरम कि उसमें चावल तक उबाले जा सकते है।

प्रश्नः 3.
कुलू प्रांत में कौन-कौन से दर्शनीय स्थान हैं?
उत्तरः
कुलू प्रांत में व्यास कुंड तथा व्यास मुनि, वसिष्ठ आदि ऋषि-मुनियों के स्थान हैं। पांडवों के मंदिर भी हैं। वहाँ भीम की पत्नी हिडिंबा देवी की भी पूजा होती है। सबसे महत्त्वपूर्ण बात तो यह है कि वहाँ मनु ऋषि यानी मनु भगवान का भी एक मंदिर है। कुलू प्रांत में ये सब स्थान दर्शनीय हैं।

प्रश्नः 4.
दशहरे के उत्सव को विराट उत्सव क्यों कहा गया है?
उत्तरः
कुलू में प्रत्येक गाँव और कस्बे के अपने-अपने देवता हैं। दशहरे के अवसर पर ये देवता अपने-अपने रथों में बैठकर कुलू के रघुनाथ मंदिर में प्रतिष्ठित राम की उपासना के लिए आते हैं। यहाँ पर दशहरे के दिन विजयी राम का उत्सव होता है, जिसमें आसपास के सब देवी-देवता रथों में बिठाकर लाए जाते हैं। इस विराट उत्सव में ऐसा सुनने में आता है, हजारों हज़ार तक देवता शामिल होते हैं। इसीलिए दशहरे के उत्सव को विराट उत्सव कहा जाता है।

प्रश्नः 5.
मनु का मानवता का स्वयंभू आदिम प्रवर्तक क्यों कहा गया है?
उत्तरः
स्वयंभू का अर्थ है जो अपने आप बना हो। ऐसी मान्यता है कि मनु से मानव उत्पन्न हुए हैं। इसीलिए मनु को स्वयंभू कहा गया हैं अर्थात् मनु स्वयं ही मानवता के आदिम प्रवर्तक बन गए।

प्रश्नः 6.
लेखक ने मनाली के नामकरण के पीछे क्या कारण बताया है?
उत्तरः
लेखक ने बताया है कि मनाली में मुनाल नामक पक्षी बहुतायत से होता है। फेजेंट जाति का हिमालय का यह पक्षी अत्यंत सुंदर होता है। इसके संबंध में यहाँ के लोगों में कई किंवदंतियाँ भी सुनने में आती हैं। लेखक के अनुसार इस पक्षी के कारण ही इस स्थान का नाम मनाली पड़ा है।

प्रश्नः 7.
कुलू में दशहरे का उत्सव किस प्रकार मनाया जाता है?
उत्तरः
कुलू में प्रत्येक गाँव और कस्बे के अपने-अपने देवता हैं जो अपने-अपने मंदिरों में बैठे हुए लोगों की पूजा पाते हैं। ये ही देवता साल में एक बार दशहरे के अवसर पर कुलू स्थित रघुनाथ मंदिर में प्रतिष्ठित भगवान राम की उपासना के लिए अपने-अपने रथों पर बैठकर कुलू जाते हैं। ये सब असंख्य देवी-देवता दशहरे के दिन कुलू में एकत्रित होते हैं। यहाँ पर तमाशे होते हैं, नाच होते हैं और जगमग रोशनी होती है।

परियोजना कार्य-4

लेखक ने चंद्रा के विषय में बताया है। सबसे पहले चंद्रा को देखकर उसे बहुत आश्चर्य हुआ था। लेखिका ने अपनी कोठी के सामने वाली कोठी के आंगन में एक बार देखा कि एक कार आकर रुकी और उसमें से एक अपाहिज युवती, बिना किसी दूसरे की सहायता से बैसाखियों के सहारे नीचे उतरी। स्वयं ही उसने कार में से पहियों वाली कुरसी बाहर निकाली तथा उस पर बैठकर, उसे अपने हाथों से सरकाती हुई अंदर चली गई। उस युवती का नाम चंद्रा था। उसका निचला धड़ एकदम बेकार हो चुका था।

केवल हंसमुख चेहरा और दोनों हाथ सही थे। फिर भी, उसने बड़ी हिम्मत और उमंग से अपनी जीवनचर्या चलाई। उसके मन में कभी अपने अपाहिज होने की उदासी या चिंता नहीं आने पाई। उसने विधाता या भाग्य को दोष नहीं दिया, बल्कि निरंतर अध्ययन तथा परिश्रम के बल पर विज्ञान जैसे कठिन विषय में उसने पी.एच.डी. करके एक आदर्श उदाहरण लोगों के सामने प्रस्तुत किया। इसीलिए लेखिका चाहती है कि इस साहसी युवती डॉक्टर चंद्रा की कहानी अन्य ऐसे लोग भी पढ़ें जो जीवन में जरा-सी मुसीबत आते ही निराश होकर आत्महत्या कर लेना चाहते हैं।

ऐसे दुर्बल युवकों में एक लखनऊ का युवक था, जो बहुत सुंदर और बुद्धिमान था। एक बार वह आई.ए.एस. (भारतीय प्रशासनिक परीक्षा) की परीक्षा देकर इलाहाबाद से रेल द्वारा लौट रहा था, तो मार्ग में किसी स्टेशन पर गाड़ी रुकने पर चाय लेने के लिए उतरा। अचानक गाड़ी चल पड़ी। चलती गाड़ी में चढ़ने की कोशिश करते हुए वह गिर पड़ा और उसका हाथ गाड़ी के पहिए के नीचे आने से कट गया। इस दुर्घटना से वह पागल-सा हो गया। पहले वह नशे की गोलियाँ खाने लगा और फिर वेश्याओं के पास जाने लगा।

लेखिका को आश्चर्य है कि उस बांके युवक ने केवल एक हाथ कट जाने से अपना जीवन बर्बादी के रास्ते पर डाल दिया। दूसरी ओर यह युवती चंद्रा है, जिसके शरीर का सारा निचला भाग एक बेजान माँस का टुकड़ा भर है, फिर भी वह निराश नहीं है। उसके चेहरे पर दुख या चिंता का कोई चिह्न नहीं है। आम लोगों की कोई एक हड्डी भी टूट जाए या पैर में ज़रा मोच आ जाए, तो वे हाहाकार से आकाश सिर पर उठा लेते हैं, किंतु चंद्रा का सारा निचला धड़ सुन्न हो जाने पर भी उसमें पढ़ने का जोश है, ऊँची नौकरी पाने की महान् आकांक्षा और लगन है।

चंद्रा जब केवल डेढ़ वर्ष की थी, तभी पोलियो के कारण उसका शरीर सुन्न-सा हो गया था। हल्का-सा ज्वर हुआ और चौथे दिन अचानक लकवे के कारण गरदन के नीचे का सारा शरीर निर्जीव-सा हो गया। बड़े-बड़े डॉक्टरों को दिखाने पर यही जवाब मिला कि रुपया बरबाद करना बेकार है, इसका कोई इलाज नहीं। किंतु चंद्रा की माँ श्रीमती सुब्रह्मण्यम् ने हिम्मत नहीं हारी। न ही उसने विधाता को कोई दोष किया। उसने अपनी नन्ही बच्ची चंद्रा को जीवित रखने के लिए कोई कसर नहीं छोड़ी।

एक डॉक्टर से सालभर इलाज कराने के बाद ऊपरी धड़ अर्थात् सिर, मुख, आँख, कान, नाक, हाथ में तो चेतना आ गई, परन्तु निचले भाग में जड़ता बनी रही। माँ ने उसे धीरे-धीरे बोलना और बैठना सिखाया। पाँच वर्ष की आयु में उसे माँ पढ़ाने लगी। बालिका चंद्रा की बुद्धि इतनी तीव्र थी कि वह बहुत जल्दी सब कुछ सीख लेती थी। अंग्रेज़ी शिक्षा वाले अच्छे स्कूल की प्रिंसिपल ने उसे प्रवेश देने में जब मज़बूरी प्रकट की, तो माँ ने एक प्रकार से स्कूल के द्वार पर सत्याग्रह कर दिया।

आखिर स्कूल की मदर मान गई। बालिका चंद्रा को पहियों वाली कुरसी पर बिठाकर उसकी माँ स्कूल ले जाती, हर कक्षा में उसके साथ रहती। दिनभर वह चंद्रा के संग-संग रहकर उसकी शिक्षा में सहायता करती रही। धीरे-धीरे चंद्रा ने अनेक परीक्षाएँ पास की। हर बार सर्वोच्च अंक प्राप्त किए। कई स्वर्ण पदक जीते। अंत में बी.एस.सी. के लिए भी स्थान प्राप्त कर लिया। तब तक उसके माता-पिता ने पेंसिलवानिया से एक ऐसी पहियों वाली कुरसी मंगवा दी, जिसे चंद्रा स्वयं चलाकर जहाँ चाहे, जा सकती थी।

उसके निचले धड़ पर हर समय चमड़े की एक पेटी, धड़ को सीधा रखने के लिए रहती थी और वह स्वस्थ व्यक्तियों से भी अधिक फुर्ती से, अपने हाथों से सब काम करती रहती थी। इस तरह माँ की अचल साधना तथा अपनी अद्भुत प्रतिभा और मेहनत से चंद्रा ने विज्ञान जैसे विषय में डॉक्टर की उपाधि प्राप्त कर ली। विज्ञान के अतिरिक्त चंद्रा की भाषा, साहित्य और समाज-सेवा में भी बड़ी रुचि थी उसकी अपनी लिखी कविताएँ पढ़कर लेखिका विस्मित हो गई थी।

उन कविताओं के अंत:करण के करुण भाव मानो साकार हो उठे थे। इसी प्रकार उसने माँ के साथ मैक्समूलर भवन से जर्मन भाषा में विशेष योग्यता प्राप्त की। इसके अतिरिक्त ‘गर्लगाइड’ की सदस्य बनकर भी उसने राष्ट्रपति से पदक प्राप्त किया। इतना ही नहीं, भारतीय और पाश्चात्य संगी में भी उसकी विशेष रुचि थी। इतनी व्यस्त रहते हुए भी वह कढ़ाई-बुनाई के लिए समय निकाल लेती थी। उसकी कढ़ाई-बुनाई के नमूने देखकर लेखिका के आश्चर्य की सीमा न रही।

निश्चय ही चंद्रा की इस उन्नति, महानता और प्रशंसा में उसकी माँ का विशेष योगदान था। इसीलिए जे.सी. बेंगलूर द्वारा उन्हें ‘वीर जननी’ का विशेष सम्मान प्रदान किया गया। चंद्रा की माँ श्रीमती सुब्रह्मण्यम् का यह कथन लेखिका को कभी नहीं भूलता-“ईश्वर सब द्वार एक साथ बंद नहीं करता। वह एक द्वार बंद करता भी है, तो दूसरा द्वार खोल भी देता है।”

प्रश्नः 1.
लेखिका ने जब पहली बार डॉ० चंद्रा को कार से उतरते देखा तो आश्चर्य से क्यों देखती रह गई ?
उत्तरः
लेखिका ने जब पहली बार डॉ० चंद्रा को कार से उतरते देखा तो वह आश्चर्य से देखती ही रह गई। इसका कारण यह था कि डॉ० चंद्रा का निचला धड़ पूरी तरह निष्प्राण था। इसके बावजूद वह बड़ी दक्षता के साथ बिना किसी सहारे के कार से उतरी और बैसाखियों से ही व्हील चेयर तक पहुँचकर उसमें बैठ गई। फिर बड़ी तटस्थता से उसे स्वयं चलाती कोठी के भीतर तक चली गई। उसका यह विचित्र आवागमन ही लेखिका के आश्चर्य का कारण था।

प्रश्नः 2.
‘अभिशप्त काया’ से लेखिका का क्या आशय है?
उत्तरः
अभिशप्त काया का अर्थ है-शापग्रस्त शरीर। डॉ० चंद्रा का शरीर किसी सामान्य व्यक्ति के शरीर की भाँति नहीं था। उसका निचला धड़ पूरी तरह से निश्चल और निष्प्राण था। ऐसा किसी शाप के कारण ही संभव है। इसीलिए लेखिका ने उसके लिए अभिशप्त काया का प्रयोग किया है।

प्रश्नः 3.
चिकित्सा क्षेत्र की हानि विज्ञान का लाभ कैसे बन गई?
उत्तरः
डॉ० चंद्रा चिकित्सा के क्षेत्र में जाना चाहती थी। परीक्षा-परिणाम में उन्हें सर्वोच्च स्थान प्राप्त हुआ था, किंतु उनकी विकलांगता के कारण उसे चिकित्सा-क्षेत्र में प्रवेश नहीं मिला। इसके बाद डॉ० चंद्रा ने विज्ञान विषय लिया और माइक्रोबायलोजी में शोध कार्य किया। उन्हें डॉक्टरेट की उपाधि प्राप्त हुई। इस प्रकार डॉ० चंद्रा की अद्भुत प्रतिभा से चिकित्सा क्षेत्र वंचित रहा और विज्ञान को उसका लाभ हुआ।

प्रश्नः 4.
‘मैडम मैं चाहती हूँ मुझे सामान्य-सा सहारा भी न दे।’ इस कथन से डॉ० चंद्रा के चरित्र की कौन-सी विशेषता उभरती है?
उत्तरः
उक्त कथन से डॉ० चंद्रा के आत्मविश्वास और आत्मसम्मान की भावना का पता चलता है।

प्रश्नः 5.
डॉ० चंद्रा की कविताएँ देखकर लेखिका की आँखें क्यों भर आईं ?
उत्तरः
लेखिका डॉ० चंद्रा ने अपनी कविताएँ दिखाई उनकी कविताओं को लेखिका ने बड़े ध्यान से देखा। जो पीडा कभी डॉ० चंद्रा के चेहरे पर नहीं आई थी वह उसकी कविताओं में आई थी। यही कारण था कि डॉ० चंद्रा की कविताएँ देखकर लेखिका की आँखें भर आईं।

प्रश्नः 6.
हमें कब अपने जीवन की रिक्तता बहुत छोटी लगने लगती है?
उत्तरः
सामान्यतः व्यक्ति अपने जीवन के अभाव के लिए विधाता को दोष दिया करते हैं। दूसरी ओर ऐसे व्यक्ति भी होते हैं जिनके जीवन में अभाव ही अभाव होते हैं, परंतु वे किसी से कोई शिकायत नहीं करते। जब कभी ईश्वर हमें किसी ऐसे व्यक्ति से मिला देता है जिसके अभाव और रिक्तताएँ हमारी रिक्तताओं से कहीं अधिक हैं, तो हमें अपने जीवन की रिक्तता बहुत छोटी लगने लगती है।

प्रश्नः 7.
लेखिका यह क्यों चाहती थी कि लखनऊ का युवक डॉ० चंद्रा के संबंध में लिखी उनकी पंक्तियों को पढ़े?
उत्तरः
लखनऊ का युवक एक दुर्घटना में अपना दायाँ हाथ खो बैठा था। वह इस दुख को सहन नहीं कर पाया और नशे का शिकार हो गया व बाद में चारित्रिक पतन का भी शिकार हो गया। उधर डॉ० चंद्रा अपने पूरे निचले धड़ के निष्प्राण होने पर भी उत्साह और जिजीविषा से भरी थी। लेखिका चाहती थी कि वह युवक डॉ० चंद्रा के बारे में उसकी लिखी गई पंक्तियों को पढकर अपनी हताशा का परित्याग करे और उत्साह के साथ जीवन-पथ पर आगे पढे।

परियोजना कार्य-5

यह कथा बालक नचिकेता के माध्यम से एक ऐसा चरित्र प्रस्तुत करती है जिसमें अटूट, सत्य-निष्ठा, दृढ़ पितृ-भक्ति के साथ-साथ अनुचित कार्य करने पर पिता का विरोध करने का और आत्म-ज्ञान की प्राप्ति के लिए सांसारिक सुखों के प्रलोभनों को ठुकरा देने का साहस भी है। यज्ञ की अग्नि प्रज्ज्वलित थी। सारे वातावरण में सुगंध व्याप्त थी। वाजश्रवा के चेहरे पर विशेष प्रसन्नता झलक रही थी। उसके द्वारा आयोजित यज्ञ की आज पूर्णाहुति थी। देशभर के बड़े-बड़े विद्वान और ऋषि-मुनि पधारे थे। यज्ञ समाप्त हुआ।

ब्राह्मणों ने वाजवा को आशीर्वाद दिया और वाजश्रवा ने उन्हें दक्षिणा देना प्रारंभ किया। किंतु ऐसी निर्बल और बूढ़ी गाएँ देने लगा जिन्होंने दूध देना ही बंद कर दिया था। लोग दबी ज़बान से वाजश्रवा की आलोचना कर रहे हैं, किंतु सबसे अधिक दुखी कोने में बैठा वह किशोर बालक है। खिन्न मन से वह उनके पास गया और बोला, “पिता जी, दक्षिणा में तो यजमान अपनी प्रिय-से-प्रिय वस्तु देते हैं। आपने तो ऐसी गाएँ दी हैं, जिनका आपके लिए कोई उपयोग ही नहीं रह गया है।

इससे आपको पुण्य नहीं मिलेगा।” फिर कुछ रुककर बोला, “पिता जी, आपको सबसे प्रिय तो मैं हूँ, आप मुझे ही किसी को दक्षिणा में क्यों नहीं दे देते?” वह बार-बार पूछता, “आप मुझे किसको दक्षिणा में दे रहे हैं?” वाजश्रवा झुंझला उठे। बच्चे के हठ से क्रुद्ध होकर वे बोले, “जा, मैंने तुझे मृत्यु को दिया।” नचिकेता ने मृत्यु के देवता यमराज के पास जाने की अनुमति माँगी। वाजश्रवा को अपनी गलती का अहसास हुआ, किंतु अब उपाय ही क्या था? नचिकेता अपने पिता और अन्य सभी संबंधियों से विदा लेकर यमराज के घर चल दिया।

यमराज उस समय यमपुरी में नहीं थे। तीन दिन तक वह किशोर भूखा-प्यासा उनके दरवाजे पर पड़ा रहा। यमराज लौटे तो एक ब्राह्मण कुमार को अपने घर इस दशा में देखकर बहुत दुखी हुए। उसके मुख पर तेज था और चेहरे पर दृढ़ता झलक रही थी। यमराज ने नचिकेता का यथोचित सत्कार कर उसके आने का प्रयोजन पूछा। नचिकेता ने अपने पिता के यज्ञ की सारी कथा सुनाकर आने का कारण बताया। यमराज बोले, “नचिकेता, तुम्हारी पितृ-भक्ति और दृढ़ निश्चय से मैं बहुत प्रसन्न हूँ।

साथ ही मुझे इस बात का बहुत दुख है कि तुम्हें तीन दिन मेरे दरवाज़े पर भूखा-प्यासा रहना पड़ा। इसका प्रायश्चित करने के लिए मैं तुम्हें तीन वर देना चाहता हूँ।”

  1. उसके पिता जी क्रोध छोड़कर, उसे पहले के समान प्यार करने लगे।
  2. उसे स्वर्ग प्राप्त करने का उपाय बताया जाए।
  3. उसे आत्मा का रहस्य समझाया जाए।

उसकी बात सुनकर यमराज और भी प्रसन्न हुए क्योंकि नचिकेता ने धन-संपत्ति या राज्य न माँगकर आत्म-ज्ञान माँगा था। यमराज ने उसे समझाया कि आत्म-ज्ञान ही सच्चा ज्ञान है। हमारा शरीर रथ है। इंद्रियाँ उस रथ के घोड़े हैं। मन लगाम और बुद्धि रथवान है। आत्मा उसमें सफर करने वाले यात्री के समान है। हे पुत्र! उठो, जागो और श्रेष्ठ ज्ञान प्राप्त करो। इस प्रकार यमराज ने उसकी इच्छा पूरी की। वह यमराज से स्वर्ग को प्राप्त करने का उपाय तथा आत्मा का रहस्य जानकर, वरदान के अनुसार वापस धरती पर आ गया। बाद में वह यमराज के उपदेशों का पालन करते हुए एक विद्वान और धर्मात्मा ऋषि के रूप में प्रसिद्ध हुआ।

प्रश्नः 1.
यज्ञ की समाप्ति पर वाजश्रवा को किस मोह ने घेर लिया था?
उत्तरः
यज्ञ की समाप्ति पर वाजश्रवा के मन संपत्ति के मोह का भाव जाग गया। उसने अपनी पूरी संपत्ति दान में देने का निश्चय किया था, परंतु वह बूढ़ी और अशक्त गायों का दान कर रहा था। कारण यह था कि उसके मन को संपत्ति के मोह ने घेर लिया था।

प्रश्नः 2.
नचिकेता अपने पिता के किस व्यवहार के कारण दखी हो गया था?
उत्तरः
नचिकेता के पिता निर्बल बूढी व दूध न देने वाली गाय दान कर रहे थे। उसे यह कपटतापूर्ण व्यवहार अच्छा नहीं लग रहा था। लोग उसके पिता की आलोचना कर रहे थे। स्वयं उसे भी अपने पिता द्वारा बूढी गायों को दान में देना अनुचित लग रहा था। इसीलिए वह दुखी हो गया था।

प्रश्नः 3.
नचिकेता के अनुसार दक्षिणा का क्या रूप होना चाहिए?
उत्तरः
नचिकेता के अनुसार दक्षिणा में यजमान को अपनी प्रिय-से-प्रिय वस्तु दान में देनी चाहिए। निरर्थक और अनुपयोगी वस्तुओं को दान में देने से दानकर्ता को कोई पुण्य प्राप्त नहीं होता।

प्रश्नः 4.
नचिकेता की दृष्टि में कौन-सी वस्तु पृथ्वी और स्वर्ग के सुख से भी बढ़कर थी?
उत्तरः
नचिकेता की दृष्टि में एक वस्तु ऐसी है जो पृथ्वी और स्वर्ग के सुख से भी बढ़कर है। वह वस्तु है हमारी आत्मा। आत्मा का सच्चा स्वरूप क्या है?

प्रश्नः 5.
वाजश्रवा नचिकेता को मृत्यु को देने की बात को वापस क्यों न ले सका?
उत्तरः
नचिकेता बार-बार अपने पिता से प्रश्नः कर रहा था कि आप मुझे किसे दक्षिणा में दे रहे हैं परंतु वे व्यस्त थे और बालक के इस प्रश्नः पर वे झुंझाला उठे। उन्होंने क्रोध में आकर कह दिया कि ‘जा मैंने मुझे मृत्यु को दिया।’ भूल से ही सही, एक बार जो बात कह दी, उसे वापस लेना संभव नहीं था। धनुष से छूटा तीर वापस नहीं लौटाया जा सकता। अतः वे नचिकेता के मृत्यु को देने की बात को वापस न ले सके।

प्रश्नः 6.
यमराज को किस बात का दुख हुआ और उन्होंने उसके लिए प्रायश्चित क्यों किया?
उत्तरः
जब नचिकेता यमराज के घर पहुँचा उस समय यमराज वहाँ पर नहीं थे। नचिकेता को तीन दिन तक भूखे-प्यासे उनकी प्रतीक्षा करनी पड़ी। जब यमराज आए तो एक ब्राह्मण किशोर को अपने घर इस दशा में देखकर बहुत दुखी हुए। उन्होंने नचिकेता से कहा, “मुझे इस बात का बहुत दुःख है कि तुम्हें तीन दिन मेरे दरवाज़े पर भूखा-प्यासा रहना पड़ा। इसका प्रायश्चित करने के लिए मैं तुम्हें तीन वर देना चाहता हूँ।”

प्रश्नः 7.
नचिकेता ने यमराज से कौन-से तीन वर माँगे?
उत्तरः
नचिकेता ने यमराज से निम्नलिखित तीन वर माँगे

  1. “मेरे पिता जी का मुझ पर क्रोध शांत हो जाए और जब मैं आपके पास से वापस जाऊँ, तो वे मुझे पहचान लें और प्यार से बोलें।”
  2. “लोग कहते हैं कि स्वर्गलोक में बहुत सुख मिलता है। न वहाँ भूख-प्यास की चिंता है, न बुढ़ापा है, न कोई रोग। वहाँ के निवासी हर समय अलौकिक सुख का ही उपभोग करते हैं, वहाँ आपका पाश भी नहीं पहुँचता और न लोगों को किसी अन्य प्रकार का भय ही लगता है। उस आनंदपूर्ण स्वर्ग को किस प्रकार प्राप्त किया जा सकता है, मुझे इसका
    उपदेश कीजिए।”
  3. “कुछ लोग कहते हैं कि मृत्यु के बाद आत्मा रहती है, कुछ कहते हैं कि नहीं रहती। इस विषय में मेरा अज्ञान अंत तक दूर नहीं हुआ है। तीसरे वर के रूप में कृपा कर मुझे आत्मा का रहस्य समझाइए।”

अभ्यास प्रश्नः

परियोजना कार्य-1

शर्मा बहुत दिन बाद मिले और ऐसी जगह जहाँ आशा न थी-अपने प्रांत से दूर, बंगलूर में बहुत खुशी हुई, गले मिले और होटल गए। दुनिया भर की गप्पें लगीं। अरसा हो गया था उनसे चिट्ठी भी मिले। जाने क्या-क्या हो गया इस बीच? बहुत मिलनसार थे। बातूनी भी। जिंदगी में बड़ा तजुर्बा हासिल किया था। फिर चुप रहे भी तो कैसे? दस-पंद्रह साल पहले जब उनसे मिला था, तब वे एक छोटे-से अखबार में उप-संपादक थे उम्र तब तीसेक की रही होगी। अब चेहरा पटरीदार हो गया था। गुज़रते समय ने गहरे निशान छोड़े थे।

पता नहीं कि उनको कैसे सूचना मिल गई कि मैं शहर पहुंच रहा हूँ। वे स्टेशन आ गए “अरे, आप हमें चिट्ठी लिख देते मैं ” वे कहते-कहते इधर-उधर देखने लगे। “चिट्ठी तो तब लिखता न, जब आप अपना पता देते?” मैंने कहा। “हाँ, गलती मेरी ही है। मुझे केशवन मिल गए। न मिलते तो आपसे मिल ही न पाता आपने उनको लिखा था न? आप नहीं जान सकते कि मैंने कितनी बार आपको लिखने की चेष्टा की कितनी बार चिट्ठियाँ लिख-लिखाकर फाड़ीं थी, क्या लिखा? एक दुखड़ा हो तो रोऊँ भी?” “क्यों, क्या हो गया?” “कभी हम किस्से लिखते थे, लेकिन अब, खुद किस्सा हो गए।”

“घर में सब ठीक तो है न?” “ठीक ही है, अगर जिंदगी टेढ़ी लकीर पर ही चलती रहे तो वह भी सीधी लगने लगती है।” “हँस लेता हूँ, रो-रोकर यही सीखा है मुश्किलों पर हँसना बेहतर है।” “सोचा था, हमारी जिंदगी जो है, सो है। कम-से-कम बच्चों की जिंदगी तो बने और बन भी गई थी। लेकिन फलने का मौसम आया तो पेड़ पर ही बिजली गिर गई।” “वह ठीक तो है न?” “हाँ, ठीक ही होगा उस लोक में, जहाँ कहते हैं, हर मरा-मारा भी आराम पाता है, किंतु वहाँ से लौटकर किसी ने बताया नहीं कि कितना आराम है।”

वे फिर ज़ोर से हँसे। पागलों-जैसी हँसी गहरे दुख को छुपाने की बनावटी हँसी। मैं हँस नहीं पाया। मैंने सोचा कि वह क्षण आ गया है जिसकी आशंका थी। अब क्या करूँ? बैरे को बुलाने के लिए घंटी बजाई। शर्मा जी ने पूछा, “काफ़ी लेंगे?” “जी नहीं, खैर, आप पुराने मित्र हैं, हितैषी हैं, इसलिए मैं वे फिर हँसे, विवशता की हँसी। “अब भी इतना गया-गुज़रा नहीं कि अखबारों के काम भी न आ सकूँ। आप संपादक हैं। कुछ कर सकते हैं। सात-आठ साल की सज़ा काफ़ी होती है।” वे हँसे। “हाँ। हाँ, ज़रूर” मेरे कहने से सहृदयता कम थी, औपचारिकता अधिक।

“आप इतने दिन बाद मिले और हमारे ही शहर में।” “हाँ, बड़ी खुशी हुई।” “आज शाम हमारे यहाँ खाना रहा। आपको लेने आ जाऊँगा, गेरा घर स्टेशन के पास ही है। वहीं से आपको पहुँचा दूंगा। ठीक है न।” शर्मा चले गए। मैंने सोचा कि पिण्ड छूटा। दिन भर काम में मशगूल रहा। होटल पहुंचा, तो शर्मा प्रतीक्षा कर रहे थे। “आइए काफ़ी पिएँ, बहुत थके हुए दीखते हैं।” उन्होंने कहा। हमने काफ़ी ली। बिल शर्मा ने चुकाया। मुझे बुरा लगा। कमाऊ आदमी का बिल बेरोज़गार आदमी चुकाए।

यह न शालीनता थी, न शिष्टता ही। फिर जो आदमी एक-एक पैसा संभाल कर खर्चता है, तो बिना मतलब के नहीं। आखिर इनका उद्देश्य क्या है? मैं नहाने चला गया। शर्मा मेरी प्रतीक्षा करते रहे। होटल का बिल चुकाया। शर्मा ने ही गाड़ी का इंतज़ाम किया। वे मुझे अपने घर ले गए। घर क्या था एक अच्छे मोहल्ले में एक छोटा-सा कमरा। चारों ओर किताबें ही किताबें। फर्श पर घिसी हुई दरी। बीचों-बीच लालटेन रखी थी। “मैंने सब चीजें बेच दी पेट के लिए। घर नंगा कर दिया।

लेकिन किताबें नहीं बेच पाया। कैसे बेचता? यह भी ठीक ही है कि किताबें खरीदने वाला कोई नहीं है, नहीं तो एक और शाप लगता।”।”हूँ” मैं इधर-उधर देखने लगा। भोजन के न्यौते पर लाए हैं और यहाँ उनका लड़का नहीं है-कहीं होटल तो नहीं गया?” “दुनिया में बहुत बड़े-बड़े लोग हैं। पर आप जानते हैं, मेरे लिए सबसे बड़े कौन हैं ? एक हमारा दूधवाला, दूसरा किराने वाला। दोनों हमें बेझिझक उधार देते रहे। उस समय भी जब पुराने दोस्त तक मुँह मोड़ लेते थे कि कहीं हम उनसे पैसा न माँग बैठें।

” बात ज़रा खली। कितना अशिष्ट आदमी है। अतिथि से उधार लेने की इस तरह भूमिका बना रहा है। फिर इधर-उधर देखा। भोजन के कोई आसार नहीं। “आपके खाने का वक्त हो रहा है। लड़के से मैं कह गया था। वह न मालूम कहाँ चला गया है। हाँ, वह क्रिकेट मैच देखने गया था। मगर अब तक उसे वापस आ जाना चाहिए था। आ जाएगा।” मैं क्या कहा? कहा, “शाम को मैं खाना-वाना नहीं खाता। आपने बुलाया था, इसलिए ……………” भूख के बावजूद मैंने उन्हें तसल्ली देने की कोशिश की।

वे बतियाते जा रहे थे। उन लेखों की कतरनें दिखाईं जो दस वर्ष पहले लिखे थे। फिर वह ढेर जो लिखा तो था, पर न किसी संपादक ने स्वीकृत किया, न प्रकाशक ने। शर्मा निश्चित बैठे अपनी राम कहानी सुना रहे थे। जिंदगी भार हो जाती है तो अनुभव कड़वे ही रह जाते हैं। भूख लगी हो तो कड़वी बातें अच्छी नहीं लगती। “खाना-वाना हो गया?” उन्होंने पूछा। मैं सोच नहीं पा रहा था कि क्या कहूँ। शर्मा ने कहा, “शाम को ये खाते ही नहीं?” गाड़ी आ गई तो मैं विदा लेकर चला। अगले स्टेशन पर खाना खाया।

किसी से कुछ नहीं कहा। कुछ दिन बाद, शर्मा के लड़के की चिट्ठी आई। “मैं आपके नाम से परिचित हूँ। पिता जी आपका जिक्र करते रहते हैं। आपसे क्षमा चाहता हूँ। आप सहृदय हैं, हमारी विवशता समझ सकते हैं पिता जी. स्वभाव से लाचार हैं। मित्रों की आवभगत करना चाहते हैं, पर साधन हैं नहीं।” “आठ साल की लंबी बेरोज़गारी। कहीं कोई आय नहीं। इतनी ठोकरें खाई कि असलियत समझने की शक्ति ही न रही। महीने का अंतिम सप्ताह। घर में खाना नहीं और पिता जी आपको बुला लाए।

मैं क्या करता? कहाँ से लाता? हम दोनों के गुज़ारे के लिए बहन थोड़ा-बहुत पैसा भेजती है। पिछला कर्ज चुकाती है। नहीं जानता कि लड़की के पास से गुज़ारे के लिए आए पैसे मित्रों की खातिरदारी में खर्चने का पिता जी को क्या अधिकार है? अधिकार हो या न हो, हमारी वजह से आपको असुविधा हुई, अपमान हुआ। आप संपन्न हैं। भूख तो आपने अगले स्टेशन पर मिटा ही ली होगी। आशा करता हूँ कि यह पत्र पढ़कर अपमान की झंझलाहट भी जाती रहेगी।” पत्र पढ़कर मैं स्तब्ध था। लगता था मेरी आँखों के सामने शर्मा ज़ोर से खिलखिलाकर हंस रहे हैं और उनकी आँखों से आँसू टपक रहे हैं।

प्रश्नः

  1. “जाने क्या-क्या हो गया था इस बीच” का उत्तर पाठ के आधार पर दो।
  2. निम्नांकित वाक्य किसने कहा, क्यों कहा? “कभी हम किस्से लिखते थे लेकिन अब खुद किस्सा हो गए।”
  3. मुश्किलों पर हँसना बेहतर कैसे है?
  4. हर एक माता-पिता की अपने बच्चों के लिए क्या अभिलाषा होती है? शर्माजी अपनी वह अभिलाषा पूरी क्यों नहीं कर सके?
  5. शर्मा जी के कहे और अनकहे दुखड़े वर्णित करो।
  6. शर्मा जी ने संस्था और परिवार में से परिवार को क्यों चुना?
  7. लेखक ने शर्माजी के प्रत्येक हास्य पर क्या-क्या कहकर टिप्पणी की है ?
  8. बातचीत के किन मोड़ों पर लेखक को लगा कि शर्मा अब पैसे माँगेगा और उसने उन मोड़ों पर क्या कुछ किया?
  9. शर्मा जी के लड़के ने लेखक को अपने पत्र में क्या लिखा था और उस पर लेखक की क्या प्रतिक्रिया हुई?

परियोजना कार्य-2

विषय

मनुष्य एक ऊँचे दर्जे का सामाजिक जीव है। उसके समय का एक बहुत बड़ा भाग अपने भाई-बंधुओं के साथ मिल बैठने और उनके कामकाज में थोड़ा बहुत हाथ बटाने में व्यतीत होता है। कभी-कभी वह संसार की भाग-दौड़ से तंग आकर थोड़े समय के लिए किसी छोटे-मोटे शगल द्वारा अपना मनोविनोद भी करना चाहता है। वास्तव में कोई शगल पाल लेना भी मनुष्य की खुराक है। वैसे तो इस संसार में शगलों का कोई ठौर-ठिकाना नहीं। पतंगबाजी और बटेरबाजी जैसी तमाशबीनियों से लेकर चित्रकला, संगीतकला, नृत्यकला आदि जो भी छोटी-बड़ी कलाएँ दिखाई देती हैं, वे सब शगलबाजी का ही दूसरा रूप हैं।

यह अलग बात है कि प्रत्येक मनुष्य अपने स्वभाव के अनुसार इनमें से कोई-न-कोई शगल चुन लेता है। परंतु अब तो ज़माने की आबोहवा इतनी बदल गई है कि ये सब शगल निहायत पुराने हो गये हैं। आजकल तो एक ही शगल है जो शेष सबसे बाज़ी ले गया है। आप पूछेगे तो सुन लीजिए, इसको कहते हैं-चमचागिरी करना। यह बात किसी से छिपी नहीं है कि चमचागिरी का रिवाज मानव-सभ्यता के आदिकाल से चला आ रहा है। इतिहास के किसी भी युग में इस प्रकार की कोई मिसाल नहीं मिलती जब किसी राजा-महाराजा, सामन्त-नवाब अथवा वज़ीर-अमीर ने चमचागिरी के विरोध में कोई अध्यादेश जारी किया हो।

इसके विपरीत वस्तुस्थिति यह है कि प्रत्येक सरकार अपने दस्तूर के अनुसार चमचागिरी को लोकप्रिय बनाने में पूर्ण सहयोग एवं प्रोत्साहन देती रही है। ज़रा ब्रिटिश साम्राज्य की नीति का ही जायज़ा लीजिए। उन दिनों भी चमचों को रायसाहिब, रायबहादुर, खानसाहिब, खानबहादुर, सरदारसाहिब, सरदारबहादुर जैसी प्रसिद्ध उपाधियों से सम्मानित एवं विभूषित किया जाता था। राज-दरबारों तथा सभा-सोसाइटियों में सर्वत्र उनका ही बोलबाला था। यह बात अलग है कि प्राचीन काल में इनको चमचे कहने की बजाय भिन्न-भिन्न नामों से स्मरण किया जाता था।

चारण, भाट, विदूषक, बन्दीजन, राय, मरासी आदि के रूप में इनकी बिरादरी बहुत विशाल थी। परन्तु यदि गंभीरता से विचार किया जाए तो आपको विश्वास हो जायेगा कि ये सब-के-सब महानुभाव एक ही थैली के चट्टे-बट्टे थे। इनके कारनामों एवं उपलब्धियों में कोई खास अंतर नहीं था। उन दिनों चमचों के अनेक नामों की तरह चमचागिरी को भी अनेक नामों से पुकारा जाता था। जैसे मक्खन लगाना, तलवे चाटना, चिलम भरना उँगलियों पर नचाना, हाँ-में-हाँ मिलाना, चापलूसी करना आदि। परंतु आजकल चमचागिरी शब्द का प्रयोग सबसे बाज़ी मार चुका है।

वास्तव में चमचा शब्द जहाँ आधुनिक बोध का समर्थक है, वहाँ इसमें लघुता का भाव भी कूट-कूट कर भरा है। कुछ लोगों का विचार है कि हरिनाम की तरह चमचों के भी सहस्त्र नाम हो सकते हैं। बेचारों को हर नई महफिल के आगे नया स्वाँग भरना पड़ता है, इसलिए इनका कोई एक स्थायी नाम नहीं हो सकता। इनको गंगा गए तो गंगा दास, जमुना गए तो जमुना दास कहना चाहिए। संसार में हर छोटे-बड़े इनसान को किसी-न-किसी रूप में चमचागिरी की नीति का पालन करना पड़ता है। जिससे उसके जीवन की गाड़ी मंज़िल की ओर बढ़ सके, अन्यथा उसको कदम-कदम पर ब्रेक लग जाती है।

कई बार मिल्क बूथ अथवा राशन की दुकान पर एक फलाँग लंबी कतार में प्रतीक्षा करते हुए आपको नानी याद आ जाती है। इस समय इन नामुराद मुसीबतों से बचने के लिए कोई राह नहीं सूझती, मगर क्या आप जानते हैं कि इस समय कबीर की इस सँकरी प्रेमगली को पार करने के लिए कौन-सा मंत्र काम आता है? यदि आपने चमचागिरी का थोड़ा-सा प्रशिक्षण भी हासिल किया है तो आपका तीरतुक्का चल जाएगा और आप सभी ज़रूरी राशन-सामग्री संभाल कर छलांगें लगाते घर पहुंच जायेंगे और अपनी निराश बीवी को प्रसन्न कर सकेंगे, अन्यथा उस बेचारी को मन मसोस कर रह जाना पड़ेगा और आपकी अनशन करने की नौबत आ जायेगी। मैं अब आपको एक पते की बात बताने चला हूँ।

यदि आप किसी दफ्तर में काम करते हैं। समय पर तरक्की चाहते हैं। कभी-कभी छुट्टी भी मारना चाहते हैं। कड़ी मेहनत करके अपनी जान जोखिम में डालना नहीं चाहते तो इन हालात में कभी-कभी अपने अफसर की कोठी के चक्कर काटने में कोई बुराई नहीं। यदि अफसर आपके आने का कारण पूछे तो कह दीजिए कि दर्शनों के लिए आया हूँ। यदि अफसर चिढ़ कर कह उठे कि मैं कोई मंदिर हूँ, तो घबराने की आवश्यकता नहीं। विनीत भाव से प्रार्थना कीजिए कि हमारे लिए मंदिर, मस्जिद, गुरुद्वारा सब कुछ सरकार ही हैं।

परंतु मेरा विचार है इतना गिड़गिड़ाने पर भी साहिब आपको क्षमा नहीं करेगा। वह कड़क कर कहेगा कि मैंने हज़ार बार कहा है कि मैं चमचागिरी पसंद नहीं करता। वास्तव में हर अफसर का यह दस्तूर है कि ऐसे अवसर पर वह एक ही वाक्य का प्रयोग करता है कि मैं चमचागिरी पसंद नहीं करता। परंतु उसकी कथनी और करनी में आकाश-पाताल का अंतर होता है। जो अफसरों की इस अदा को भाँप लेते हैं, वे अवसर मिलने पर कभी नहीं चूकते और तुरंत यह ऐलान कर देते हैं कि सरकार तो चमचों से सौ कोस दूर भागती है।

बस आपके इतना कहने की देर है, फिर आपको कोई नहीं पूछ सकता। फिर चाहे आप दफ़्तर में बैठकर कैरम बोर्ड खेलें या लात-पर-लात रखकर उपन्यास पढ़ें, यह आपकी इच्छा है। बीरबल का नाम तो आपने खूब सुना होगा। आपकी गिनती अकबरी दरबार के नवरत्नों में होती थी। अकबर की इन पर विशेष कृपा थी और वह इन्हें हर समय एक अंतरंग की तरह अपने अंग-संग रखता था। इसमें संदेह नहीं कि बीरबल अपने समय का एक बहुत बड़ा पदाधिकारी था, परंतु यदि आप गंभीरता से विचार करें तो आप सहज ही इस परिणाम पर पहुँच जायेंगे कि उसकी तरक्की का केवल एक ही रहस्य था बादशाह की चमचागिरी करना, जिसने उसको बादशाह की मूंछ का बाल बना दिया था।

पुराने बुजुर्ग बताते हैं कि एक बार अकबर और बीरबल सैर करने निकल गए। सैर करते हुए बादशाह की नज़र बैंगनों के एक खेत पर जा टिकी। हरे-भरे, कोमल पौधों के साथ लटकते हुए बैंगनों की शोभा देखकर बादशाह से न रहा गया और कहने लगा – बीरबल! ज़रा देखो तो बैंगनों की क्या अजब बहार है ? बीरबल जैसा काइयाँ (धूर्त) वज़ीर भला इस अवसर से कब चूकने वाला था। उसने बादशाह का मूड देखकर तत्काल बैंगन की बड़ाई शुरू कर दी। उसने अपनी चमचागिरी की कला के प्रभाव से बैंगन को संसार की तमाम सब्जियों का सिरताज सिद्ध कर दिया।

यहाँ तक कि बैंगन के श्याम वर्ण की महिमा का बखान करते हुए उसे कृष्ण महाराज के रूप की उपमा सूझने लगी। बैंगन के सिर पर फैले हुए डंठल में उसे ताज की अनुभूति होने लगी। बादशाह बीरबल की अक्ल की दाद देने लगे और उसे विश्वास हो गया कि बैंगन की बढ़िया सब्जी भाग्यवानों को ही नसीब होती है। बादशाह पर बीरबल के भाषण का कुछ ऐसा प्रभाव पड़ा कि बादशाह उस दिन से नाना प्रकार की रसभीनी तरकारियों को छोड़ बैंगनों का ही जी भर कर सेवन करने लगा।

परिणामस्वरूप बादशाह भयानक पेचिश का शिकार हो गया और इसका सारा दोष बैंगनों के ही सिर थोपने लगा। इस नाजुक स्थिति में बीरबल को भी अपना नमक हलाल करने की आवश्यकता महसूस हुई और वह भी बैंगनों पर बुरी तरह से बरस पड़ा और बोला-इस काले कलूटे पर तो पहले ही विधाता का कोप है। यह निर्दोष होता तो खुदा के कहर से चमगादड़ की तरह उल्टा क्यों लटकता? सचमुच खुदा मूर्ख नहीं है, व मुँह देख-देख कर ही चपत लगाता है? बादशाह को बीरबल की यह गिरगिट जैसी नीति पसन्द न आई और वह कहने लगा-बीरबल! तुम बेपेंदे के लोटे हो।

कभी तो अपनी बात पर कायम रहा करो। अब बीरबल को एक भयंकर अग्नि-परीक्षा का सामना करना पड़ गया। परंतु बीरबल मैदान से भागने वाला व्यक्ति न था। उसने चमचागिरी में एम.ए. की डिगरी हासिल कर रखी थी। झट बोल उठा-बादशाह सलामत। बंदा बादशाह का नौकर है, बैंगन का नहीं। सरकार को बीमार करके भला यह मूंजी कैसे बन सकता है? फिर क्या था, बादशाह के क्रोध का पारा जो सौ डिग्री छू रहा था तत्काल सामान्य हो गया और बीरबल महोदय फिर अपनी चमचागिरी की बंशी बनाने लगे।

प्रश्नः

  1. संसार में कितने प्रकार के शगल प्रचलित हैं ?
  2. ब्रिटिश साम्राज्य में चमचों को किन-किन नामों से विभूषित किया जाता था?
  3. बीरबल को काइयां वजीर क्यों कहा गया है?
  4. बे पेंदे के लोटे से लेखक का क्या तात्पर्य है?
  5. बीरबल को अग्नि-परीक्षा का सामना कब करना पड़ा?
  6. इस पाठ में चमचागिरी के लिए लेखक ने किन-किन मुहावरों का प्रयोग किया है ?
  7. हमारे दैनिक जीवन में चमचागिरी का क्या महत्त्व है?

परियोजना कार्य-3

फलों का राजा आम हमारा सर्वप्रिय फल है। आज ही नहीं सदियों से आम का हमारे जीवन से घनिष्ठ संबंध रहा है। आम का इतिहास लगभग उतना ही पुराना है, जितना कि भारत का इतिहास। अनेक इतिहासकारों और कवियों ने आम को अपनी रचनाओं में स्थान दिया है। वैशाली की प्रसिद्ध नगरवधू का नाम आम्रपाली था। महाकवि कालिदास ने भी मेघदूत में आम्रकूट नामक पर्वत का सुंदर वर्णन किया है। महर्षि वाल्मीकि जी भी अपनी रामायण में आम के बागों की सुंदर छटा का वर्णन करते नहीं अघाते।

अजन्ता तथा एलोरा की गुफाओं में बनी मूर्तियों पर आम के वृक्षों की सुंदरता ने महत्त्वपूर्ण स्थान पा लिया है। बौद्ध यात्री फाह्यान और यून सांग भी अपनी यात्रा का वर्णन करते हुए भारतीय जीवन में आम के महत्व का वर्णन करने से नहीं चूके। इससे पता चलता है कि भारतीय जीवन और आम का शुरू से घनिष्ठ संपर्क रहा है। हिंदू आम को एक पवित्र वृक्ष मानते हैं। विवाह-शादियों तथा अन्य खुशी के अवसरों पर आम के पत्तों से सजावट की जाती है। आम के पत्ते गुच्छियों में बाँधकर मुख्य द्वार पर लटकाए जाते हैं; उसे ‘बंदनवार’ कहा जाता है।

यज्ञ आदि करने के लिए आम की लकड़ी की समिधा जलाना शुभ माना जाता है। आम का केवल काल्पनिक महत्त्व ही नहीं, यह तो वस्तुत: बहुत ही काम का फल है। पके हुए आम को खाना स्वास्थ्यवर्धक है। क्या अमीर और क्या गरीब, क्या बच्चा और क्या बूढ़ा, क्या स्त्री और क्या पुरुष सभी आम को बड़े चाव से खाते हैं, चूसते हैं। वस्तुतः आम एक सुलभ फल है। आम से बहुत-सी वस्तुएँ तैयार की जाती हैं। इससे तैयार किया गया अचार, मुरब्बा, स्कवैश, जैली और चटनी बहुत स्वादिष्ट होते हैं।

आजकल नगर के हर बाज़ार में आम-रस की धूम है। आम के रस को दूध में मिलाकर पी लिया जाता है। आम के गूदे को दूध में घोलकर पेय तैयार किया जाता है। उसे “मैंगोशेक” कहा जाता है। बरफ़ डालकर तैयार किया गया यह ठंडा पेय स्वादिष्ट तो है ही, गरमियों में गरमी से बचाव का बढ़िया साधन भी है। इसके गूदे या रेशों को आटे में मिलाकर बढ़िया बिस्कुट तैयार किए जाते हैं। आम में अनेक रोगनाशक गुण भी हैं। पके हुए आम खाने से मूत्र बाधा दूर हो जाती है।

आम की जलती लकड़ी से निकलने वाला धुआँ हिचकी और गले की पीड़ा दूर करने के लिए उपयोगी माना जाता है। दमा और दस्त जैसे रोगों के उपचार के लिए आम के गूदे से बनी दवाई का प्रयोग किया जाता है। आम के रस में चीनी मिलाकर बनाई गई रसदार सब्जी हैजे और प्लेग के रोगियों के लिए स्वास्थ्यदायक होती है। आम के वृक्ष से निकलने वाली गोंद को नींबू के रस में मिलाकर खुजली और चर्म रोग से ग्रस्त लोगों का उपचार किया जाता है। आम के पत्तों से प्राप्त रस रूपी तेल अनेक आयुर्वेदिक दवाइयों में प्रयुक्त होता है। आम अपने विशेष गुण के कारण भारत के लगभग हरेक कोने में पैदा हो जाता है।

समुद्र तल से 5000 फुट तक ऊँचे स्थानों पर यह शीघ्र पनपता है। इस पर परिवर्तनशील तापमान का भी कोई विपरीत प्रभाव नहीं पड़ता। मिट्टी कैसी भी हो, आम के वृक्ष में सभी प्रकार की मिट्टी में पैदा होने की क्षमता है। वर्षा ऋतु में इसके पनपने की गति अधिक होती है। जब फूल लगने व फल पकने का समय होता है, उस समय अत्यधिक धुंध भी इसके लिए हानिकारक है। अतः ऐसे क्षेत्रों में, जहाँ अधिक वर्षा होती हो या दिसंबर में धुंध रहती हो, वहाँ आम का उपजाना लाभदायक नहीं रहता। उत्तर प्रदेश, आंध्र प्रदेश, बिहार और पंजाब आम की उपज के मुख्य प्रदेश हैं।

भारत में लगभग 300 किस्मों के आमों की पैदावार होती है। इनमें से 20 किस्मों का प्रमुख स्थान प्राप्त है। महाराष्ट्र, गुजरात व गोवा में उत्पन्न होने वाली आलफौंस किस्म तथा दक्षिण भारत में पैदा होने वाली प्रसिद्ध किस्में लंगड़ा और दुसहरी हैं। दुसहरी आम खाने में बहुत मीठा और स्वादिष्ट होता है। इसीलिए विदेशों में भी इसकी काफ़ी माँग है। कुछ देश इसे अत्यधिक मीठेपन से उकता कर आलफौंस की ओर झुक रहे हैं। भारत आम की उपज वाला प्रमुख देश है। भारत आम की उपज को और उन्नत करने के लिए विशेष प्रयत्न कर रहा है। लखनऊ में केन्द्रीय आम-अनुसंधान केन्द्र खोला गया है।

संसार के कुल आम उत्पादन का 80 प्रतिशत भाग भारत में स्थित है, किन्तु संसार के निर्यात होने वाले कुछ आम का केवल 10 प्रतिशत भाग ही भारत से निर्यात होता है। वास्तव में अब फिलिपाइन, थाईलैण्ड, बर्मा, मिस्र, श्रीलंका, दक्षिणी अफ्रीका आदि अनेक देश आमों को उपजाने में रुचि ले रहे हैं। वैज्ञानिक सूझ-बूझ के आधार पर उन्होंने इनमें काफ़ी सफलता भी प्राप्त कर ली है। अब वे अपनी आवश्यकता के लिए स्वयं ही आम उगा रहे हैं। भारत का यह सर्वप्रिय फल अब विश्व भर में प्रसिद्धि पा चुका है। वह दिन दूर नहीं, जब आम संसार का एक आम फल बन जाएगा।

प्रश्नः

  1. हमारा सर्वप्रिय फल कौन-सा है ?
  2. आम को पवित्र वृक्ष किस धर्म के लोग मानते हैं ?
  3. आम के वृक्ष में किस प्रकार की मिट्टी में पैदा होने की क्षमता है?
  4. बंदर वार किसे कहते हैं ? इसका उपयोग कहाँ होता है ?
  5. आम का भारतीय जीवन से घनिष्ठ संपर्क रहा है। स्पष्ट करें?
  6. आम से कौन-कौन-सी स्वादिष्ट वस्तुएँ तैयार की जाती हैं?
  7. आम के गुणों का वर्णन करें।

परियोजना कार्य-4

लोग धर्म के नाम पर बड़े-बड़े उत्पात कर डालते हैं, परंतु यह उनका अज्ञान है। वास्तव में धर्म वह है जो धारण करे, जो हमें पतन के गर्त में गिरने से संभाले। प्रस्तुत पाठ में पूज्य महात्मा गांधी ने धर्म की सुंदर व्याख्या की है। विविध धर्म एक ही जगह पहँचने वाले अलग-अलग रास्ते हैं। एक ही जगह पहुँचने के लिए हम अलग-अलग रास्ते से चलें तो इसमें दुख का कोई कारण नहीं है। सच पूछो तो जितने मनुष्य हैं, उतने ही धर्म भी हैं। हमें सभी धर्मों के प्रति समभाव रखना चाहिए। इससे अपने धर्म के पति उदासीनता आती हो, ऐसी बात नहीं, बल्कि अपने धर्म पर जो प्रेम है, उसकी अंधता मिटती है।

इस तरह वह प्रेम ज्ञानमय और ज्यादा सात्त्विक तथा निर्मल बनता है। मैं इस विश्वास से सहमत नहीं हूँ कि पृथ्वी पर एक धर्म हो सकता है या होगा। इसलिए मैं विविध धर्मों में पाया जानेवाला तत्व खोजने की ओर इस बात को पैदा करने की कि विविध धर्मावलंबी एक-दूसरे के प्रति सहिष्णुता का भाव रखें, कोशिश कर रहा हूँ। मेरी संमति है कि संसार के धर्म-ग्रंथों को सहानुभूतिपूर्वक पढ़ना प्रत्येक सभ्य पुरुष और स्त्री का कर्तव्य है। अगर हमें दूसरे धर्मों का वैसा आदर करना है, जैसा हम उनसे अपने धर्म का कराना चाहते हैं तो संसार के सभी धर्मों का आदरपूर्वक अध्ययन करना हमारा एक पवित्र कार्य हो जाता है।

दूसरे धर्मों के आदरपूर्ण अध्ययन से हिंदू धर्म-ग्रंथों के प्रति मेरी श्रद्धा कम नहीं हुई। सच तो यह है कि हिंदू-शास्त्रों की मेरी समझ पर उनकी गहरी छाप पड़ी है। उन्होंने मेरी जीवन-दृष्टि को विशाल बनाया है। सत्य के अनेक रूप होते हैं, इस सिद्धांत को मैं बहुत पसंद करता हूँ। इसी सिद्धांत ने मुझे एक मुसलमान को उसके अपने दृष्टिकोण से और ईसाई को उसके स्वयं के दृष्टिकोण से समझना सिखाया है। जिन सात अंधों ने हाथी को अलग-अलग व सात तरह से वर्णन किया, वे सब अपनी दृष्टि से ठीक थे।

एक-दूसरे की दृष्टि से सब गलत थे और जो आदमी हाथी को जानता था, उसकी दृष्टि से सही भी थे और गलत भी थे। जब तक अलग-अलग धर्म मौजूद हैं, तब तक प्रत्येक धर्म को किसी विशेष बाहय चिहन की आवश्यकता हो सकती है। लेकिन जब बाह्य चिह्न केवल आडंबर बन जाते हैं अथवा अपने धर्म को दूसरे धर्मों से अलग बताने के काम आते हैं तब वे त्याज्य हो जाते हैं। धर्मोपदेश का उद्देश्य यह होना चाहिए कि वह एक हिंदू को बहुत अच्छा हिंदू, मुसलमान को बहुत अच्छा मुसलमान और एक ईसान को अधिक अच्छा ईसाई बनाने में मदद करे।

दूसरों के लिए हमारी यह प्रार्थना नहीं होनी चाहिये-ईश्वर, तू उन्हें वही प्रकाश दे जो तूने मुझे दिया है, बल्कि यह होनी चाहिए-तू उन्हें वह सारा प्रकाश दे जिसकी उन्हें अपने सर्वोच्च विकास के लिए आवश्यकता है। एक ऐसी रहस्यमयी शक्ति है जो सर्वत्र व्याप्त है। मैं उसे अनुभव करता हूँ, यद्यपि देखता नहीं हूँ। यह अदृश्य शक्ति अपना अनुभव तो कराती है, परंतु उसका कोई प्रमाण नहीं दिया जा सकता, क्योंकि जिन ऋतुओं का मुझे अपनी इंद्रियों द्वारा ज्ञान होता है, उन सबसे वह बहुत भिन्न है।

मैं यह ज़रूर अनुभव करता हूँ कि जब मेरे चारों ओर हर चीज़ हमेशा बदलती है, नष्ट होती रहती है, तब इन परिवर्तनों के पीछे , कोई चेतन शक्ति ज़रूर है जो बदलती नहीं है, जो सबको धारण किए हुए है, जो सृजन करती है, संहार करती है और नया सृजन करती है। यह जीवनदायी शक्ति या सत्ता ही ईश्वर है, और चूँकि केवल इंद्रियों द्वारा दिखाई देने वाली कोई भी चीज़ न तो स्थायी है और न हो सकती है, इसलिए एकमात्र ईश्वर का ही अंतिम अस्तित्व है।

यह शक्ति कल्याणकारी है या अकल्याणकारी? मैं देखता हूँ कि यह सर्वथा कल्याणकारी है, क्योंकि मुझे दिखाई देता है कि मृत्यु के बीच जीवन कायम रहता है, असत्य के बीच सत्य टिका रहता है और अंधकार के बीच प्रकाश स्थिर रहता है। इससे मुझे पता चलता है कि ईश्वर जीवन है, सत्य है और प्रकाश है। वही प्रेम है। वही परम मंगल है।

प्रश्नः

  1. लोग किस चीज़ के नाम पर बडे-बडे उत्पात करते हैं?
  2. धर्मोपदेशकों का क्या उद्देश्य होना चाहिए?
  3. कौन-सी शक्ति सृजन और संहार करती है?
  4. हमें सब धर्मों के प्रति कैसे भाव रखने चाहिए?
  5. गांधी जी ईश्वरीय शक्ति को कल्याणकारी क्यों मानते हैं?
  6. गांधी जी के कर्म विषयक विचारों को अपनी भाषा में लिखें।
  7. ईश्वर के अस्तित्व को इंद्रियों से अनुभव क्यों नहीं किया जा सकता?

परियोजना कार्य-5

सदाचार का अर्थ है-अच्छा, नेक व उत्तम व्यवहार; अथवा जो काम सज्जन करते हैं, उन कामों को करना ही सदाचार है। सदाचार से मानव में अनेक गुण-नम्रता, सुशीलता, बड़ों का आदर करना, सबसे प्रेम करना, दीनों के प्रति दया, नैतिकता और सत्यनिष्ठा आते हैं। सदाचारी मनुष्य आदर्श नागरिक होती है। सबकी आँखों का तारा होता है। वह जाति-संप्रदाय के भेद-भाव को समाप्त करता है, ईर्ष्या द्वेष से ऊपर उठता है। मानव मात्र से प्रेम करती है-उसका जीवन कृतार्थ हो जाता है। उसके कारण समाज में भी व्यवस्था आती है, चारों ओर शांति होती है।

पशु-पक्षी अपनी शारीरिक संरचना के अनुरूप काम करते हैं। वे अपनी प्रकृति से ऊपर नहीं उठ सकते। पर मानव केवल शारीरिक आवश्यकताओं के अनुरूप काम नहीं करता। उसमें बौद्धिक शक्ति है। वह सूझ-बूझ रखता है। अच्छाई-बुराई का निर्णय करता है। वह समझता है कि बड़ों का सत्कार, साथियों से प्रेम और दीनों की सहायता करने से प्रसन्नता मिलती है। ऐसी बातें अच्छी हैं, सत् हैं। इसके विपरीत दूसरों से लड़ना-झगड़ना, दीनों को सताना, माता-पिता का अनादर करना बुरा है, असत् है।

असत् को त्याग कर सत् को अपनाने की दृढ़ इच्छाशक्ति होनी चाहिए। जिससे हम बुद्धि द्वारा निर्णीत सत्य को आचरण में ला सकें। इच्छा, ज्ञान और कर्म का पूरा मेल हो। तभी हम सदाचारी बन सकते हैं। सदाचार में दो शब्द हैं, सत् + आचार; अर्थात् सत् को जानना और उस पर आचरण करना। शास्त्रों से सत् को धर्म, तो सदाचार को परम-धर्म कहा गया है। गुरुओं ने भी सत् की अपेक्षा सच्चे आचरण को किया है। सदाचार का मुख्य गुण सत् है। यह सृष्टि और मानव-जीवन का आधार है। हमारी आस्था है, ‘सत्यमेव जयते नानृतम्’ अर्थात् सत्य की जीत होती है, झूठ की नहीं।

जो बात जिस प्रकार देखी या सुनी हो उसी प्रकार कहना तथा मुख से निकले हुए शब्दों पर दृढ़ रहना सत्य कहलाता है। सत्यवादी हरिश्चंद्र को कौन नहीं जानता, जिन्होंने अपना वचन निभाने के लिए अपना राजपाट छोड़ा; वे अपनी पत्नी और पुत्र से पृथक् हुए। श्मशान भूमि में नौकरी करने लगे। जब उनकी पत्नी शैव्या पुत्र रोहिताश्व का शव लेकर आई, तो उसे भी बिना कर लिए दाह संस्कार करने की अनुमति नहीं दी। बचपन में महात्मा गांधी इस कथा से इतने प्रभावित हुए कि उन्होंने आजीवन सत्य का सहारा लिया और देश को स्वतंत्र कराया।

सामान्य रूप से बच्चा सत्य ही बोलता है, झूठ जानता ही नहीं। हम स्वार्थवश उसे झूठ बोलना सिखाते हैं अथवा वह डरकर झूठ बोलता है। यदि बालक कोई भूल कर बैठता है अथवा उससे कोई नुकसान हो जाता है तो प्यार से सही स्थिति जाननी चाहिए। झूठ बोलने का अवसर नहीं देना चाहिए। सत्यवादी बालक छल, कपट, हेराफेरी और दूसरे अपराधों को नहीं करता। वह सजग रहता है। वह निर्भय हो जाता है। सबका विश्वासपात्र बन जाता है। अहिंसा अर्थात् मन, वाणी और कर्म से दूसरों को कष्ट न पहुँचाना सदाचार का दूसरा महत्त्वपूर्ण गुण है। हिंसा का मूल कारण स्वभाव की निर्ममता, कठोरता और अहंभाव है।

हिंसक व्यक्ति अपने को महान और दूसरों को हीन समझता है। उनकी भावनाओं का आदर नहीं करता। इसी कारण उसका अपने मन वाणी और कर्मों पर नियंत्रण नहीं होता। वह बुरा सोचता है, गालियाँ निकालता है, मार-पीट करता है, आतंक मचाता है। पर सदाचारी मनुष्य सबको अपने जैसा समझता है, सबकी भावनाओं का आदर करता है। सबका हित सोचता है, मीठा बोलता है और सबका भला करता है। अहिंसा आत्मा की शक्ति है, जिसके आगे क्रूर और अत्याचारी व्यक्ति भी नतमस्तक हो जाता है।

वह अपनी भूल पर पछताता है और सही इंसान बन जाता है। अहिंसा से शत्रु भी मित्र बन जाते हैं। पराए भी अपने हो जाते हैं। सदाचार का तीसरा महत्त्वपूर्ण गुण नम्रता है। यही असली विद्या है। ‘विद्या ददाति विनयं’। अर्थात् विद्या विनय देती है। विनयभाव से बालक सात्पात्र बनता है। व्यक्ति जितना नम्र होता है उतना ही महान होता है। बड़ों का अभिवादन और सत्कार करने से और उनकी आज्ञानुसार चलने से नम्रता का विकास होता है।

शास्त्रों का आदेश है, ‘मातृदेवो भव, पितृदेवो भव, आचार्य देवो भव’ अर्थात् माता-पिता और गुरु को देवता समझो। माता-पिता देवता हैं। क्योंकि वे हमें जीवन देते हैं, हमारा पालन-पोषण करते हैं। खून पसीना एक करके हमें पढ़ाते हैं और हमें अपने पांवों पर खड़ा करते हैं। गुरु हमें अंधकार से प्रकाश की ओर ले जाते हैं, वे हमें दूसरा जन्म देते हैं। इनका आदर करना हमारा नैतिक कर्तव्य है। माता-पिता और गुरु की तरह समाज में बड़ों की सेवा करने, उन्हें प्रणाम करने से वे हमें उठा कर गले लगाते हैं।

हमें आशीर्वाद देते हैं, ‘स्वस्थ रहो’, ‘दीर्घायु हो’, ‘यशस्वी बनो’, ‘विद्वान् बनो।’ नम्रता सचमुच वरदान है। इससे हमारा व्यक्तित्व खिल उठता है। जिससे हम नम्रता से व्यवहार करते हैं, वह ईर्ष्या, द्वेष, क्रोध को थूक देता है। विरोधाभाव भुला देता है। सदाचार का सबसे महत्त्वपूर्ण गुण नैतिकता है। वर्तमान शिक्षा पद्धति में इस पर बल नहीं दिया जाता। आजकल बालक घर में रहते हैं, स्कूल में पढ़ते हैं। घर में सब सुविधाएँ प्राप्त हैं। दूरदर्शन, सिनेमा और पाश्चात्य संस्कृति ने जीवन के आदर्शों में परिवर्तन ला दिया है।

बाल्यावस्था और कुमारावस्था में मन कोमल होता है। प्रत्येक बात हृदय पर अंकित हो जाती है। बुरी बातों का प्रभाव और आकर्षण अच्छी बातों से कहीं अधिक और शीघ्र होता है। इसी तथ्य को दृष्टि में रखकर अपनी पुस्तक ‘भारत-भारती’ में मैथिलीशरण गुप्त ने नवयुवकों को चेतावनी दी थी, ‘यदि तुम न संभलोगे अभी, तो फिर न संभलोगे कभी।’ सबसे पहले बालकों की संगति का ध्यान रखना चाहिए। सदाचारी मित्रों, अच्छी कुटुंबियों और सज्जनों का संपर्क होना चाहिए। अवकाश का सदुपयोग होना चाहिए।

चरित्र निर्माण करने वाली पुस्तकों का अध्ययन, सामाजिक व ऐतिहासिक चल-चित्रों को देखना, खेलकूद व स्कूल की अन्य गतिविधियों में भाग लेने को प्रोत्साहित करना चाहिए। दैनिक कार्यक्रम निश्चित करें। प्रातः उठना, सैर अथवा हल्का व्यायाम करने, समय पर स्कूल जाने, घरेलू कामों में सहयोग देने, समय पर सोना तथा आलस्य को दूर रखने से जीवन में नियमितता आएगी। रहन-सहन में सरलता अपनाए, कृत्रिम श्रृंगार और चटकीले वस्त्रों से कुविचार उभरते हैं। खान-पान पौष्टिक और संतुलित हों।

ऐसे आचरण से क्रमशः चरित्र का निर्माण होगा। शरीर स्वस्थ व नीरोग होगा। मुखमंडल में कांति और प्रसन्नता होगी, अंगों में ओज तथा मन और बुद्धि में उत्साह होगा। चरित्र का महत्त्व इस उक्ति से स्पष्ट होता है, ‘धन हानि कोई हानि नहीं, स्वास्थ्य हानि कुछ हानि है, चरित्र हानि से सर्वनाश हो जाता है।’ इस तरह सदाचार में सत्यवादिता, प्रेमभावना, नम्रता, सुशीलता, नैतिकता आदि गुणों का समावेश है। जिसे अपनाने से मनुष्य अपना जीवन सार्थक करता है, मान-सम्मान पाता है, समाज व राष्ट्र का हित करता है।

प्रश्नः

  1. सदाचार से क्या तात्पर्य है?
  2. ‘सत्यमेव जयते’ का क्या अर्थ है?
  3. हिंसा का मूल कारण क्या है?
  4. जीवन में सदाचार का क्या महत्त्व है?
  5. सदाचारी व्यक्ति में क्या-क्या गुण होते हैं?
  6. बाल्यावस्था जीवन की प्रभावशाली अवस्था है, ऐसा क्यों?
  7. बालकों को किस तरह की संगति का ध्यान रखना चाहिए?
  8. जीवन में नियमितता कैसे लाई जा सकती है?
Read More