Skip to main content

PGDCA IMPORTANT QUESTIONS PART-2

एल्गोरिदम और फ्लोचार्ट

एल्गोरिदम और फ्लोचार्ट

1. एल्गोरिदम और फ्लोचार्ट

एल्गोरिदम (Algorithm): एल्गोरिदम समस्याओं को हल करने का एक चरण-दर-चरण तरीका है। इसे सरल और तार्किक चरणों में लिखा जाता है जिसे कंप्यूटर या व्यक्ति आसानी से समझ सके।

उदाहरण: दो संख्याओं को जोड़ने के लिए एल्गोरिदम:

            1. शुरू करें।
            2. दो संख्याएँ A और B दर्ज करें।
            3. जोड़ें: Sum = A + B।
            4. परिणाम (Sum) प्रिंट करें।
            5. बंद करें।
        

फ्लोचार्ट (Flowchart): फ्लोचार्ट एल्गोरिदम का ग्राफिकल रूप है, जिसमें प्रतीकों का उपयोग करके समस्या को हल करने के चरण दिखाए जाते हैं।

2. लिंकिंग और लोडिंग

लिंकिंग (Linking): यह प्रक्रिया प्रोग्राम के विभिन्न हिस्सों (जैसे, object files और लाइब्रेरी) को एक साथ जोड़ने की है ताकि एक executable फाइल बन सके।

लोडिंग (Loading): यह प्रक्रिया executable फाइल को मेमोरी में लोड करके CPU द्वारा निष्पादन के लिए तैयार करती है।

3. C भाषा में स्विच स्टेटमेंट का सिंटैक्स

            switch (expression) {
                case value1:
                    // अगर expression value1 के बराबर है तो यह कोड चलेगा।
                    break;
                case value2:
                    // अगर expression value2 के बराबर है तो यह कोड चलेगा।
                    break;
                ...
                default:
                    // अगर कोई भी केस मैच नहीं हुआ तो यह कोड चलेगा।
            }
        

उदाहरण:

            #include 
            int main() {
                int day = 3;
                switch (day) {
                    case 1:
                        printf("सोमवार\n");
                        break;
                    case 2:
                        printf("मंगलवार\n");
                        break;
                    case 3:
                        printf("बुधवार\n");
                        break;
                    default:
                        printf("अवैध दिन\n");
                }
                return 0;
            }
        

4. C में विभिन्न ऑपरेटर्स

  • अंकगणितीय ऑपरेटर्स: +, -, *, /, %
  • संबंध ऑपरेटर्स: <, >, <=, >=, ==, !=
  • तार्किक ऑपरेटर्स: &&, ||, !
  • बिटवाइज ऑपरेटर्स: &, |, ^, ~, <<, >>
  • असाइनमेंट ऑपरेटर्स: =, +=, -=, *=, /=, %=
  • इंक्रीमेंट/डिक्रीमेंट ऑपरेटर्स: ++, --
  • टर्नरी ऑपरेटर: ? :
  • विशेष ऑपरेटर्स: sizeof, & (एड्रेस), * (डीरिफरेंस)

5. C में एक-आयामी ऐरे

परिभाषा: एक-आयामी ऐरे एक डेटा संरचना है जिसमें एक ही प्रकार के कई तत्व क्रमबद्ध तरीके से संग्रहित होते हैं। इसे इंडेक्स के माध्यम से एक्सेस किया जाता है।

            #include 
            int main() {
                int arr[5] = {10, 20, 30, 40, 50}; // ऐरे घोषित करें और मान दें।
                for (int i = 0; i < 5; i++) {
                    printf("तत्व %d: %d\n", i, arr[i]);
                }
                return 0;
            }
        

