Chapter 4 गूँगे | Chapterwise Important MCQs Question for Class 11th Hindi Antra

NCERT Class 11 Hindi Antra Chapter 4 गूंगे- रांगेय राघव बहुवैकल्पिक प्रश्नोत्तर 

1. छोटी बच्ची को किसे आवाज देकर बुलाने को कहा गया ?

दूधवाले को 

सब्जी वाले को 

गूंगे को 

पड़ोसन को

उत्तर:- गूंगे को

2. कहानी का प्रमुख पात्र कौन है ?

चमेली 

बसंता 

गूंगा किशोर 

कोई भी नहीं

उत्तर:- गूंगा किशोर 

3. छोटी बच्ची ने क्या आवाज लगाई ?

गूंगे 

ओए बहरे 

ओए गूंगे 

दुंदे

उत्तर:- दुंदे

4. सीने पर हाथ मार कर गूंगा क्या इशारा करता है ?

मैं पहलवान हूं 

मैं स्टंटमैन हूं 

मैं मेहनती हूं 

उपयुक्त सभी

उत्तर:- मैं मेहनती हूं 

5. किशोर के जन्म से गूंगे होने का कारण क्या है ?

पागलपन 

दुर्घटना के कारण 

बहरापन 

उपयुक्त सभी

उत्तर:- बहरापन

6. गूंगे का पालन पोषण किसने किया था ?

बुआ ने 

माता-पिता ने 

फूफा ने 

बुआ फूफा ने

उत्तर:- बुआ फूफा ने

7. चमेली का पति स्वभाव से कैसा था ?

नटखट 

उतावला 

पागल 

सीधा साधा

उत्तर:-  सीधा साधा

8. चमेली स्वभाव से कैसी महिला थी?

गुस्सा वाली

पागल

भावुक

उपयुक्त सभी 

उत्तर:-  भावुक

9. चमेली की बेटी का क्या नाम था ?

परी 

बसंता

शकुंतला  

किशोर

उत्तर:-  शकुंतला

10. चमेली ने गूंगे को कितने पैसे पर काम पर रखा था ?

4 रुपए

3 रुपए

100 रूपए महीना 

200 रुपएमहीना 

उत्तर:-  4 रुपए

11. चमेली ने गूंगे से इशारे करके क्या पूछा ?

कहां से आया है 

कौन है 

हमारे यहां रहेगा 

खाना खाएगा

उत्तर:-  हमारे यहां रहेगा 

12. चमेली ने गूंगे के आगे रोटियां फेंक कर क्यों दी ?

वह भिखारी था 

वह भाग गया था 

वह गलत काम करता था 

उपयुक्त सभी

उत्तर:-  वह भाग गया था 

13. गूंगे कितने रुपए में नौकरी करने को तैयार हो गया ?

5 रुपए 

4 रुपए 

3 रुपए 

6 रुपए

उत्तर:-  4 रुपए

14. गूंगा अपने बारे में सभी को क्या बताता है ?

वह मेहनती है 

भीख नहीं मांगता 

किसी के सामने हाथ नहीं फैलाता 

उपयुक्त सभी

उत्तर:-  उपयुक्त सभी

15. चमेली गूंगे को किससे मारती है ?

जूता 

झाड़ू 

चिमटा 

चप्पल

उत्तर:-  चिमटा

16. चमेली को गूंगे से सावधान किसने किया था ?

पड़ोसन ने 

पड़ोसन सुशीला ने 

बसंता ने 

इनमें से कोई नहीं

उत्तर:-  पड़ोसन सुशीला ने ?

17. गूंगा किसकी आवाज को कभी अनसुना नहीं करता था बसंता ?

चमेली 

सुशीला 

शकुंतला

उत्तर:-  चमेली

18. चमेली के बेटे ने किसको चपट मारा था ?

अपने पापा को 

अपनी बहन को

गूंगे को 

इनमे से कोई नही 

उत्तर:-  गूंगे को

19. चमेली गूंगे का हाथ पकड़कर दरवाजे से बाहर क्यों निकाल देती है ?

छोरी के कारण 

गंदी हरकतें के कारण 

बसंता पर हाथ उठाने के कारण 

इनमें से कोई नहीं

उत्तर:-  छोरी के कारण 

20. “काम तो करता नहीं ” भिखारी किसने कहा था ?

चमेली 

सुशीला 

बसंता 

शकुंतला 

उत्तर:-  चमेली

21. गूंगे का नाम क्या था ?

गूंगा 

बसंता 

किशोर 

राम प्यारे

उत्तर:-  किशोर

Read More

Chapter 3 टार्च बेचनेवाले | Chapterwise Important MCQs Question for Class 11th Hindi Antra

Class 11 Hindi (Antra) torch bechne wala MCQ with Answers

Question: 1  “टॉर्च बेचने वाला” में पाठ के लेखक कौन है ?

(क) हरिशंकर परसाई

(ख) अमरकांत

(ग) महादेवी वर्मा

(घ) कबीरदास

Answer: हरिशंकर परसाई

Question: 2  “टॉर्च बेचने वाले” पाठ किस विधा की रचना है?

(क) सरल

(ख) दर्दनाक

(ग) व्यंग्य

(घ) इनमे से कोई नही

Answer: व्यंग्य

Question: 3 लेखक किसकी दाढ़ी बड़ी हुई देखता है?

(क) अपनी

(ख) पहले मित्र की

(ग) दूसरे मित्र की

(घ) अपने पिता की

Answer: पहले मित्र की

Question: 4  किस सवाल के पैर जमीन में गड़े थे?

(क) पैसे कैसे कमाया जाए

(ख) क्या काम करे

(ग) कहां जाए

(घ) इनमे से कोई नही

Answer: पैसे कैसे कमाया जाए

Question: 5 दोनों मित्रों ने तय किया:-

(क) एक ही दिशा में जाएंगे

(ख) अलग-अलग दिशा में जाएंगे

(ग) पूर्व दिशा में जाएंगे

(घ) दक्षिण दिशा में जाएंगे

Answer: अलग-अलग दिशा में जाएंगे

Question: 6  पहला मित्र किसका भय दिखाता था?

(क) जानवरों का

(ख) धूप का

(ग) अंधेरे का

(घ) राक्षसों का

Answer: अंधेरे का

Question: 7  आसमान को छूता सवाल कौन-सा था ?

(क) घर कैसे जाया जाया

(ख) पैसे कैसे कमाया जाया

(ग) क्या काम करे

(घ) घूमने कहा जाए

Answer: पैसे कैसे कमाया जाया

Question: 8  दोनों दोस्तो ने कितने साल बाद मिलने का वादा किया?

(क) 3 साल बाद

(ख) 2 साल बाद

(ग) 7 साल बाद

(घ) 5 साल बाद

Answer: 5 साल बाद

Question: 9 पहला मित्र क्या काम करता था?

(क) शिक्षक का

(ख) कपड़े बेचने का

(ग) टॉर्च बेचने का

(घ) इनमें से कोई नहीं

Answer: टॉर्च बेचने का

Question: 10 पहला मित्र अपने को पाता है:

(क) भव्य मंच पर

(ख) गली पर

(ग) अस्पताल पर

(घ) स्कूल पर

Answer: भव्य मंच पर

Question: 11 “भव्य पुरुष” देखने में कैसा था?

(क) दाढ़ी बड़ी हुई थी

(ख) कैश लंबे थे

(ग) सुंदर रेशमी वस्त्र पहने थे

(घ) ये सभी

Answer: ये सभी

Question: 12 टॉर्च बेचने वाली कंपनी का क्या नाम था?

(क) चांदछाप

(ख) ताराछाप

(ग) सुरजछाप

(घ) इनमे से कोई नही

Answer: सुरजछाप

Question: 13 पहले मित्र ने अपनी टॉर्च कहां प्रवाहित कर दी?

(क) कुएं में

(ख) नदी में

(ग) समंदर में

(घ) गड्डे में

Answer: नदी में

Question: 14 भव्य पुरुष पहले मित्र को क्या करने का इशारा करता है?

(क) चुप रहने का

(ख) नचाने का

(ग) गाना गाने का

(घ) भाग जाने का

Answer: चुप रहने का

Question: 15 “टॉर्च बेचने वाला” अध्याय में किस पर व्यंग्य किया है?

(क) भगवानों के प्रति आस्था

(ख) राजनीतिक दुनिया

(ग) धार्मिक आडंबरों के ऊपर

(घ) इनमे से कोई नही

Answer: धार्मिक आडंबरों के ऊपर

Question: 16 “टॉर्च बेचने वाला” पाठ की भाषा है:-

(क) व्यंग्यनात्मक खेड़ी बोली

(ख) रचनात्मक बोली

(ग) प्रेमनात्मक बोली

(घ) प्रसन्नात्मक बोली

Answer: व्यंग्यनात्मक खेड़ी बोली

Question: 17 पहला मित्र किस नई कंपनी की टॉर्च बेचने की बात कहता है?

(क) सुरजछाप कंपनी

(ख) तारछाप कंपनी

(ग) सनातन धर्म कंपनी

(घ) इनमे से कोई नही

Answer: सनातन धर्म कंपनी

Question: 18 पहला मित्र अपने बारे मे यह किस्सा किसको सुना रहा है?

(क) एक बूढ़े व्यक्ति को

(ख) लेखक को

(ग) दूसरे मित्र को

(घ) इनमे से कोई नही

Answer: लेखक को

Question: 19 ” हमने दूसरी तरफ मुंह कर लिया” टॉर्च बेचने वाला पाठ में से इस वाक्य में “हमने” किसके लिए प्रयोग हुआ है?

(क) लेखक के लिए

(ख) पत्रकार के लिए

(ग) दोनों मित्रो के लिए

(घ) इनमे से कोई नही

Answer: दोनों मित्रो के लिए

Question: 20 लेखक को पहला मित्र किसलिए अपने बारे में बताता है?

(क) क्योंकि वह शहर छोड़के जा रहा होता है

(ख) क्योंकि वह मरने वाला होता है

(ग) क्योंकि वह पागल हो चुका हो होता है

(घ) क्योंकि वह उसे यह सब बताना चाहता था

Answer: क्योंकि वह शहर छोड़के जा रहा होता है

Question: 21 पहले मित्र के बदले हुए स्वरुप को देखकर , किसको चिंता होने लगती है?

(क) उसके मित्र को

(ख) उसके पिता को

(ग) उसकी मां को

(घ) लेखक को

Answer: लेखक को

Question: 22 पहले मित्र का दोस्त क्या कार्य करता था?

(क) बिजनेस मैन का

(ख) संत तथा ताश्निक का

(ग) टॉर्च बेचने का

(घ) इनमे से कोई नही

Answer: संत तथा ताश्निक का

Question: 23 मन के अंधकार को दूर करने के लिए “टॉर्च बेचने वाले” व्यंग्य के आधार पर किसकी आवश्यकता होती है?

(क) प्रकाश की

(ख) टॉर्च की

(ग) सनातन धर्म अपनाने की

(घ) दाढ़ी बढ़ाने की

Answer: प्रकाश की

Question: 24 “टॉर्च बेचने वाला” पाठ में पहला मित्र किस्से बात कर रहा है?

(क) अपने मित्र से

(ख) चौधरी से

(ग) लेखक से

(घ) नाई से

Answer: लेखक से

Question: 25 “टॉर्च बेचने वाला” पाठ के लेखक का जन्म हुआ था:-

(क) 24 अगस्त 1924

(ख) 22 अगस्त 1924

(ग) 23 अगस्त 1923

(घ) 24 अगस्त 1942

Answer: 22 अगस्त 1924

Read More

Chapter 2 दोपहर का भोजन | Chapterwise Important MCQs Question for Class 11th Hindi Antra

