 on that... अरे की समत्या लोग्ता, में यह छोग। than the concept of an array... अरे की लीगों पकदबी होग। how does an array act? अगर लीगों लिक तो यह जाग। if the array is given a dimension of a block of a block of an array, it is one dimensional array like a vector. But if we need to repaint of the matrix, then we need to repaint of the matrix as we have two dimensional arrays, we will have rows and columns in it. Now we will look at the matrices on the C++ कोी بी matrix define करना है बहाँ डेकने, matrix होती कैसे में या 2 by 2 matrix है, देकने है आपने matrices या जब में, जी स्टॅन का उसी बहुझे, अह आपनी भी आरे में आरे युज की ती, पतानी है, how many elements I want to keep. So, I wanted to define an array. A two-dimensional array in C++ is defined by something like this. तो जेसे आरे का एक नाम हुता था, और उस में एक index हूता था. ये आरे में, दो साईज हैं. एक number of rows है, एक number of columns. आर तो तो तो तो सी एक जेषांच्ता, शाईज रोग तो तो तो तो रोग रोग. और या का आजा, आव ही तो, आब अपने बच्छट यहे गाडे, तो मेंऊरी कैसे आलोकेत होगी. मैंटरी तो तो यह टीमेंच्छनाल हुता, यक यह पीचे लोकेशिन नें तो इसका करता है कि पहले जितने भी फाँस रो है वस में जितने भी एलीमन्ट होंगे वग जेगा पहले बना लेगे तो यह रो वाइज नेंज करता लेए सु तो जिसे यस में सव रोज है और सो कालंट सें उसके बाद में रहेगा जीरो एत रोका, सेकिन कालम, उसके बाद में आज़े आलोट होता जाएगा, और चूग कि साईज हम ने दिकलेर किया है, 100 by 100, तो 100 कालम से हैं, तो पहले रो में, 100 value जाएगी. तो last value क्या होगे, पहले रोकी, 0, 99. उसके तुरन तगला वाला मेंरी लोकेशन है, वो अलाट होगाएगा, C1, 0. और जिस तरे से किसी भी एकसप्रेशन में, हम लोग आरे एलमेंट लिख सकते थे, उसी तरे से किसी भी एकसप्रेशन में आप, 2-dimensional matrix का एलमेंट लिख से. तो फर एकसमपल, if you ever write a statement which says, this M is equal to 2 multiplied by Q plus 7 multiplied by C, i, j. जे परफेखली वेलेड ची अच्प्रेशन. तो यहापे जैसे क्यो है, उसी तरे C, i, j. अब जैसे आरे के बारे में सुचाता, that unless the value of i and j are defined, this has no meaning. आई और जेके वेल्लू दिफाईन हुनी चीए, और किस रेंज में हुनी चीए वेल्लूज, i should be between 0 and 99, j should be between 0 and 9. अगर यहापे आमने हजार कर देते साईज, तो 0 to 9, 99 रेंच हो जाँ. ती के यस तरे से matrix replane कर. अगर square matrix हो, तो यस तरे का साईज दिकलेर करेंगे. अखर में, के बािर और वेलोत के यस कंईगजम यहापे अछमें। श्के ये कुतल से माई चीझ हो ठ्यारتمने थे � आप दे दिया दे भी करolis�� तम के ढवगर करوे क-, where i will say for i equal to 0, i less than m, i plus plus for j equal to 0, j less than n, j plus plus and here if i write input what will this program do? what will this program do? what will this program do? what will this program do? first m and n will have to be the value, assume that m is equal to 3 and n is equal to 2, these values are given in input, so what will these segments do after this? you execute it, otherwise this is nested iteration, first the value of i will change, for some value of i, the value of j will change, and how will it change? you should see from which rate the value changes, here we write i, here we write j and execute the program, first our control came here, it said i equal to 0, here i equal to 0, then check that zero less than m is, if m is 2, then zero less than m, it will come in, it came in and the second loop started here, what will happen here? for j equal to zero, so what will the value of j be? it will be zero, zero less than n, so it will come in, now this statement will be executed, now what is this statement saying? here c in c i j, i is zero j is zero, so what will be read? it will read c zero zero, this value will be read, after reading this, it came here, after coming here, where will it go? it will go back to the inner iteration, j will increment, j will become one, so j became one, this one is still less than n, then it came in, so it will come in and say c i j, here it is zero, this is one, so what value will it read? c zero one, then it came here, then the value of i increased, the value of j increased, because this is the inner loop, so the value of j increased is two, it is two less than n, no, n is two, do not forget this, so it means that it is over, it will not do one more, so it will come out of this loop and come here, now after coming here, this loop is over, then it will return it and send it back, now what will happen at this time? the value of i will increase from one, so the value of i has increased, one is one less than n, yes it is, so it will come down, but it will come down here from this side, it is not repeating, it is coming back again, the fourth statement will be executed once again, so then j is equal to zero, any value of j remains, if it is executed in the fourth statement, then j is equal to zero, so this j is two, it will become zero again, now zero because it is less than n, then it will come in and then the internal inner loop will be executed in the previous way, so first it will be zero, so what value will it read this time? c one zero, then after that it will be one, then it will read c one one, then after that it will become two, and then two is not less than n, then it will come out of here, then it will increase the value of i, now it will become two, and then it will come from above, so the fourth will start again, so remember this, whenever you approach a fourth statement from above, the initialization starts, the entire iteration starts again, whenever you are thrown back, then only increment is done and testing is done, so after this what will happen now, i will become two and j will become zero, and now this time you will read what? two zero, then this will become one, you will read c two one, then this will become two again, two is not less than n, come out, again go back, now what will happen? three is done, is three less than n? no, because m is equal to three, so now it will come out of this loop also, this loop comes out of here, so it will come out of here, this will be the effect of the inner iteration and the outer iteration, for one value of i, j will go twice, then for the next value of i, j will go twice, then for the next value of i, till the value of i is there, till then it will continue to come out twice or it will come out again, zero one and minus one, whatever its value, in this way you can not only read the values, you can also use it, you can do anything, what can be used for matrices, come lets add two matrixes, so we have to add two matrixes, a plus b, so first its size should be compatible, अप एक 50 भी 70 मेट्रिक्स को 30 भी 68 मेट्रिक्स को अरनी कर सक्टी तो दोनो कमपैटिबल हो नाचे दोनो M by N हो तो यहापे दिकलेर कर लेते हैं आयोर जे रोर कोलम इंडिक्स के लिएंगे अभ यह आरे पडी के से जाए के A और B आरे आरे आद करना है मानले हैं आरे A आरे B आरे C तो यह देखे कमें किस तर से लिए लिएं? कि पहले यह दिकलेर करने के बाद में हम सब से पहले M अर N के लेएंगे अंपुट कर लेंगे और A और B जो आरे जें को तो दीमेंचिनल एसा लिएंगे देते हैं इन सब के यह एले में सम पहले यह यह कमेंट है नहां एसा इंटेखस वगर है लिए में कुई जोर रती आनक्रे जी में हमले लिए लिएं लिएंगे लिएं सलइसस्टार और स्थाश खिलाआज् सक होगी आता है बी आएज बोलुप ख़दम कर दो, तो बी की वेलिव आगाई बी की वेलिव आगाई अब इसके बाद में यहाँ पे यहाँ आपने कोड लिख लिख लिएग अबी यहाँ में लिखते हैं, नाउ, परफ्वाम, अदिशिन के से आद करंगे, कोई फरक नी परता है, जब तक आए मो रेंज थे जादा है, हमें जगा चीजे ज़े रखने के लिए, उसका आप्सुल्ट्रॉट्र शाईस ज्ता गरा जे उसे बड़ा होना चीजे, चल हमने देखा था, अआईभ शाएस किता हो, सवहो, हजार हो. तो क्या उदारन दिया था हमने क्या में जी आमारे गर में जितने लोग हैं। उतने कम्रे से जाडा कम्रे होने गर हो तो कापी। आप लोग हैं तो पनरा कम्रे का गर मना दिया। आगे भी कुन्बा बड़े तो जगा हैं। तो you don't have to worry about it. Similarly, arrays sizes, you should not be stingy. तो क्यी कमेंट लिग दीजी हैं। तो I assure that I will not require more than this size. 1,000 by 1,000. 1,000,000 by 1,000. आप मरजी करो. 1,000 by 10,000. अगर आपके रोज और कालम्स लागे लगे हैं, तो पूरा दिने की जोरत. आप मरजी करो. आप मरजी करो. 1,000 by 10,000. अगर आपके रोज और कालम्स लागे लगे हैं, तो पूरा दिने की जोरत. लेकिन इतने ख्याल रहागे, असल में कमपालर एरर नहीं देपा है. उजब आपका प्रोगराम लोड करोगे।, ژ is equal to what ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ ژ mania । इनीगे सबाल को आरे बडातको, जुक वे हमैं ये कल्षिलेट करनाः भी A, I, J अर B, I, J अं बान लिजाे हम ने एके लूप लगाया, for I equal to 0 to m, for J equal to 0 to n minus , तो अंटोती क्छा़े से करšeBa leada finding of sea on the I, J, from C तो हमान डब जोग ठाशॉने आवत करने से नहींनो की अंटोती कादे, जो में ढ़ीिस ञेज है षेलोग जोग मोग ठीख स्वेनी Chairman viya diagonal तो जब लिता वो सहा मदक। its time �aging� off confidence यहा आने के बाद में जोबी एकश्परिषन है, वो येवल्वेट होने माडा है अब एकश्प्रिषन क्या है, येवल्ज्टन है, A, I, J अआएकिवल्विट मालु में, J ॐकीवल्ट्ट्टटटटटट आई आएआआ आए मालु में तो क्म्पूडर में सी अगताले, उसके आगे B I J लिखा आग, तो I K value मानू में, J K value मैं, तो B I J मानूं, तो आप कितनी आरेज यूँस कर रहा हो, कितने मेंटरैइस आज यूँँँस कर रहा हो, उसका फोर लुब से कोई तलुख नी है, आप जोवें एक्प्रश्यन लिख यूँ जे मूल्टिपलाईए बाए आजा लिखा आपने क्या, विस्चा थे लिए एक मैट्ट्रिक से दूस्फी मैट्ट्रिक से एक आरेए अग दूस्फी आरेए, तो इस में कितने आरेज कितने मैट्राइस लिख के कोई मत्लद नहीं, कुम्टुटर के लिए हर एक्प्रश्यन में जे एक एक एलिमेंट, वो एलिमेंट दिफाईन होना जी, यहापे हम नहीं लिखा प्लास जेएड, अब देखिए जब आप यहाप यहाप यहाप आप, तो आप को हितना मालु में कि यहाप आते ताइम में, अचुकी यहापे हम आई उस कर है, आई शीरो है, तो पी शीरो के बहलु लेगा, वो मान दीखे तीन है, उसके बाद बोलेगा प्लास, 27.3, मल्टीप प्लाइड भाई एक और आगे चु, उसका एलिमेंट क्या है चे है, जे की वल्ग क्या है शीरो है, वहाँ मेमरी से निकाल लेगा, वहाँ वहाँ लोकेटिं दे अप्रोप्रेट वल्ग स्वम मेमें, वहाँ जेड है, जेड इस नहीं आरे, वहाँ जेड शुद भी दिकलेड आज, वहाँ जेड, फ्लोड जेड, उसके जोभी वल्ग होगी उस समय, उसके अपके अप थरीन वाँ रहाँगा बी वहाँ वेश माँद बकी यह विजनर गर लेए, अपविछन ती उसके विछन ना, क्या एक रहाे अप को छूग रहे है, यह मैटड्क्स के हर एलीमःन से अप वीशी और ख्ञागे गर रहे है, 1 2 1 2 m 0 2 m minus 1 y m minus 1 the array is m by n so the fundamental question can you multiply two matrices each of which is m by n if this matrix m by n is m by p then it should be n by p and the resultant matrix will be m by p there is a lot of difference which doesn't seem to be the rule of addition subtraction now we have declared all this but now what we have to do is we have to define p with m and n and we will read the a matrix m by n elements we will read the b matrix n by p elements this is one more reason which you asked why we don't have to read both the arrays in the same nested iteration it was possible because we assumed that both the arrays were m by n but if we have to multiply two arrays the array dimensions will be completely mismatched so i can't read them in a single loop for reading array a i will have to set up a nested iteration how i equal to 0 to m minus 1 and j equal to 0 to n minus 1 but for reading b i will have to set i equal to 0 to n minus 1 and j equal to 0 to p minus 1 because that is n by p array and when i calculate the c matrix i will vary from 0 to m minus 1 and j will vary from 0 to p minus 1 so the multiplication is going to happen completely different let us assume that you have read these arrays now let us see here i am writing input statement in the cryptic language here i and j will be here and since i am writing k in this formula then how will this k be arranged? k equal to 0 to this formula so first let us read two matrix here how will we read? c in now let us read a matrix see how i am writing here i will have to read m and n and p because m by n is this and n by p is this now i am reading the m by n matrix so how i will read for i equal to 0 i less than m i plus plus now i am writing here instead of writing for j see i can write in one line for i equal to 0 i less than m i plus plus outer loop is done i am writing for j equal to 0 i am writing here by opening brass then another opening brass starts with j in that i am writing read input a i j i am writing here c in a i j and then i have to close the loop of j and i have to close the loop of i there are two processes this is done in one line if you want to read b matrix then how to read for i equal to 0 i less than n i plus plus here for j equal to 0 j less than p j plus plus and this time i will input b i and i will have to close two loops nhape semicolon another point to be noted here also i am saying a i j here also i am saying b i j it does not mean that both are the same elements because that depends on what is value of i and j isme i or j key value 0 to n minus 1 0 to n minus 1 as it change home or isme i or j key value 0 to n minus 1 or 0 to p minus 1 change home so i will read different set of elements i will read different set of elements is that clear now i want to multiply this so how to calculate this now how many elements i have to calculate m by p elements calculate once i will calculate one element so this c matrix first i will calculate this and this and this then i will do this and this and this i will do this so this may be nested iteration so here i will write for i equal to 0 i less than m i plus plus for j equal to 0 j less than p because i have to calculate m by p elements now whatever i will write here how many times it will execute m into p times first i equal to 0 then j equal to 0 1 2 3 4 p minus then i equal to 0 1 j equal to 0 1 2 3 p minus i equal to 2 j equal to 0 1 2 3 p i.e. this way all elements of c matrix now what i have to write here now here i have to do summation again how do we do summation by iteration what is the variable of iteration what is the variable k equal to 0 to n minus 1 so i will write iteration how do i do it first i will tell it sum is equal to 0 then i will write for k equal to 0 k less than n k plus plus and here i have to write sum is equal to what aik multiplied by now see what will happen from the outer loop some value of i has come if i have to write here then some value of j has come i and j have a specified value 2 5 3 7 whatever will happen i.e. some element has been fixed here i am calculating for that element now to calculate that element so sum is equal to 0 and iterate around k k varies from 0 to n minus 1 so what will happen in this a i 0 multiplied by b 0 j plus a i 1 multiplied by b 1 j plus a i 2 multiplied by b 2 j whatever value of i and j is the value of i and j till n minus 1 and here when i will come out so this sum should be the value of this so i will write here c i j equal to sum and then i will write this iteration here okay so whatever value of i and j will come here it will calculate this sum for the i j element then next time it will change value of j it will calculate next element another j then i will change again j will vary from 0 etc when the whole work will be done then all elements will be calculated now i will ask one more question is it necessary to have a location called sum at all can i not accumulate the sum in c i j itself in c i j there is no value in the beginning suppose i put 0 in that c i j and instead of adding the sum i add it in c i j so finally the value will come in c i j do you get this suppose instead of this sum equal to 0 i write c i j equal to 0 and instead of writing sum is equal to sum plus this sum plus this if i say c i j is equal to c i j plus this now there is no need for this when the inner iteration will end then all the value will come in c i j so i don't need a separate value that's the point now you go home and take the value of m and n and p or any value 2 3 2 and see if you get the final 2 by 2 matrix or not write any value write b element and execute it from hand if you are c plus plus then you will know how i is varying how j is varying how k is varying you can do this in a lecture i gave in the main class i solved simultaneous equations simultaneous equations simultaneous equation matrix how do you solve it matrix form x is unknown your a matrix is a coefficient suppose here it is written 5 4 3 minus 2 here it is written x1 x2 and is equal to something is written 15 and 7 7.5 do you understand the meaning of this equation it means 5 x1 plus 4 x2 is equal to 15 3 x1 minus 2 x2 equal to 7.5 remember such equations are written now how do you solve this equation by elimination you will multiply this equation by 3 and this equation by 5 subtract one from the other then you will get something so you will eliminate one variable you will find the second variable then you will do back substitution or back substitution then you can do it again 2 x 2 you will do equation from hand you will do 3 x 3 10 x 10 engineering problems are there in that system of 500 simultaneous equations 500 variables 500 equations you will solve it from hand all of them class of CS1 will not be there that is where we need to use computer so that means we have to be able to write a program the way we solve this problem we have to do it with computer so we solved this problem in regular class in that such two equations are very simple then tell me how to multiply and then substitute then how to change in that system we have decided that if you have a coefficient matrix then this matrix if it comes in this form if it comes in this form what do we call it upper triangular matrix from lower triangular matrix do something in this do something in that how do we do this from this program we discussed this in a lecture that lecture we will do matrices problem we will do moodle and home page you have read the slide there is a whole program that if you have given a coefficient matrix then how will it come here and once it comes then how will we get the value of the variable of back substitution first of all this is equal to right hand side directly last variable then we will substitute the value of last variable that multiplied by this so xn-1 plus this multiplied by xn will be equal to bn you can find out xn-1 then xn-2 etc etc this is what you write in mathematics in this you write x1-x2 a11-a12 b11-b12 etc in c++ you write 0-1 so this will be x0 this will be x1 we will call it coefficient 0-0 coefficient 0-1 coefficient 1-0 coefficient 1-1 that is the difference now how do we get iteration in this how do we calculate it that is not very straight forward now I would like you to read that at home and as I said I have given an example of 2 by 2 equation take the coefficient of that example and execute the whole program of that coefficient that you are getting the right result at the end and if it works for 2 by 2 then it will work for 100 by 100 for 1000 by 1000 that is the advantage of the computer on the model the quiz papers all the solutions will be uploaded tomorrow see that problem someone was commenting that there is a very difficult problem in the quiz so the problem has come it will not be difficult because in the world you have to solve difficult problems later so don't do difficult problems no one will understand at the beginning if you try then it will come so read the problems of quiz understand that problem and see the answer to that what is written on the model that is the whole program next week I am thinking to make some notes of 50-60 pages the slides of the lecture the main points of that by consolidating in 2-2 pages and make all the programs their listing and by giving some explanation so I am trying if it is written then in next week I will distribute so it will be material for you to read ok ok thank you