6. मैट्रिक्स का जोड़ और ट्रांसपोज (C प्रोग्राम)

            #include 
            int main() {
                int a[2][2], b[2][2], sum[2][2], transpose[2][2];

                // मैट्रिक्स इनपुट करें
                printf("मैट्रिक्स A के तत्व दर्ज करें:\n");
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        scanf("%d", &a[i][j]);
                    }
                }
                printf("मैट्रिक्स B के तत्व दर्ज करें:\n");
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        scanf("%d", &b[i][j]);
                    }
                }

                // मैट्रिक्स का जोड़
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        sum[i][j] = a[i][j] + b[i][j];
                    }
                }

                // मैट्रिक्स A का ट्रांसपोज
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        transpose[j][i] = a[i][j];
                    }
                }

                // परिणाम प्रिंट करें
                printf("मैट्रिक्स का जोड़:\n");
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        printf("%d ", sum[i][j]);
                    }
                    printf("\n");
                }

                printf("मैट्रिक्स A का ट्रांसपोज:\n");
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        printf("%d ", transpose[i][j]);
                    }
                    printf("\n");
                }

                return 0;
            }
        

7. किसी संख्या का वर्ग निकालने का एल्गोरिदम और फ्लोचार्ट

एल्गोरिदम:

            1. शुरू करें।
            2. संख्या N दर्ज करें।
            3. वर्ग निकालें: Square = N × N।
            4. परिणाम (Square) प्रिंट करें।
            5. बंद करें।
        

फ्लोचार्ट चरण:

  • Start (ओवल)
  • Input N (पैरेललोग्राम)
  • Square = N × N (रेक्टेंगल)
  • Output Square (पैरेललोग्राम)
  • End (ओवल)

Comments

Popular posts from this blog

2024 ke Best Smartphones: Kya Kharidna Chahiye? 2024 ke Best Smartphones: Kya Kharidna Chahiye? Introduction 2024 mein smartphones ki duniya mein bahut saari innovations aur upgrades dekhe gaye hain. Har brand apne naye models ke sath market mein utar raha hai, jo technology, design, aur features mein behtareen hain. Aaj hum kuch best smartphones ki list banayenge jo aapke liye perfect ho sakte hain. 1. Apple iPhone 15 Pro Max Price: ₹1,49,900 (Starting) 6.7-inch Super Retina XDR display A17 Bionic chip for unmatched performance Advanced camera system with 5x optical zoom Long-lasting battery life with fast charging support Why Choose It? iPhone 15 Pro Max best performance, build quality, aur ecosystem ka combination offer karta hai, jo Apple fans ke liye perfect hai. 2. Samsung Galaxy S24 Ultra Price: ₹...

SQL kya hai?

  1. SQL kya hai? Jawaab: SQL ka full form hai "Structured Query Language". Yeh ek aisi language hai jisse hum computer ko bol sakte hain ke database (jaise ek badi kitaab ya register jisme data hota hai) se kuch information nikaale, badle, ya naye data ko store kare. SQL zyada tar database manage karne ke liye use hoti hai, jaise MySQL aur SQL Server. 2. Primary Key kya hoti hai? Jawaab: Primary Key ek aisa khaas column hota hai jo table ke har record ko unique banata hai, yaani har row alag hoti hai. Yeh key kabhi repeat nahi hoti aur NULL bhi nahi hoti. Jaise ek class mein har student ka alag roll number hota hai, waise hi Primary Key ek unique ID banati hai. 3. SQL mein Joins kya hote hain? Aur inke types batao. Jawaab: Joins ka kaam do ya zyada tables ke records ko jodna hota hai. Jaise ek table mein students ke naam hain aur doosri mein unke marks, toh join se dono tables ke data ko ek saath dekh sakte hain. INNER JOIN: Sirf wahi rows lata hai jo dono tables mein m...
5G vs. Wi-Fi 6: Which is Better for You? 5G vs. Wi-Fi 6: Which is Better for You? As technology evolves, the debate between 5G and Wi-Fi 6 becomes increasingly relevant. Both technologies promise faster internet speeds and improved connectivity, but they serve different purposes and use cases. In this article, we'll explore the unique features of each technology and help you determine which is better suited for your needs. Understanding the Basics 5G , the fifth generation of mobile networks, offers incredibly fast download and upload speeds, reduced latency, and the ability to connect more devices simultaneously. It is designed to provide seamless connectivity in urban areas and can support applications such as autonomous vehicles and smart cities. Wi-Fi 6 , on the other hand, is the latest iteration of wireless local area networks (WLAN). It brings enhanced performance in crowded environments, faster speeds, and im...