NCERT Class 11 Hindi (Antra) Dopahar ka bhojan MCQ with Answers

Question: 1 दोपहर का भोजन कहानी के लेखक कौन हैं ?

(क) अमरकांत

(ख) मोहन राकेश

(ग) कबीरदास

(घ) हरीशंकर परसाई

Answer: अमरकांत

‍ Questions: 2 सिद्धेश्वरी के कितने बेटे हैं?

(क) दो

(ख) चार

(ग) तीन

(घ) पांच

Answer: तीन

Question: 3 सिद्धेश्वरी के बड़े बेटे का क्या नाम है ?

(क) मोहन

(ख) रामचन्द्र

(ग) राम

(घ) प्रमोद

Answer: रामचंद्र

Question: 4 सिद्धेश्वरी के मंझले बेटे का क्या नाम है ?

(क) मोहन

(ख) श्याम

(ग) प्रमोद

(घ) सोहन

Answer: मोहन

Question: 5 मोहन की उम्र क्या है ?

(क) 15 साल

(ख) 18 साल

(ग) 20 साल

(घ) 7 साल

Answer: 18 साल

Question: 6 सिद्धेश्वरी के पति का क्या नाम है ?

(क) राम प्रसाद

(ख) मोहम्मद खान

(ग) मुंशी चंद्रिका प्रसाद

(घ) इनमे से कोई नहीं

Answer: मुंशी चंद्रिका प्रसाद

Question: 7 अंत में जब सब खा चुके थे तब कितनी रोटी बची थी?

(क) दो रोटी

(ख) चार रोटी

(ग) एक रोटी

(घ) एक भी नही

Answer: एक रोटी

Question: 8 “दोपहर का भोजन” पाठ का मुख्य पात्र कौन है –

(क) मुंशी जी

(ख) रामचंद्र

(ग) मनोज

(घ) सिद्धेश्वरी

Answer: सिद्धेश्वरी

Question: 9 अंत में सिद्धेश्वरी के अलावा और कौन बचा था जिसने खाना नही खाया था ?

(क) उसका बड़ा बेटा, रामचंद्र

(ख) उसका पति, मुंशी जी

(ग) उसका सबसे छोटा बेटा,प्रमोद

(घ) कोई नही

Answer: उसका सबसे छोटा बेटा,प्रमोद

Question: 10 अमरकांत को साहित्य अकादमी पुरुस्कार कब मिला?

(क) 2006 में

(ख) 2007 में

(ग) 2013 में

(घ) 2010 में

Answer: 2007 में

Question: 11 मुंशी चंद्रिका प्रसाद ने रोटी के स्थान पर खाने के लिए क्या मांगा ?

(क) गुड़ तथा गुड़ का ठंडा रस

(ख) एक कटोरी पनियाई दाल

(ग) चने को तरकारी

(घ) इनमे से कोई नही

Answer: गुड़ तथा गुड़ का ठंडा रस

Question: 12. ” दोपहर का भोजन ” कहानी में सिद्धेश्वरी झूठ क्यों बोलती है ?

(क) सबको भ्रमित करने के लिए

(ख) झूठ बोलना उसकी आदत है

(ग) डर के कारण

(घ) परिवार में एकता बनाए रखने के लिए

Answer: परिवार में एकता बनाए रखने के लिए

Question: 13. “दोपहर का भोजन” कहानी में कौन-सा पात्र बीमार है ?

(क) रामचंद्र

(ख) प्रमोद

(ग) मोहन

(घ) मुंशी जी

Answer: रामचंद्र

Question: 14 रामचंद्र क्या काम करता है-

(क) मैकेनिक का

(ख) प्रफूरीडिंग का

(ग) ड्राइवर का

(घ) अध्यापन का

Answer: प्रफूरीडिंग का

Question: 15 “दोपहर का भोजन” कहानी में सिद्धेश्वरी का मूल स्वर क्या है –

(क) वर्ग संघर्ष

(ख) अपनी नाकामियों के विरुद्ध संघर्ष

(ग) समाज में व्यापक आर्थिक विषमता

(घ) शोषण के विरुद्ध संघर्ष

Answer: वर्ग संघर्ष

Question: 16 सिद्धेश्वरी किसकी झूठी थाली लेकर खाना को बैठी थी?

(क) रामचंद्र की

(ख) मुंशी जी की

(ग) प्रमोद की

(घ) उपरोक्त में से कोई नही

Answer: मुंशी जी की

Question: 17 रामचंद्र की उम्र कितनी है –

(क) 21 वर्ष

(ख) 23 वर्ष

(ग) 24 वर्ष

(घ) 20 वर्ष

Answer: 21वर्ष

Question: 18 सिद्धेश्वरी के खाते समय आंसू टपकना कैसी व्यथा को दर्शाता है –

(क) अमीरी

(ख) गरीबी

(ग) दोनो

(घ) इनमें से कोई नही

Answer: गरीबी

Question: 19 अमरकांत जी का जन्म कब हुआ –

(क) सन् 1952 में

(ख) सन् 1924 में

(ग) सन् 1925 में

(घ) सन् 1950 में

Answer: सन् 1925 में

Question: 20 जब मोहन खा रहा था तब घर में कौन प्रवेश करता है –

(क) रामचंद्र

(ख) मेहमान

(ग) अंकल

(घ) मुंशी चंद्रिका जी

Answer: मुंशी चंद्रिका जी

Read More

Chapter 1 ईदगाह | Chapterwise Important MCQs Question for Class 11th Hindi Antra

Q 1. ईदगाह कहानी के लेखक कोन हैं ?
(क) कबीरदास
(ख) हरीशंकर परसाई
(ग) मुंशी प्रेमचन्द
(घ) सूरदास

Ans. (ग) मुंशी प्रेमचन्द।

Q 2. ईदगाह कहानी का प्रमुख पात्र कौन है ?
(क) हामिद
(ख) अमीना
(ग) महमूद
(घ) मोहसिन

Ans. (क) हामिद।

Q3. मुंशी प्रेमचन्द जी की मृत्यु कब हुई ?
(क) 13.नवंबर.1936
(ख) 8.अक्टूबर.1936
(ग) 13.अक्टूबर.1938
(घ) 9.नवंबर.1937

Ans. (ख) 8.अक्टूबर.1936

Q 4. हामिद की दादी उसको कितने पैसे देती है ?
(क) चार पैसे
(ख) दो पैसे
(ग) तीन पैसे
(घ) एक पैसे

Ans. (ग) तीन पैसे

Q 5. हामिद अपनी दादी के लिए क्या लाता है ?
(क) खिलौना
(ख) चिमटा
(ग) रबड़ी
(घ) मिठाई

Ans. (ख) चिमटा

Q 6. ईदगाह का त्योहार कौन-से महीने में आता है ?
(क) अक्टूबर
(ख) दिसम्बर
(ग) अप्रैल
(घ) जुलाई

Ans. (क) अक्टूबर

Q 7. हामिद के पिता की मृत्यु कैसे हुई थी ?
(क) दुर्घटना के कारण
(ख) हैजे के कारण
(ग) कैंसर के कारण
(घ) मलेरिया के कारण

Ans. (ख) हैजे के कारण

Q 8. हामिद के पिता का क्या नाम था ?
(क) जिन्ना
(ख) चौधरी
(ग) फहीमन
(घ) आबिद

Ans. (घ) आबिद

Q 9. हामिद की दादी का क्या नाम है ?
(क) फहीमन
(ख) अमीना
(ग) राज्या
(घ) फिरोजा

Ans. (ख) अमीना

Q 10. ईदगाह गांव से कितना दूर है?
(क) 3 कोस दूर चलना पड़ता है
(ख) 4 कोस दूर चलना पड़ता है
(ग) 2 कोस दूर चलना पड़ता है
(घ) 5 कोस दूर चलना पड़ता है

Ans. (क) 3 कोस दूर चलना पड़ता है ।

Q 11. मोहसिन के पास कितने पैसे हैं ?
(क) 12 पैसे
(ख) 13 पैसे
(ग) 15 पैसे
(घ) 11 पैसे

Ans. (ग) 15 पैसे

Q 12. ईद के समय लोगो के वस्त्र कैसे होते है?
(क) सादे
(ख) भड़कीले
(ग) लंबे
(घ) महंगे

Ans. (ख) भड़कीले

Q 13. रेवड़ी दिखाकर हामिद को कौन चिढ़ाता है ?
(क) मोहसिन
(ख) सम्मी
(ग) नूरे
(घ) महमूद

Ans. (क) मोहसिन

Q 14. चिमटे वाला हामिद को चिमटे के कितने दाम बताता है ?
(क) 6 पैसे
(ख) 4 पैसे
(ग) 3 पैसे
(घ) 5 पैसे

Ans. (क) 6 पैसे

Q 15. महमूद कौन-सा खिलौना लेता है ?
(क) भिश्ती
(ख) वकील
(ग) सिपाही
(घ) धोबिन

Ans. (ग) सिपाही

Q 16. झूला झूलने के लिए कितने पैसे देने पड़ रहे थे ?
(क) 2 पैसे
(ख) 3 पैसे
(ग) 1 पैसे
(घ) इनमे से कोई नहीं

Ans. (ग) 1 पैसे

Q 17. हामिद चिमटा कितने पैसे में खरीदता है ?
(क) एक पैसे में
(ख) तीन पैसे में
(ग) चार पैसे में
(घ) दो पैसे में

Ans. (ख) तीन पैसे में

Q 18. सम्मी अपने लिए कौन-सा खिलौना खरीदता है ?
(क) वकील
(ख) चिमटा
(ग) भिश्ती
(घ) धोबिन

Ans. (घ) धोबिन

Q 19. फहीमन हामिद की दादी को कितने पैसे देकर जाती है ?
(क) आठ आने
(ख) चार आने
(ग) पांच आने
(घ) सात आने

Ans. (क) आठ आने

Q 20. गांव से जो मंडली ईदगाह तक गई थी , वो गांव कितने बजे पहुंची ?
(क) तीन बजे
(ख) दस बजे
(ग) ग्यारह बजे
(घ) एक बजे

Ans. (ग) ग्यारह बजे

Read More

Communication Open Source Concept | class 12th | Important question Computer Science

Important Questions for Class 12 Computer Science – Communication Technologies

Question 1:
Give two examples of PAN and LAN type of networks. Delhi 2016
Аnswer:

Two examples of PAN type of networks 3.
are as follows:

  1. Upload the photo from your cell phone to your desktop computer.
  2. Watch movies from an online streaming service to your TV.

Two examples of LAN type of networks
are as follows:

  1. Small office or a Internet cafe.
  2. Two or more computers connected in few distances.

Question 2:
Which protocol helps us to browse through Web pages using Internet browsers? Name any one Internet browser. Delhi 2016
Аnswer:

Protocol → HyperText Transfer Protocol A.
(HTTP)
Internet Browser → Google Chrome

Question 3:
Write two advantages of 4G over 3G Mobile Telecommunication Technologies in terms of speed and services. Delhi 2016
Аnswer:

Two advantages of 4G over 3G mobile telecommunication technologies are as follows:

Question 4:
Write two characteristics of Web 2.0. Delhi 2016; All India 2016
Аnswer:

Characteristics of Web 2.0 are as follows:

  1. Free classification of information
  2. User as a contributor

Question 5:
What is the basic difference between Trojan Horse and Computer Worm? Delhi 2016; All India 2016
Аnswer:

Computer worms are programs that replicate themselves from system to system without the use of a host file, while Trojan horses are impostor files that claim to be something desirable but, in fact are malicious.

Question 6:
Categorise the following under Client Side and Server Side script category:

  1. VBScript
  2. ASP
  3. JSP
  4. JavaScript
    All India 2016: Delhi 2016

Аnswer:
Client side scripting languages are as follows: JavaScript, VBScript
Server side scripting languages are as follows: ASP, JSP

Question 7:
Differentiate between PAN and LAN types of networks. All India 2016
Аnswer:
PAN network is a computer network organised around an individual person, while LAN network is a privately owned networks within a single building or campus upto a few kilometres in distance.

Question 8:
Which protocol helps us to transfer files to and from a remote computer? All India 2016
Аnswer:

Protocol → File Transfer Protocol ( FTP )

Question 9:
Write two advantages of 3G over 2G Mobile Telecommunication Technologies in terms of speed and services. All India 2016
Аnswer:

Two advantages of 3G over 2G Mobile Telecommunication Technologies are as follows:

  1. The downloading and uploading speeds available in 3G technologies are upto 21 Mbps and 5.7 Mbps respectively while in 2G technologies the downloading and uploading speeds are upto 236 Kbps.
  2. The services like mobile TV, video transfer and GPS systems are the additional features of 3G technology that are not available with 2G technologies.

Question 10:
Illustrate the layout for connecting
5 computers in a bus and a star topology of networks. All India 2015: Delhi 2015
Аnswer:

important-questions-for-class-12-computer-science-c-communication-technologies-(346-1)

Question 11:
What is a spam mail? Delhi 2015
Аnswer:

Spam Mail is flooding on the Internet with many copies of the same meaning, in an attempt to force the message on people who would not otherwise choose to receive it.

Question 12:
Differentiate between FTP and HTTP.  Delhi 2015
or
What is the difference between HTTP and FTP? All India 2013
Аnswer:

FTP is a protocol used to upload files from a workstation to a FTP server or download files from a FTP server to a workstation while, HTTP is a protocol used to transfer files from a Web server onto a browser in order to view a Web page that is on the Internet.

Question 13:
Out of the following, which is the fastest

  1. wired and
  2. wireless medium of communication? Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber.
    All India 2015: Delhi 2015

Аnswer:

  1. Wired-Optical Fiber
  2. Wireless-Infrared

Question 14:
What is Worm? How is it removed? Delhi 2015
Аnswer:

A computer worm is a stand alone malware computer program that replicates itself in order to spread to other computers.
Worms can be removed by installing antivirus.

Question 15:
Out of the following, which one comes under cyber crime?

  1. Stealing away a brand new computer from a showroom.
  2. Getting in someone’s social networking account without his consent and posting pictures on his behalf to harass him.
  3. Secretly copying files from’ server of a call center and selling it to the order organisation.
  4. Viewing sites on a internal browser. Delhi 2015

Аnswer:
(ii) Getting in someone’s social networking account without his consent and posting pictures on his behalf to harass him.

Question 16:
What kind of data gets stored in cookies and how is it useful? All India 2015
Аnswer:

Cookies contain random alphanumeric text characters, which are determined by the specific Website that created that cookie. It helps you to access a site faster and more efficiently.

Question 17:
Differentiate between packet switching over message switching. All India 2015
or
Differentiate between packet switching and message switching technique in network communication? Delhi 2011
Аnswer:

In message switching, large storage space is required at each node to buffer the complete message blocks. On the other hand in packet switching, messages are divided into subset of equal length, which are generated in the source node and reassembled to get back the initial complete message in destination node.

Question 18:
What is Trojan Horse? All India 2015
Аnswer:

Trojan Horse It is a type of malware designed to provide unauthorised, remote access to a user’s computer. Trojan horses do not have the ability to replicate themselves. They can lead to viruses being installed on a machine since they allow the computer to be controlled by the trojan creator.

Question 19:
Write one characteristic each for 2G and 3G mobile technologies. Delhi 2014
Аnswer:

Characteristic of 2G mobile technology is that it has introduced data services for mobile, starting with text messaging.
Characteristic of 3G mobile technology is that it is faster than 2G and supports video calling.

Question 20:
What is the difference between video conferencing and chat? Delhi 2014
Аnswer:

Chat generally involves one-to-one communication. On the other hand, video conferencing means more than two persons are involved in a discussion.

Question 21:
Expand the following:

  1. GPRS
  2. CDMA
  3. GSM Delhi 2014: All India 2014

or

Expand the following abbreviation:

  1. GSM
  2. CDMA Delhi 2009

Аnswer:

  1. GPRS General Packet Radio Services.
  2. CDMA Code Division Multiple Access.
  3. GSM Global System for Mobile Communication.

Question 22:
Write two characteristics of Wi-Fi.  All India 2014
Аnswer:

Characteristics of Wi-Fi are as follows:

  1. It is a wireless solution for getting connected to the Internet.
  2. It is handly as well as availably throughout the journey.

Question 23:
What is the difference between E-mail and chat? All India 2014; Delhi 2013C
Аnswer:

In order to chat, you need have an account on the same service as the person you are chatting with.
On the other hand, in case of e-mail, it is not necessary, i.e. you can have an account from any provider and you can establish your own.

Question 24:
Which type of network (out of LAN, PAN and MAN) is formed, when you connect two mobiles using bluetooth to transfer a picture file? Delhi 2014
or
Which type of network (out of LAN, PAN and MAN) is formed, when you connect two mobiles using bluetooth to transfer a video.  All India 2014
Аnswer:

When two mobiles are connected using bluetooth to transfer a picture file, a PAN (Personal Area Network) is created.

Question 25:
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. All India 2013

Аnswer:
(ii) Stealing keyboard and mouse from a shop.

Question 26:
What is the difference between domain name and IP address? Delhi 2013
Аnswer:

IP address is an identifier for a computer or device on a TCP/IP network, e.g. 1.160.10.240 could be an IP address. Whereas, a domain name is a name that identifies one or more IP addresses, e.g. the domain name microsoft.com represents about a dozen IP addresses.

Question 27:
Write two advantages of using an optical fibre cable over an Ethernet cable to connect two service stations, which are 190 m away from each other. Delhi 2013
or
Write two advantages of using an optical fibre cable over an Ethernet cable to connect two service stations, which are 190 —> 200 m away from each other.  All India 2013
Аnswer:

Two advantages of using optical fibre cable over an Ethernet cable are as follows:

  1. Low power because signals in optical fibres degrade less, low-power transmitters can be used.
  2. Digital Signals Optical fibres are ideally suited for carrying digital information, which is especially useful in computer networks.

Question 28:
What is the difference between packet switching and circuit switching techniques? All India 2013 (C)
Аnswer:

(i) circuit Switching In this, firstly complete
physical connection between two computers is established. After that data are transmitted from the source computer to the destination computer.
e.g. In telephone call, circuit switching is used.
Packet Switching In this, there is a fixed size of packet and data packets are stored in the main memory.
This improves the access time.

Question 29:
Expand the following abbreviations:
(a) HTTP (b) VoIP
All India 2013
Аnswer:

(a) HTTP: HyperText Transfer Protocol
(b) VoIP: Voice over Internet Protocol

Question 30:
Which of the following crime(s) is/are covered under cybercrime?

  1. Stealing brand new hard disk from a shop.
  2. Getting unknown person’s social networking account and start messaging on his behalf.
  3. Copying some important data from a computer without taking permission from the owner of the data. Delhi 2013

Аnswer:
(ii) Getting into unknown person’s social networking account and start messaging on this behalf.

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

  1. E-mail
  2. VoIP
  3. FTP Delhi: All India 2012

Аnswer:
(ii) VoIP

Read More

Chapter 7: Boolean Algebra | class 12th | Important question Computer Science

Chapter 7 – Boolean Algebra, Chapter important question Class 12, Computer Science

Boolean algebra is an algebra that deals with Boolean values((TRUE and FALSE) . Everyday
we have to make logic decisions: “Should I carry the book or not?” , “Should I watch TV or not?” etc. Each question will have two answers yes or no, true or false. In Boolean Algebra we use 1 for true and 0 for false which are known as truth values.

Truth table:
A truth table is composed of one column for each input variable (for example, A and B), and one final column for all of the possible results of the logical operation that the table is meant to represent (for example, A XOR B). Each row of the truth table therefore contains one possible configuration of the input variables (for instance, A = true B = false), and the result of the operation for those values.

Logical Operators:
In Algebraic function e use +,-,*,/ operator but in case of Logical Function or Compound statement we use AND,OR & NOT operator. Example: He prefers Computer Science NOT IP.
There are three Basic Logical Operator:
1. NOT
2. OR
3. AND

 NOT Operator—Operates on single variable. It gives the complement value of variable.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

 OR Operator –It is a binary operator and denotes logical Addition operation and is represented by ”+” symbol

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

 AND Operator – AND Operator performs logical multiplications and symbol is (.) dot.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Truth table:

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Basic Logic Gates
A logic gate is an physical device implementing a Boolean function, that is, it performs a logical operation on one or more logic inputs and produces a single logic output. Gates also called logic circuits.

Or

A gate is simply an electronic circuit which operates on one or more signals to produce an output signal. NOT gate (inverter):The output Q is true when the input A is NOT true, the output is the inverse of the input:

Q = NOT A
A NOT gate can only have one input. A NOT gate is also called an inverter.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

AND gate
The output Q is true if input A AND input B are both true: Q = A AND B An AND gate can have two or more inputs, its output is true if all inputs are true.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

OR gate
The output Q is true if input A OR input B is true (or both of them are true): Q = A OR B An OR gate can have two or more inputs, its output is true if at least one input is true.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Basic postulates of Boolean Algebra:
Boolean algebra consists of fundamental laws that are based on theorem of Boolean algebra. These fundamental laws are known as basic postulates of Boolean algebra. These postulates states basic relations in boolean algebra, that follow:
I If X != 0 then x=1 and If X!=1 then x=0
II OR relations(logical addition)

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Principal of Duality
This principal states that we can derive a Boolean relation from another Boolean relation by performing simple steps. The steps are:-
1. Change each AND(.) with an OR(+) sign
2. Change each OR(+) with an AND(.) sign
3. Replace each 0 with 1 and each 1 with 0
e.g
0+0=0 then dual is 1.1=1
1+0=1 then dual is 0.1=0

Basic theorem of Boolean algebra
Basic postulates of Boolean algebra are used to define basic theorems of Boolean algebra that provides all the tools necessary for manipulating Boolean expression.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Some other rules of Boolean algebra
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Derivation of Boolean expression:-
 

Minterm :
minterm is a Product of all the literals within the logic System.
Step involved in minterm expansion of Expression
1. First convert the given expression in sum of product form.
2. In each term is any variable is missing(e.g. in the following example Y is missing in first term and X is missing in second term), multiply that term with (missing term +complement( missing term) )factor e.g. if Y is missing multiply with Y+Y” )
3. Expand the expression .
4. Remove all duplicate terms and we will have minterm form of an expression.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Other procedure for expansion could be
1. Write down all the terms
2. Put X‟s where letters much be inserted to convert the term to a product term
3. Use all combination of X‟s in each term to generate minterms
4. Drop out duplicate terms
 

Shorthand Minterm notation:
Since all the letters must appear in every product, a shorthand notation has been developed that saves actually writing down the letters themselves. To form this notation, following steps are to be followed:
1. First of all, Copy original terms
2. Substitute 0s for barred letters and 1s for nonbarred letters
3. Express the decimal equivalent of binary word as a subscript of m.
Rule1. Find Binary equivalent of decimal subscript e.g.,for m6 subscript is 6, binary equivalent of 6 is 110.
Rule 2. For every 1s write the variable as it is and for 0s write variables complemented form i.e., for 110 t is XYZ. XYZ is the required minterm for m6.
 

maxterm:
A maxterm is a sum of all the literals (with or without the bar) within the logic system. Boolean Expression composed entirely either of Minterms or Maxterms is referred to as Canonical Expression.
 

Canonical Form:
Canonical expression can be represented is derived from
(i) Sum-of-Products(SOP) form
(ii) Product-of-sums(POS) form

Sum of Product (SOP)
1. Various possible input values
2. The desired output values for each of the input combinations

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Product of Sum (POS)
When a Boolean expression is represented purely as product of Maxterms, it is said to be in Canonical Product-of-Sum from of expression.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Minimization of Boolean expressions:-
After obtaining SOP and POS expressions, the next step is to simplify the Boolean expression.
There are two methods of simplification of Boolean expressions.
1. Algebraic Method
2. Karnaugh Map :

1.Algebraic method:This method makes use of Boolean postulates, rules and theorems to simplify the
expression.
Example No. 1: Reduce the expression

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

2. Using Karnaugh Map :
Karnaugh Maps:
Karnaugh map or K Map is a graphical display of the fundamental product in a truth table.
For example:

  •  Put a 1 in the box for any minterm that appears in the SOP expansion.
  •  Basic idea is to cover the largest adjacent blocks you can whose side length is some power of 2.
  •  Blocks can “wrap around” the edges.
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Remember, group together adjacent cells of 1s, to form largest possible rectangles of sizes that are  powers of 2. Notice that you can overlap the blocks if necessary.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

For reducing the expression first mark Octet, Quad, Pair then single.
• Pair: Two adjacent 1’s makes a pair.
• Quad: Four adjacent 1’s makes a quad.
• Octet: Eight adjacent 1’s makes an Octet.
• Pair removes one variable.
• Quad removes two variables.
• Octet removes three variables.
Reduction of expression: When moving vertically or horizontally in pair or a quad or an octet it can be observed that only one variable gets changed that can be eliminated directly in the expression. For Example

In the above Ex

Step 1 : In K Map while moving from m7 to m15 the variable A is changing its state Hence it can be removed directly, the solution becomes B.CD = BCD. This can be continued for all the pairs, Quads, and Octets.

Step 2 : In K map while moving from m0 to m8 and m2 to m10 the variable A is changing its state. Hence B’ can be taken similarly while moving from m0 to m2 and m8 to m10 the variable C is changing its state. Hence D’ can be taken; the solution becomes B’.D’ The solution for above expression using K map is BCD + B’D’.

Example1: Reduce the following Boolean expression using K-Map:
F(P,Q,R,S)=Σ(0,3,5,6,7,11,12,15)

Soln:
This is 1 quad, 2pairs & 2 lock
Quad(m3+m7+m15+m11) reduces to RS
Pair(m5+m7) reduces to P‟QS
Pair (m7+m6) reduces to P‟QR
Block m0=P‟Q‟R‟S‟
M12=PQR‟S‟
hence the final expressions is F=RS + P‟QS + P‟QR + PQR‟S‟ + P‟Q‟R‟S‟

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Example2: Reduce the following Boolean expression using K-Map:
F(A,B,C,D)=Π(0,1,3,5,6,7,10,14,15)

Soln:
Reduced expressions are as follows:
For pair 1, (A+B+C)
For pair 2, (A‟+C‟+D)
For Quad 1, (A+D‟)
For Quad 2, (B‟+C‟)
Hence final POS expression will be

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

More about Gates:
NAND gate (NAND = Not AND)
This is an AND gate with the output inverted, as shown by the ‘o’ on the output. The output is true if input A AND input B are NOT both true: Q = NOT (A AND B) A NAND gate can have two or more inputs, its output is true if NOT all inputs are true.
NOR gate (NOR = Not OR)
This is an OR gate with the output inverted, as shown by the ‘o’ on the output. The output Q is true if NOT inputs A OR B are true: Q = NOT (A OR B) A NOR gate can have two or more inputs, its output is true if no inputs are true.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

EX-OR (EXclusive-OR) gate
The output Q is true if either input A is true OR input B is true, but not when both of them are true: Q = (A AND NOT B) OR (B AND NOT A) This is like an OR gate but excluding both inputs being true. The output is true if inputs A and B are DIFFERENT. EX-OR gates can only have 2 inputs.
EX-NOR (EXclusive-NOR) gate
This is an EX-OR gate with the output inverted, as shown by the ‘o’ on the output. The output Q is true if inputs A and B are the SAME (both true or both false):

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Q = (A AND B) OR (NOT A AND NOT B) EX-NOR gates can only have 2 inputs.
Summary truth tables
The summary truth tables below show the output states for all types of 2-input and 3-input gates.

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

NAND gate equivalents
The table below shows the NAND gate equivalents of NOT, AND, OR and NOR gates:

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Low Order Thinking Questions: (Boolean Algebra)
a) State and verify absorption law in Boolean algebra.
Ans. Absorption Law states that :
a) X+XY=X b) X(X+Y)=X
b) Verify X’.Y+X.Y’=(X’+Y’).(X+Y) algebraically.
Ans. LHS= X’Y + XY’
= (X’+X) (X’+Y’) (Y+X) (Y+Y’)
= 1.(X’+Y’) (X+Y).1
= (X’+Y’) (X+Y)
= RHS, hence proved
c) Write the equivalent Boolean Expression F for the following circuit diagram :

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Ans.: A’B+AB+B’C
d) If F(P,Q,R,S) = Π (3,4,5,6,7,13,15) , obtain the simplified form using K-Map.
Ans.:

Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Reduction of groups following the reduction rule :
Quad1 = M4.M5.M6.M7
= P+Q’
Quad2 = M5.M7.M13.M15
= Q’+S’
Pair = M3.M7
= P+R’+S’
Therefore POS of F(P,Q,R,S) = (P+Q’)(Q’+S’)(P+R’+S’)
e) F(a,b,c,d)=Σ(0,2,4,5,7,8,10,12,13,15)
F(a,b,c,d)=B1+B2+B3
B1=m0+m4+m12+m8==c’d’
B2=m5+m7+m13+m15=bd
B3=m0+m2+m8+m10=b’d’
F(a,b,c,d)=c’d’+bd+b’d’
f) Write the equivalent Boolean expression for the following logic circuit:
Chapter 7 - Boolean Algebra, Chapter Notes, Class 12, Computer Science

Read More

Chapter 6: Database & SQL | class 12th | Important question Computer Science

Important Questions for Class 12 Computer Science (C++) – Database Concepts


2 Marks Questions

Question 1:
Observe the following table MEMBER carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown in RESULT. Also, find the Degree and Cardinality of the RESULT: All India 2017

Answer:
RDBMS Operation → SELECTION
Degree of table RESULT = 3
Cardinality of table RESULT = 1

Question 2:
Observe the following PARTICIPANTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in RESULT? Also, find the Degree and Cardinality of the RESULT. All India 2016

Answer:
RDBMS Operation → Cartesian Product
Degree → 4, Cardinality → 6

Question 3:
Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in LIST. Also, find the Degree and Cardinality of the LIST. Delhi 2016

Answer:
RDBMS Operation → Cartesian Product
Degree → 4, Cardinalitv → 6

Question 4:
Observe the following table carefully and write the names of the most appropriate columns, which can be considered as
(i) Candidate keys and (ii) Primary key. Delhi 2015
Important Questions for Class 12 Computer Science (C++) - Database Concepts-4
Answer:
(i) Candidate Keys → Id, Product
(ii) Primary Key → Id

Question 5:
Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) Candidate keys and (ii) Primary key: All India 2015

Answer:
(i) Candidate Keys → Code, Item
(ii) Primary Key → Code

Question 6:
Observe the following table carefully and find the degree and cardinality of the table : All India 2018 (C)

Answer:
Degree → 3, Cardinality → 5

Question 7:
Observe the following table and answer the parts (i) and (ii): All India 2014 (C)

(i) In the above table, can we have Qty as primary key? [Answer as yes/no]. Justify your answer.
(ii) What is the cardinality and degree of the above table?
Answer:
(i) No, Qty cannot have as primary key because it is not uniquely identify in a table.
(ii) Cardinality → 5, Degree → 4

Question 8:
Explain the concept of Cartesian Product between two tables, with the help of appropriate example. All India 2014

Or

Illustrate cartesian product operation between the two tables/relations using a suitable example. Delhi 2012 (C)
Answer:
Cartesian Product The cartesian product means the cross join of two relations and the resultant relation will contain all the possible combinations of the tuples from the two tables, i.e. the cardinality of the resulting relation will be equal to the product of cardinalities of the two relations. It is denoted by ‘x’ symbol.
The two tables GABS1 and GABS2 are as follows:

The cartesian product of above two tables is as follows:

Question 9:
Explain the concept of candidate keys with the help of an appropriate example. All India 2013

Or

What do you understand by candidate key in a table? Give a suitable example of candidate key from a table containing some meaningful data. Delhi 2010.2009
Answer:
A candidate key is a set of one or more attributes that uniquely identify in a table. There can be multiple candidate keys in one table. Each candidate key can work as a primary key.

Question 10:
What is the difference between degree and cardinality of a table? What is the degree and cardinality of the following table?
Delhi 2013

Answer:
Degree The number of attributes or columns in a table is called the degree of the table. The degree of the given table is : 3.
Cardinality The number of rows or records in a table is called ,the cardinality of the table. The cardinality of the given table is : 2.

Question 11:
Differentiate between the primary key and alternate key of a table with the help of an example. Delhi 2013C

Or

Give a suitable example of a table with sample data and illustrate primary and alternate keys in it. All India 2012.2011; Delhi 2011 (c)
Answer:
Primary Key It’s a column or set of columns that helps to identify records uniquely. One table can have only one primary key.
Alternate Key/Secondary Key It’s a column or set of columns that can act as a primary key but not selected as a primary key.
\
e.g. In table Student, RollNo and AdmNo of all students are different.
Both of them can be selected as primary key. Suppose we have selected RollNo as a primary key then AdmNo is called as alternate key.

Question 12:
Give suitable example of a table with sample data and illustrate primary and candidate keys in it. Delhi 2012
Answer:
The table student is as follows:


Here, AdmNo and RollNo both can identify records uniquely. So, both are candidate keys, and from them we can also make AdmNo as a primary key.

Question 13:
What do you mean by union and cartesian product operation in relational algebra? Delhi 2011
Answer:
Union (binary operator) It operates on two relations and is indicated by ‘∪’.
Cartesian Product (binary operator) It operates on two relations and is denoted by ‘×’. e.g. cartesian product of two relations R1 and R2 is represented by R = R1 x R2. The degree of R is equal to sum of degrees of R1 and R2. The cardinality of R is product of cardinality of R1 and cardinality of R2.
e.g. R = R1 ∪ R2 represents union operation between two relations R1 and R2. The degree of R is equal to degree of R1. The cardinality of R is sum of cardinality of R1 and cardinality of R2.

Question 14:
What do you understand by selection and projection operation in relational algebra? All India 2011
Answer:

Question 15:
What do you understand by primary key? Give a suitable example of primary key from a table containing some meaningful data. All India 2010
Answer:
A primary key is a set of one or more attributes that can uniquely identify tuples within the relation.
e-g.

The attribute ItemNo is a primary key as it contains unique value for each tuple in a relation.

Question 16:
What is the purpose of a key in a table? Give an example of a key in a table. All India 2009
Answer:
A key is used to identify a tuple uniquely within the relation. The value of key is unique. No rows in the relation can have same value, e.g. in an Employee relation EmpCode is a key, using EmpCode one can obtain the information of a particular employee.

Read More

Chapter 5: Data Structures | class 12th | Important question Computer Science

Important Questions for Class 12 Computer Science – Data Structure

Topic – 1
Data Structure and One-Dimensional Array
Previous years Examination Questions
2 Marks Questions

Question 1:
Write the definition of a function AddUp(int Arr[ ], int N) in C++, in which all even positions (i.e. 0,2,4 ) of the array should be added with the content of the element in the next position and odd positions (i.e. 1,3,5, ) elements should be incremented by 10. All India 2017

NOTE

  • The function should only alter the content in the same array.
  • The function should not copy the altered content in another array.
  • The function should not display the altered content of the array.
  • Assuming, the Number of elements in the array are Even.

Аnswer:

void AddUp(int Arr[], int N)
{
for(int i=0;i<N;i++)
{
if(i%2==0)
Arr[i] += Arr[i+1]; 
else
Arr[i] += 10;
}
}

Question 2:
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:

Аnswer:

void FixPay(float Pay[], int N)
{
for(int i=0;i<=N—1;i++)
{
if(Pay[i]<100000)
Pay[i] = Pay[i]+(Pay[i]*25)/100; 
else if(Pay[i]>=100000 && Pay[i]<200000)
Pay[i] = Pay[i]+(Pay[i]*20)/100; 
else
Pay[i] = Pay[i]+(Pay[i]*15)/100;
}
}

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

Аnswer:

void FixSalary(float Salary[], int N)
{
for(int i=0;i<=N—1;i++)
{
if(Salary[i]<100000)
Salary[i]=Salary[i]+(Salary[i]*35)/100; 
else if(Salary[i]>=100000 && Salary[i]<200000) 
Salary[i]=Salary[i]+(Salary[i]*30)/100; 
else
Salary[i]=Salary[i]+(Salary[i]*20)/100;
}
}

Question 4:
Write the definition of a function Alter (int A[ ], int N) in C++, which should change all the multiples of 5 in the array to 5 and rest of the elements as 0. e.g. if an array of 10 integers is as follows:
important-questions-class-12-computer-science-c-data-structure-(195-1)
Аnswer:

void Alter(int A[], int N)
{
for(int i=0;i<10;i++)
{
if(A[i]%5==0)
A[i]=5; 
else 
A[i]=0;
}
}

Question 5:
Write the definition of a function Changeant P[ ], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1.  All India 2015

Аnswer:

void Change(int P[], int N)
{
for (int i=0;i<N;i++)
{
if (P[i]%10 == 0)
P[i] = 10; 
else
P[i] = 1;
}
}

Question 6:
Write the definition of a function Modify(int A[ ], int N) in C++, which should reposition the content after swapping each adjacent pair of numbers in it.
[NOTE Assuming the size of array is multiple of 4]

Аnswer:

void Modify(int A[], int N) 
{
for(int i=0;i<N;i++)
{
int temp = A[i];
A[i] = A[i+2];
A[i+2] = temp; 
if(i%4>=1)
i = i+2;
}
}

Question 7:
Write code for a function void oddEven(int S[ ], int N) in C++, to add 5 in all the odd values and 10 in all the even values of the array S.

Аnswer:

void oddEven(int S[],int N)
{
for(int i=0;i<N;i++)
{
if(S[i]%2 == 0)
S[i] += 10; 
else
S[i]+=5;
}
}

Question 8:
Write code for a function void EvenOdd (int T [ ], int C) in C++, to add 1 in all the odd values and 2 in all the even values of the array T.


Аnswer:

void EvenOdd(int T[],int C)
{
for(int i=0;i<C;i++)
{
if(T[i]%2 == 0)
T[i] += 2; 
else
T[i] += 1;
}
}

Question 9:
Write a function in C++ TWOTOONE( ) which accepts two array X[ ], Y[ ] and their size n as argument. Both the arrays X[ ] and Y[ ] have the same number of elements. Transfer the content from two arrays X[ ], Y[ ] to array Z[ ]. The even places (0,2,4….) of array Z[ ] should get the contents from the array X[ ] and odd places (1,3,5…) of array Z[ ] should get the contents from the array Y[ ].
Example: If the X[ ] array contains 30,60,90 and the Y[ ] array contains
10.20.50. Then Z[ ] should contain
30.10.60.20.90.50. All India 2014
Аnswer:

void TW0T00NE(int X[], int Y[], int n) 
{
int Z[40], i,j=0,k=0; 
for(i=0;i<(n+n);i++)
{
if(i%2 == 0)
{
Z[i] = X[j]; 
j++;
}
else
{
Z[i] = Y[k]; 
k++;
}
}
}

Question 10:
Write code for a function void Convert (int T[ ], int Num) in C++, which repositions all the elements of the array by shifting each of them one to one position before and by shifting the first element to the last position.

Аnswer:

void Convert(int T[], int Num)
{
int temp = T[0]; 
for(int i=0;i<(Num-1);i++)
{
T[i]=T[i+l];
}
T[i]= temp; 
}

Question 11:
Write code for a function void ChangeOver(int P[ ], int N) in C++, which re-positions all the elements of the array by shifting each of them to the next position and by shifting the last element to the first position.

Аnswer:

void ChangeOver(int P[],int N)
{
int temp;
for(int i=0;i<(N-1);i++)
{
temp = P[N-1];
P[N-1] = P[i];
P[i] = temp;
} 
}

Question 12:
Write the definition for a function void Transfer (int A[6], int B[6]) in C++, which takes two integer arrays, each containing 6 elements as parameters. The function should exchange all odd places (i.e. 3rd and 5th) of the two arrays.

Аnswer:

void Transfer(int A[6],int B[6]) 
{
int i,temp;
for(i=1;i<=5;i=i+2)
{
temp = A[i];
A[i] = B[i];
B[i] = temp;
}
}

Question 13:
Write a function SWAP2CHANGE(int p[ ], int N) in C++ to modify the content of the array in such a way that the elements, which are multiples of 10 swap with the value present in the very next position in the array.
e.g. If the content of array p is
91, 50, 54, 22, 30, 54
The content of array p should become
91, 54, 50, 22, 54, 30
Аnswer:

void SWAP2CHANGE(int p[],int N)
{ 
int C,i;
for(i=0;i<=N-2;i++)
{
if(p[i]%10 == 0)
{
C = p[i]; 
p[i] = p[i+1];
p[i+1] = C; 
i++:
}
}
}

Question 14:
Write a function SWAP2BEST(int ARR[ ], int Size) in C++ to modify the content of the array in such a way that the elements, which are multiples of 10 swap with the value present in the very next position in the array.
e.g. If the contents of array ARR are
90, 56, 45, 20, 34, 54
The contents of array should become
56, 90, 45, 34, 20, 54  All India 2012
Аnswer:

void SWAP2BEST(int ARR[], int Size) 
{
int i,C;
for(i=0;i<=Size-2;i++)
{
if(ARR[i]%10==0)
{
C=ARR[i];
ARR[i] = ARR[i+1];
ARR[i+1] = C; 
i++;
}
}
}

Question 15:
Write a Get2From1( ) function in C++ to transfer the content from one array ALL[ ] to two arrays Odd[ ] and Even[ ]. The Even[ ] array should contain the values from places(0, 2, 4, …) of array ALL[ ] and Odd[ ] array should contain the values from odd position like (1, 3, 5, …).
e.g. The ALL[ ] array should contain 30,10, 60, 50, 90, 80
If the Even[ ] array contains 30, 60, 90
and the Odd[ ] array contains
10, 50, 80 All India 2011
Аnswer:

void Get2From1(int ALL[], int N)
{ 
int p,q,i,j=0,k=0; 
if(N%2 == 0)
{
p = N/2; 
q = N/2;
}
else
{
p = N/2; 
q = ((N/2)+l); 
}
int *0dd = new int[p]; 
int *Even = new int[q]; 
for(i=0;i<(N);i++)
{
if(i%2 == 0)
Even[j++]=ALL[i]; 
else
Odd[k++]=ALL[i];
}
}

Question 16:
Write a function CHANGE( ) in C++, which accepts an array of integer and its size as parameters and divide all those array elements by 7, which are divisible by 7 and multiply other array elements by 3.

Аnswer:

void CHANGE(int A[],int N) 
{
for(int i=0;i<N;i++)
if(A[i]%7 == 0)
A[i]=A[i]/7; 
else 
}
A[i] = A[i]*3;
}
}

Question 17:
Write a function REASSIGN( ) in C++, which accepts an array of integer and its size as parameters and divide all those array elements by 5, which are divisible by 5 and multiply other array elements by 2.
Аnswer:

void REASSIGN(int A[],int N)
{
for(int i=0;i<N;i++)
{
1f(A[i]%5 == 0)
A[i] = A[i]/5; 
else
A[i] = A[i]*2;
}
}

Question 18:
Write a function SORTPOINTS( ) in C++ to sort an array of structure Game in descending order points using bubble sort.
NOTE Assume the following definition of structure Game.

struct Game 
{
long PNo; //Player Number 
char PName[20]; 
long Points;
}


Аnswer:

void SORTPOINTS(struct Game G[], int n)
{
int i, j; 
struct Game t; 
for(i=1;i<n;i++)
{
for(j=0;j<=n-i-1;j++)
{
if(G[j+1].Points>G[j].Points) 
{
t = G[j];
G[j] = G[j+1]:
G[j+1] = t;
}
}
}
}

Question 19:
Write a function SORTSCORE( ) in C++to sort an array of structure. Examinee in descending order of Score using bubble sort.
NOTE Assume the following definition of structure Examinee.

struct Examinee
{
long Roll No; 
char Name[20]; 
float Score;
};


Аnswer:

void SORTSCORE(struct Examinee ex[],int n) 
{
int i,j;
struct Examinee t; 
for(i=1;i<n;i++)
{
for(j=0;j<=n-i-1;j++)
{ 
if(ex[j+1].Score>ex[j].Score)
{
t = ex[j]; 
ex[j] = ex[j+1]; 
ex[j+1] = t;
   }
  }
 }
}

Topic – 2
Two-Dimensional Array
2/3 Marks Questions

Question 1:
Write a definition for a function SUMMIDCOLfint MATRIX[ ][10], int N, int M) in C++, which finds the sum of the middle column’s elements of the MATRIX (Assuming N represents number of rows and M represents number of columns, which is an odd integer). All India 2017
Example: If the content of array MATRIX having N as 5 and M as 3 is as follows:

The function should calculate the sum and display the following:
Sum of Middle Column : 15
Аnswer:

void SUMMIDCOL(int MATRIX[][10],int N,int M)
{
int j, SUM=0;
j=M/2;
for(int i=0;i<N;i++)
SUM += MATRIX[i][j]; 
cout<<"SUM of Middle Column:"<<SUM;
}

Question 2:
ARR[15][20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[5][15], if the element ARR[10][5] is stored at the memory location 35000.
All India 2017
Аnswer:

B = 35000, W = 4 bytes, R=15, C=20, Lr=10, Lc=5, I=5, J=15
For row-wise allocation,
Address of ARR[I][J] = B+W[C(I-Lr)+(J-Lc)]
ARR[5][15] = 35000+4[20(5-10)+(15-5)] 
= 35000+4[20(-5)+10]
= 35000+4[-100+10]
= 35000+4[-90]
= 35000-360 
= 34640

Question 3:
Write definition for a function DISPMID (int A[ ] [5], int R, int C) in C++ to display the elements of middle row and middle column from two dimensional array A having R number of rows and C number of columns.

Аnswer:

void DISPMID(int A[][5], int R, int C) 
{
int i; 
i=R/2;
for(int j=0;j<C;j++) 
cout<<A[i][j]<<'\t'; 
count<<endl; 
i=C/2;
for(j=0;j<R;j++) 
cout<<A[j][i]<<'\t';
}

Question 4:
R[10][50] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 8 bytes, find the address of the element R[5][15], if the element R[8] [10] is stored at the memory location 45,000. All India 2016
Аnswer:

B = 45000, R = 10, C = 50. W = 8 bytes, Lr = 8, Lc = 10, I = 5, J = 15
For row-wise allocation,
R[I][J] = B + W[C(I-Lr)+(J-Lc)]
R[5][15] = 45000 + 8[50(5-8)+(15-10)]
= 45000 + 8[50x(-3)+5]
= 45000 + 8[-150+5]
= 45000 - 1160 
= 43840

Question 5:
Write definition for a function SHOWMID(int P[ ][5], int R, int C) in C++ to display the elements of middle row and middle column from a two dimensional array P having R number of rows and C number of columns, e.g. if the content of array is as follows:

The function should display the following as output:
103 101 121 102 101
116 121 109 Delhi 2016
Аnswer:

void SHOWMID(int P[][5], int R, int C)
{
int i,j; 
i=R/2;
for(j=0;j<C;j++) 
cout<<P[i][j]<<'\t';
Cout<<endl;
i=C/2;
for(j-0;j<R;j++) 
cout<<P[j][i]<<'\t';
}

Question 6:
T[20] [50] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element T[15][5], if the element T[10][8] is stored at the memory location 52000. Delhi 2016
Аnswer:

B = 52000, R = 20, Ir= 10, C = 50 Ic = 8, W = 4bytes, I = 15, J = 5 
For row-wise allocation,
T[I][J] = B+W[C(I-Lr)+(J-Lc)] 
T[15][5] = 52000 + 4[50(15-10)+(5-8)]
= 52000 + 4[50x5+(-3)]
= 52000 + 4[250-3]
= 52000 + 4 x 247 
= 52000 + 988 
= 52988

Question 7:
Write definition for a function SHOWMID(int P[ ][5], int R, int C) in C++ to display the elements of first, third and fifth column ffom a two dimensional array P having R number of rows and C number of columns.
For example, if the content of array is as follows:


Аnswer:

void SHOWMID(int P[][5], int R.int C) 
{
int i,j;
for(j=0;j<C;j+=2) 
{
cout<<endl;
for(i=0;i<R;i++)
{
cout<<P[1][j]<" ";
}
}
}

Question 8:
Write a function REVROW (int P[ ][5], int N, int M) in C++ to display the content of a two dimensio) al array, with each row content in reverse order. All India 2015

Аnswer:

void REVR0W(int P[][5], int N, int M)
{
for(int i=0;i<N;i++)
{
int x=M-1; 
for(int j=0;j<M;j++)
{ 
if(J<x)
{
int t = P[i][j];
P[i][j] = P[i][x];
P[i][x]= t; 
x--;
}
}
}
for(i=0;i<N;i++)
{
for(int j=0;j<M;j++)
cout<<P[i][j]<<""; 
cout<<endl;
}
}

Question 9:
A two dimensional array ARR[50] [20] is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[30][10], if the element ARR[10][5] is stored at the memory location 15000.
All India 2015
Аnswer:

B = 15000, R = 50, C = 20,W = 4 bytes, Lr = 10. Lc = 5, I = 30, J = 10 
For row-wise allocation,
ARR[I][J] = B + W[C(I-Lr)+(J-Lc)]
= 15000 + 4[20(30-10)+(10-5)]
= 15000 + 4[20x20+5]
= 15000 + 4[405]
= 15000 + 1620 
= 16620

Question 10:
Write a function REVCOL (int P[ ][5], int N, int M) in C++ to display the content of a two dimensional array, with each column content in reverse order. Delhi 2015
NOTE Array may contain any number of rows.

Аnswer:

void REVCO(int P[][5], int N, int M)
{
for(int i=0;i<M;i++) 
{
int X=N—1;  
for(int j=0;j<N;j++)
{
if(j<X)
{
int t = P[j][i];
P[j][i] = P[X][i];
P[X][i] = t;
X--;
}
}
}
for(i=0;i<N;i++)
}
for(int j=0;j<M;j++) 
cout<<p[i][j]<<""; 
cout<<endl;
}
}

Question 11:
A two dimensional array P[20][50] is stored in the memory along the row with each of its element occupying 4 bytes. Find the address of the element P[10][30], if the element P[5][5] is stored at the memory.
Аnswer:

B=15000 R=20 C=50 W=4 bytes Lr=5, Lc=5, I=10, J=30 
For row-wise allocation,
P[I][J] = B + W[C(I-Lr)+(J-Lc)] P[10][30]
= 15000 + 4[50(10-5)+(30-5)] 
= 15000 + 4[50(5)+25]
= 15000 + 4[250 + 25]
= 15000 + 4 x 275 
= 15000 + 1100 
= 16100

Question 12:
Write a function ADDDIAG (int A[ ][5], int N, int M) in C++ to display sum of the content, which at the diagonals of a two dimensional array.
[NOTE: Assume the array to be of even dimension such as 2×2,4×4, 6×6 etc.]

Аnswer:

void ADDDIAG(int A[][5],int N, int M)
{
int sum = 0;
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{
if(i == j) 
sum = sum + A[i][j]; 
else if(j == M-i-1) 
sum = sum + A[i][j];
}
}
cout<<sum;
}

Question 13:
Write a user-defined function SumLast3 (int A[ ][4],int N,int M) in C++ to find and display the sum of all the values, which are ending with 3 (i.e. unit place is 3).

Аnswer:

void SumLast3(int A[][4],int N.int M) 
{
int sum=0;
for(int r=0;r<N;r++)
{
for(int c=0;c<M;c++)
{
int rem = A[r][c]%10; 
if(rem == 3) 
sum += A[r][c];
}
}
cout<<sum; 
}

Question 14:
Write a user-defined function AddEnd2(int A[ ] [4], int N, int M) in C++ to find and display the sum of all the values, which are ending with 2 (i.e. unit place is 2).

Аnswer:

void AddEnd2(int A[][4],int N.int M)
{
int sum = 0; 
for(int i=0;i<N;i++)
{  
for(int j=0;j<M;j++)
{
if(A[i][j]%10 == 2)
sum += A[i][j];
}
}
cout<<sum;
}

Question 15:
An array T[25] [20] is stored along the row in the memory with each element requiring 2 bytes of storage. If the base address of array T is 42000, find out the location of T[10][15]. Also, find the total number of elements present in this array. Delhi 2014
Аnswer:

B = 42000 U = 2 bytes, C = 20, R = 25, Lr =0, Lc = 0, I = 10, J = 15
For row-wise allocation,
Address of
T[I][J] = B + W[C(I-Lr)+(J-Lc)] 
T[10][15] = 42000 + 2[20(10-0)+(15-0)]
= 42000 + 2[20 x 10 + 15]
= 42000 + 2[200 + 15]
= 42000+215x2 
= 42000+430 
= 42430
Total number of elements present in this array = R x C = 25x20 = 500

Question 16:
An array A[20][30] is stored along the row in the memory with each element requiring 4 bytes of storage. If the base address of array A is 32000, find out the location of A[15][10]. Also, find the total number of elements present in this array. All India 2014
Аnswer:

B = 32000, W = 4 bytes, R = 20, C = 30, Lr = 0 Lc = 0, I = 15, J = 10 
For row-wise allocation,
Address of
A[I][J] = B + W[C(I-Lr)+(J-Lc)]
A[15][10] = 32000 + 4[30(15-0)+(10-0)] 
= 32000+C(15x301+10] x 4 
= 32000 + [460 x 4]
= 32000+1840
= 33840 
Total number of elements present in this array = R x C = 20 x 30 = 600

Question 17:
Write a function in C++ which accepts a 2D array of integers and its size arguments and displays the elements which lie on minor diagonal. [Top right to bottom left diagonal]
[Assuming the 2D array to be square matrix with odd dimension i.e. 3×3, 5×5, 7×7, etc….] All India (C) 2014
For example,

Аnswer:

void MinorDiagonal(int A[][10], int M, int N)
{
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
if(j==N—i—1)
{
cout<<A[i][j]<<endl;
}
}
}
}

Question 18:
Write a user-defined function DispTen(int A[ ][4], int N, int M) in C++ to find and display all the numbers, which are divisible by 10.

Аnswer:

void DispTen(int A[][4], int N, int M) 
{
int i,j;
for(i=0;i<N;i++) 
for(j=0;j<M;j++)
if(A[i][j]%10 == 0)
cout<<A[i][j]<<" ";
}

Question 19:
Write a user-defined function DispNTen(int L[ ][4], int R, int C) in C++ to find and display all the numbers, which are not divisible by 10.

Аnswer:

void DispNTen(int L[][4],int R,int C) 
{
int i,j;
for(i=0;i<R;i++) 
for(j=0;j<C;j++) 
if(L[i][j]%10 != 0) 
cout<<L[i][j]<<" "; 
}

Question 20:
Write a user-defined function int SumSingle(int A[4] [4]) in C++, which finds and returns the sum of all numbers present in the first row of the array.

Then, the function should return 33.
Аnswer:

int SumSingle(int A[4][4])
{
int Sum = 0; 
for(int j=0;j<=3;j++)
{
Sum = Sum + A[0][j];
}
return Sum;
}
Read More

Chapter 4: Pointers | class 12th | Important question Computer Science

Important Questions for Class 12 Computer Science – Pointers

Question 1:
Obtain the output from the following C++ program as expected to appear on the screen after its execution. Delhi 2014
Important Note:
All 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[]={l,5,7,9};
Ptr=A; 
cout<<*Ptr<<String<<endl;
String++;
Ptr+=3;
cout<<*Ptr<<String<<endl;
}

Аnswer:
Output of the given program will be
1SARGAM
9ARGAM

Question 2:
Obtain the output from the following C+ + program as expected to appear on the screen after its execution. All India 2014.2013
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[] = {11,5,7,9};
P = Num;
cout<<*P<<Text<<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}

Аnswer:
Output of the given program will be
1AJANTA
5JANTA

Question 3:
Observe the following C+ + code carefully and obtain the output, which will appear on the screen after execution of it.
Delhi 2013
Important Note:

All the desired 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:
Output of the given program will be
10SHAKTI
15HAKTI

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

void main()
{
float *Ptr,Points[] = {120,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:
Output of the given program will be
20
32.5
42.5

Question 5:
Find the output of the following program: All India 2012

#include<iostream.h> 
#include<conio.h>
#include<ctype.h> 
typedef char Str80[80]; 
void main() 
{
char *Notes;
Str80 Str="vR.zGooD";
int L=6;
Notes = Str; 
while(L>=3)
{
Str[L]=isupper(Str[L])?
tolower(Str[L]); 
toupper(Str[L]); 
cout<<Notes<<endl;
L--;
Notes++; 
getch();
}
}

Аnswer:
Output of the given program will be
vR.zGoOd
R.zGOOD
.zgOOD
ZgOOD

Question 6:
Find the output of the following program: Delhi 2012

#include<iostream.h> 
#include<conio.h>
#include<ctype.h> 
typedef char Txt80[80]; 
void main()
{
char *PText; 
Txt80 Txt="Ur2GReAt"; 
int N=6;
PText=Txt:
while(N>=3)
{
Txt[N]=isupper(Txt[N])? 
tolower(Txt[N]);
toupper(Txt[N]); 
cout<<PText<<endl;
N--;
PText++;
}
}

Аnswer:
Output of the given program will be
Ur2GReat
r2GREat
2GrEat
grEat

Question 7:
In the following program, what will be the possible output(s) from the following options (i), (ii), (iii) and (iv)? Justify your answer. Delhi 2011C

#include<iostream.h> 
#include<stdlib.h> 
#include<string.h> 
#include<conio.h> 
void main()
{
clrscr();
char *Text="1234"; 
int L=strlen(Text);
randomize(); 
for(int I=0;I<L;I++)
{
int Start=random(I)+1; 
char P=Text[Start]; 
cout<<P<<":";
}
getch();
}
(i) 1:3:2:4: 
(ii) 2:2:3:2:
(iii) 2:2:4:4: 
(iv) 2:2:2:3:

Аnswer:
The possible output will be (ii) 2:2:3:2: and (iv) 2:2:2:3:

Question 8:
Find the output of the following program : Delhi 2011

#include<iostream.h>
#include<conio.h> 
void main()
{
int Track[] = {10, 25, 30, 55},*Striker; 
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"<<*Striker[0]<<endl;
}

Аnswer:
There is an error in last line, i.e. *Striker[0], so the program will not run. In case, if there is no subscript in Striker pointer, then the output would be
Striker10
Next@55
Last@55
Rest To55

Question 9:
Find the output of the following program: All India 2011

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

Аnswer:
There is an error in last line, i.e. *Moves[0], so the program will not run. In case, if there is no subscript in Moves pointer, then the output would be
Queen @11
Now@55
Finally@44
New 0rigin@0

Question 10:
Find the output of the following program:

#include<iostream.h> 
#include<conio.h> 
void main()
{
int Numbers[]={2,4,8,10}; 
int *ptr = Numbers; 
for(int c=0;c<3;c++)
{
cout<<*ptr<<"@";
ptr++;
}
cout<<endl;
for(c=0:c<4:c++)
{
(*ptr) *= 2;
--ptr;
}
for(c=1:c<4;c++)
cout<<Numbers[c]<<"#";
cout<<endl;
}

Аnswer:
Output of the given program will be
2@4@8@
8#16#20#

Question 11:
Find the output of the following program:

#include<iostream.h> 
#include<conio.h> 
void main()
{
int Array[]={4,6,10,12}; 
int *pointer = Array; 
for(int i=1;i<=3;i++)
{
cout<<*pointer<<"#";
pointer++;
}
cout<<endl; 
for(i=1;i<=4;i++)
{
(*pointer) *= 3;
--pointer;
}
for(i=l;i<5;i++)
cout<<Array[i-1]<<"@"; 
cout<<endl;
}

Аnswer:
Output of the given program will be
4#6#10#
12@18@30@36@

Question 12:
Give the output of the following program segment. (Assume, all required header files are included in the program.)

void main()
{
int a=32,*X=&a;
char ch=65, &eco=ch; 
eco+=a;
*X+=ch;
cout<<a<<','<<ch<<endl;
}

Аnswer:
Output of the given program will be
129,a

Question 13:
Identify the syntax error(s), if any, in the following program. Also, give reason for errors.

void main()
{
const int i=20;
const int *const ptr=&i;
(*ptr)++;
int j=15;
ptr=&j;
}

Аnswer:
(*ptr)++ cannot modify a const object ptr-&j cannot modify a const object.

Question 14:
Give the output of the following program segment. (Assume, all required header files are included in the program.)

void main()
{
int array[] = {2,3,4,51}; 
int *arptr=array;
int value=*arptr; 
cout<<va1ue<<'\n'; 
value=*arptr++; 
cout<<value<<'\n'; 
value=*arptr; 
cout<<value<<'\n'; 
value=*++arptr; 
cout<<value<<'\n'; 
}

Аnswer:
Output of the given program will be
2
2
3
4

Question 15:
Give the output of the following program segment. (Assume, all required header files are included in the program.)

void main()
{
char *s="GOODLUCK";
for(int x=strlen(s)-1;x>=0;x--) 
{
for(int y=0;y<=x;y++) 
cout<<s[y]; 
cout<<endl;
}
}

Аnswer:
Output of the given program will be
GOODLUCK
G00DLUC
G00DLU
GOODL
GOOD
GOO
GO
G

Question 16:
Give the output of the following program segment. (Assume, all required header files are included in the program).

void main()
{
char *NAME="a ProFile"; 
for(int x=0;x<strlen(NAME);x++) 
if(islower(NAME[x])); 
else
if(isupper(NAME[x])) 
if(x%2!=0)
NAME[x]=tolower(NAME[x-l] 
else
NAME[x]--;
cout<<NAME<<endl;
}

Аnswer:
Output of the given program will be
a Orooile

Question 17:
Find and write the output of the following C++ program code: All India 2017
NOTE Assume all required header files are already being included in the program.

void main()
{
int *Point, Score[]={100,95,150,75,65,120};
Point=Score; 
for(int L=0;L<6;L++)
{
if((*Point)%10==0) 
*Point /= 2; 
else
*Point -= 2; 
if((*Point)%5==0) 
*Point /= 5; 
Point++;
}
for(int L=5;L>=0;L--)
cout<<Score[L]<<"*";
}

Аnswer:
Given program will give error, i.e. Multiple declaration for ‘L’
If we remove int from 2nd for loop then output will be:
12*63*73*15*93*10*

Question 18:
Find the output of the following program: Delhi 2012C

#include<iostream.h> 
void main() 
{
int Points=300; 
int *Start=&Points; 
int *End;
End=new int;
(*End)=Points-150:
Points+=100;
cout<<Points<<":"<<*Start<<endl; 
cout<<*End<<endl;
Start=End;
cout<<Points<<":"<<*Start<<endl; 
cout<<*End<<endl;
Points-=100;
*Start-=50;
cout<<Points<<":"<<*Start<<endl; 
cout<<*End<<endl; 
delete End;
}

Аnswer:
Output of the given program will be 400:400
150
400:150
150
300:100
100

Question 19:
Find the output of the following program Delhi 2009

#include<iostream.h> 
#include<conio.h> 
void main()
{
int X[]={10, 25, 30, 55, 110}; 
int *p=X; 
whi1e(*p<110)
{
if(*p%3!= 0)
*p = *p+1; 
else
*p = *p+2; 
p++:
}
for(int 1=4;I>=1;I--)
{
cout<<X[I]<<"*"; 
if(I%3 == 0) 
cout<<endl;
} 
cout<<X[0]*3<<endl;
}

Аnswer:
Output of the given program will be
110*56*
32*26*33

Question 20:
Find the output of the following program. Delhi (C) 2009

#include<iostream.h> 
#include<conio.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, 951}};
score *Point=Arr;
Change(Point, 50); 
cout<<Arr[0].Year<<"#"<<Arr[0].topper<<endl; 
Change(++Point);
cout<<Point->Year<<"#"<<Point->topper<<endl;
}

Аnswer:
Output of the given program will be
2008#75
2009#100

Question 21:
Find the output of the following program. All India 2009

#include<iostream.h>
#include<conio.h> 
void main()
{
int A[] = {10, 15, 20, 25. 30}; 
int *p = A; 
whi1e(*p<30)
{
if(*p%3!= 0)
*p = *p+2;
else
*p = *p+1;
P++;
}
for(int J=0;J<=4;J++)
{
cout<<A[J]<<"*"; 
if(J*3 == 0) 
cout<<endl;
}
cout<<A[4]*3<<endl;
}

Аnswer:
Output of the given program will be
12*
16*22*27*
30*90

Question 22:
What will be the output of the following program?

#include<iostream.h> 
#include<ctype.h>
#include<conio.h>
#include<string.h> 
void ChangeString(char Text[],int SCounter)
{
char *Ptr = Text;
int Length = strlen(Text); 
for(;Counter<Length-2;Counter+=2,Ptr++)
{
*(Ptr+Counter)=toupper(*(Ptr+Counter));
void main()
{
int Position=0;
char Message[]="Pointers Fun"; 
ChangeString(Message, Position); 
cout<<Message<<"@"<<Position;
}

Аnswer:
Output of the given program will be
PoiNteRs Fun@10

Question 23:
What will be the output of the following program?

#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<string.h> 
void NewtextCchar String[],int &Position)
{
char *Pointer=String;
int Length=strlen(String);
for(;Position<Length-2;Position+=2,Pointer++)
{
*(Pointer+Position)=toupper(*(Pointer+Position));
}
}
void main()
{
clrscr();
int Location=0;
char Message[]="Dynamic Act";
Newtext(Message, Location);
cout<<Message<<"#"<<Location;
}

Аnswer:
Output of the given program will be
DynAmiC ACt#10

Read More

Chapter 3: Data File Handling | class 12th | Important question Computer Science

Important Questions for Class 12 Computer Science – Data File Handling

Question 1:
Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the hard disk with a data of 200 clients: All India 2017

class CLIENTS
{
int CCode;char CName[20]; 
public:
void REGISTER(); void DISPLAY();
}:
void main()
(
fstream File;
File.open("CLIENTS.DAT",ios::binary|ios::in);
CLIENTS C;
File.seekg(6*sizeof(C));
File.read!(char*)&C, sizeof(C)):
cout<<"Client Number:"<<File.tellg()/sizeof(C)+1;
File.seekg(0,ios::end);
cout«"of"<<File.tellg()/sizeof(C)<<endl;
File.close();
}

Answer:
Output

Client Number:8 of 200

Question 2:
Find the output of the following C++ code considering that the binary file MEM.DAT exists on the hard disk with a data of 1000 members: Delhi 2016

class MEMBER
{
int Mcode;char MName[20];
public:
void Register();void Display();
};
void main()
{
fstream MFile;
MFile.openCMEM.DAT", ios ::binary| ios :: in); .
MEMBER M;
MFile.read((char*) &M. sizeof(M));
cout<<"Rec :"<<MFile.tellg()/sizeof(M)<< endl;
MFile.read!(char*) &M, sizeof(M));
MFile.read((char*) &M, sizeof(M)); 
cout<<"Rec :"<<MFile.tellg()/sizeof(M)<<endl;
MFile. close();
}

Answer:
Output

Rec : 1
Rec : 3

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: All India 2016

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.tel 1 g()/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:
Output

Rec: 1 
Rec: 3

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

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: "<<P0S<<endl;
CF.close();
}

Answer:
Output

PRESENT RECORD:3

Question 5:
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. All India 2015

class MEMBER
{
int Mno; char Name[20]; 
public:
void In(); void Out(); 
};
void main()
{
fstream MF;
MF.openC"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 P0SITI0N=MF.tel1g()/sizeof(M); 
cout<<”PRESENT RECORD: ”<<P0SITI0N<<endl ; 
MF.close();
}

Answer:
Output

PRESENT RECORD:3

Question 6:
Find the output of the following C++ code considering that the binary file GAME. DAT exist on the hard disk with information of around 200 games. All India 2015 c

class GAME 
{
int Gno; char GName[20]; 
public:
void Getln(); void ShowName();
};
void main()
{
fstream GF;
GF.open("GAME.DAT",ios::binary | ios::in); 
GAME G;
GF.seekg(sizeof(G)*5) ;
GF.read((char*)&G, sizeof(G)):
GF.readC(char*)&G, sizeof(G)); 
int REC0RDN0=GF.tel 1g()/sizeof(G); 
cout<<"REC0RDN0: "<<REC0RDN0<<endl; 
GF.close();
}

Answer:
Output

REC0RDN0:7

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. Delhi 2014

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 ChangeMobile() //Function to change Mobile
{
cout<<”Changed Mobile:"; 
gets(Mobile);
}
};
void RepUpdate()
{
fstream F;
F.open("REP.DAT", ios::binary|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 l: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 "<<endl;
F.close();
}

Answer:
Statement 1

M.ChangeMobile()

Statement 2

F.seekp(-l*sizeof(M),ios::cur)

Question 8:
Fill in the blanks marked as Statement 1 and Statement 2 in the program segment given below with appropriate functions for the required task. All India 2014

class Agency 
{
int ANo; //Agent code
char AName[20];  //Agent name
char Mobile[30];   //Agent mobile 
public:
void Enter(); //Function to enter details of agent
void Disp(); //Function to display details of agent
int RAno() {return ANo;
}
void UpdateMobileO //Function to update Mobile 
{
cout<<"Updated Mobile:"; 
gets(Mobile);
}
};
void AgentUpdateC)
{
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;
whileUUpdt && F.read((char*)&A,sizeof(A)))
{
if (A.RAnoO == 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.UpdateMobile()

Statement 2

F.seekpC-l*sizeof(A),ios::cur)

Question 9:
Fill in the blanks.marked as Statement 1 and Statement 2 in the program segment given below with appropriate functions for the required task. All India 2013

class Club
{
long int MNo;             //Member number
char MName[20];          //Member name
char Email[30];          //Email of member
public:
void Register();         //Function to register member
void Disp();             //Function to display details
void ChangeEmail()    //Function to change Email
{
cout<<"Enter Changed Email:"; 
cin>>Email;
}
long int GetMno()
{
return MNo;
}
};
void ModifyData()
{
fstream File;
File.open("CLUB.DAT",ios::binary|ios::in|ios::out); 
int Modify = 0, Position; 
long int ModiMno;
cout<<MMno-whose email required to be modified:";
cin>>ModiMno;
Club CL;
whi1e(!Modify&&Fi1e.read((char*)&CL,sizeof(CL)))
{
if(CL.GetMno() == ModiMno)
{
CL.ChangeEmail();
Position = File.tellgO-sizeof(CL);
//Statement 1:To place file pointer to the required position 
____________________________________;
//Statement 2:To write the object CL onto the binary file 
____________________________________; 
Modify++;
}
}
if(Modify)
cout<<"Email Changed..."<<endl;
else
cout<<"Member not found.. ."<<endl;
File.close();
}

Answer:
Statement 1

File.seekp(Position)

Statement 2

File.write((char*)&CL,sizeof(CL))

Question 10:
Fill in the blanks marked as Statement 1 and Statement 2 in the program segment given below with appropriate functions for the required task. Delhi 2013

class Customer
{
long int CNo; //Customer number
char CName[20]; //Customer name
char Email[30]; //Email of customer
public:
void Allocate(); //Function to allocate 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(!Change && File.read((char*)&CU,sizeof(CU)))
{
if(CU.GetCno() = ChangeCno)
{
CU.ModifyEmai1();
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(Location)

Statement 2

File.write((char*)&CU,sizeof(CU))

Question 11:
Fill in the blanks marked as Statement 1 and Statement 2 in the program segment given below with appropriate functions for the required task. Delhi 2013C

class Agent 
{
long ACode; //Agent Code
char AName [20]; //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 GetCommO {return Commission;} 
long GetAcodeO {return ACode;}
};
void ChangeCommissiondong 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,sizeof(A)))
{
if(A.GetAcode()==AC)
{
Changed = 'Y’;
A.Update(CM);
//Statement l:To place file pointer to the required position 
___________________________________;
//Statement 2:To write the object A onto the binary file
___________________________________;
}
}
if(Changed=='N')
cout <<"Agent not registered..."; 
F.close ();
}

Answer:
Statement 1

F.seekp(-1*sizeof(A),ios::cur)

Statement 2

F.write((char*)&A,sizeof(A))

Question 12:
Fill in the blanks marked as Statement 1 and Statement 2 in the program segment given below with appropriate functions for the required task. Delhi 2012C

#include<fstream.h>
class Movie
{
long MNo;  //Movie Hall Number
char MName[20];   //Movie Name
int Seats; //Number of Vacant Seats
public:
void MovieIn();
void MovieOut();
void Booking(int N) //Function to Book Seats
{
Seats _=N;
}
int RSeats()
{
return Seats;
}
long RMno()
{
return MNo;
}
};
void BookMySeat(long MH,int S) //MH stands for Hall Number
//S stands for Number of Tickets to purchase
{
fstream File;
File.open("M0VIE.DAT", ios::binary|ios::in|ios::out); 
int Found = 0, Booked = 0, Rec;
Movie M;
whileUFound && File.read((char*)&M,sizeof(M)))
{
if(M.RMnoC)==MH)
{
Found = 1;
if((M.RSeats()-S)> 0)
{
M.Booking(S);
Booked = 1;
}
else
cout<<"House Full";
}
}
if(Found && Booked)
Rec = File.tellg()-sizeof(M);
//Statement 1 : To place file pointer to the required position 
______________________;
//Statement 2 : To write the object M on to the binary file
______________________;
}
if(! Found)
cout<<"No updation done as Hall not found.";
File.close();
}

Answer:
Statement 1

File.seekpCRec,ios: :beg)

Statement 2

File.write((char*)&M,sizeof(M))

Question 13:
Observe the program segment given below carefully and answer the questions that follow: All India 2012

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 == 1)
cout<<"Purchase Updated"<<endl; 
else
cout<<"Wrong item No."<<endl;
File.closeO;
}

(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 updation is done in the binary file.

Answer:
Statement 1

File.seekp(-1*sizeof(S),ios::cur);

Statement 2

File.write((char*)&S,sizeof(S));

Question 14:
Observe the program segment given below carefully and answer the questions that follow: Delhi 2012

class Inventory 
{
int Ano, Qty; char Article[20]; 
public:
void Input!()
{
cin>>Ano; 
gets(Article); 
cin>>Qty;
}
void Issue(int Q)HQty 4= Q;)
void Procure(int Q) (Qty -= Q;)
int GetAno()(return Ano:)
};
void ProcureArticle(int TAno, int TQty)
{
fstream File;
File.open("ST0CK.DAT", ios::binary|ios::in|ios::out); 
Inventory I; 
int Found = 0;
while(Found == 0 && File.read((char*)&I.sizeof(I)))
{
if (TAno == I.GetAno())
{
I.Procure(TQty);
__________________ //Statement 1
__________________ //Statement 2
Found++;
}
if (Found == 1)
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 Article.
(ii) Write Statement 2 to perform the write operation, so that the updation is done in the binary file.

Answer:
Statement 1

File.seekp(-1*sizeof(I),ios::cur);

Statement 2

File.write((char*)&I,sizeof(I));

Question 15:
Observe the program segment given below carefully and fill in the blanks marked as Statement 1 and Statement 2 using seekg() or seekp() or tellg() or tellp() functions for performing the required task. Delhi 2011

#include<fstream.h>
class product
{
int pno;char pname[20];int qty;
public:
void modifyqty(); //Function is to modify quantity of product
};
void product::modifyqty()
{
fstream fil;
file.open("product.dat",ios::binary|ios::in|ios::out);
int mpno;
cout<<”product number to modify quantity 
cin>>mpno;
while(fil.read((char*)this.sizeof(product)))
{
if(mpno == pno)
{
cout<<"present quantity:"<<qty<<endl; 
cout<<"changed quantity:"; 
cin>>qty;
int position =__________; //Statement 1
___________________; //Statement 2
fil.writet(char*)this,sizeof(product));
}
}
fil.close();
}

Answer:
Statement 1

fil.tellg( )-sizeof(product)

Statement 2

fil.seekp(Position) 

or

fil.seekp(-1*sizeof(product),ios::cur)

Question 16:
Observe the program segment given below carefully and fill in the blanks marked as
Statement 1 and Statement 2. You can use any function from seekg(), seekp(), tellp() and tellg() for performing the required task. Delhi 2011C

#include<fstream.h> 
class Country
{
int Code; 
char Name[20]; 
int Population; 
public:
//Function to search and display the content from a particular record number
void SearchFor(int);
//Function to modify the content of a particular record number void Update(int);
};
void Country::SearchFor(int Record)
{
Country C; 
fstream File;
File.open("COUNTRY.DAT",ios::binary|ios::in);
File.read((char*)&C,sizeof(C));
_________ //Statement1
cout<<C.Code<<"==>"<<C.Name<<"==>"<<C.Population<<endl;
File.closet();
}
void Country::Update(int Record)
{
Country C;
fstream File;
Fi le.open("COUNTRY.DAT",ios::binary |ios::in|ios::out);
cin>>C.Code;
cin.getline(C.Name,20);
cin>>C.Population;
_________ //Statement 2
File.write((char*)&C,sizeof(C));
File.closet();
}
}

Answer:
Statement 1

if(C.Code == Record);

Statement 2

File.seekp(-1*sizeof (C), ios:: cur);

Question 17:
Observe the program segment given below carefully and fill in the blanks marked as Statement 1 and Statement 2 using seekg(), seekp(), tellp() and tellg() functions for performing the required task. All India 2011

#include<fstream.h>
class ITEM 
{
int Ino; char Iname[20];
float Price;
public:
void ModifyPrice(); //The function to modify price of a particular ITEM
};
void ITEM::ModifyPrice()
{
fstream File;
File. open("ITEM.DAT",ios::binary|ios::in|ios::out); 
int Cino;
cout<<"Item No to modify price:"; 
cin>>Cino;
while(File.read((char*)this,sizeof(ITEM)))
{
if(Cino == Ino)
{
cout<<"Present Price:"<<Price<<endl;
cout<<"Changed Price:"; 
cin>>Price;
int FilePos =___________; //Statement 1
__________________; //Statement 2
File.write((char*)this,sizeof(ITEM)); //Re-writing the record
}
}
File.close();
}

Answer:
Statement 1

File.tellg()-sizeof (ITEM)

Statement 2

File.seekp(FilePos,ios::beg) 
or
File.seekp(-1*sizeof(ITEM),ios::cur)

Question 18:
Observe the program given below carefully and fill in the blanks marked as Statement 1 and Statement 2 using tellg() and seekp() functions for performing the required task. All India 2010

#include<fstream.h> 
class Customer
{
long Cno; char Name[20], Mobi1e[12]; 
public:
//function to allow user to enter the Cno, Name , Mobile 
void Enter();
//function to allow user to enter (modify) Mobile number 
void Modify();
//function to return value of Cno 
long GetCno() {return Cno;}
};
void ChangeMobile()
{
Customer C; 
fstream F;
F.open("CONTACT.DAT". ios::binary|ios::in|ios::out);
long Cnoc; //Customer number whose mobile number needs to be changed
cin>>Cnoc;
while(F.read((char*)&C,sizeof(C)))
{
if(Cnoc == C.GetCno())
C.Modify();
//Statement 1 to find the current position of file pointer int Pos = _________________
//Statement 2 to move the file pointer to write the 
//modified record back onto the file for desired Cnoc
F.write((char*)&C,sizeof(C));
}
F.close();
}

Answer:
Statement 1

F.tellg():

Statement 2

F.seekp(Pos-sizeof(C),ios::beg): 
or
F.seekp(-1*sizeof(C),ios::cur);

Question 19:
Observe the program segment given below carefully and fill in the blanks marked as Statement 1 and Statement 2 using tellg() and seekp() functions for performing the required task. Delhi 2010

#include<fstream.h> 
class Client 
{
long Cno;
char Name[20], Email[30]; 
public:
void Enter(); //Function to allow user to enter the Cno.Name,Email 
void ModifyO; //Function to allow user to enter(modify) Email 
long ReturnCnoO (return Cno;}
};
void ChangeEmail ()
{
Client C;
fstream F;
F.open("INF0.DAT",ios::binary|ios::in|ios::out);
long Cnoc; //Client’s number whose Email needs to be changed
cin>>Cnoc;
while(F.read((char*)&C,sizeof(C)))
{
if(Cnoc == C.ReturnCno())
{
C.Modify();
//Statement 1 to find the current position of file pointer int Pos = ______________
//Statement 2 to move the file pointer to write the 
//modified record back onto the file for the desired Cnoc
______________
F.write((char*)&C,sizeof(C));
}
}
F.close();
}

Answer:
Statement 1

F.tellg():

Statement 2

F.seekp(Pos-sizeof(C),ios::beg);
or
F.seekp(-1*sizeof(C) ,ios: :cur);
Read More