Print Array Elements in Reverse Order in C++ | C++ Example Programs #80
0:00
Today we’re going to talk about how we can print the elements of an array in reverse order.
آج ہم بات کرنے والے ہیں کہ ہم ایرے کے ایلیمنٹس کو ریوارس آڈر میں کس طرح سے پرینٹ کر سکتے ہیں
0:06
For example, we have an array whose elements are 10, 20, 30, 40, and 50.
فار ایزمپل ہمارے پاس ایک ایرے ہے جس کے ایلیمنٹس ہیں 10, 20, 30, 40 and 50
0:12
Here, we’ll take values from the user. They’ll enter an array of their choice, and then we’ll reverse it.
یہاں پہ ہم کیا کریں گے یوزر سے ویلیوز لیں گے وہ اپنی مرضی کا ایرے انٹر کرے گا اس کے بعد ہم کیا کریں گے اسے ریوارس کریں گے
0:20
For example, here I've taken an array: 10, 20, 30, 40, and 50.
جیسے یہاں پہ میں نے یہ ایک ایرے لیا ہوا ہے 10, 20, 30, 40 and 50
0:25
And here it has been reversed: 50, 40, 30, 20, and 10. So, let's get started.
اور یہاں پہ اسے ریورس کیا ہوا ہے 50, 40, 30, 20 and 10 سو آئیے شروع کرتے ہیں
0:33
Hello friends, welcome to Technical Amar. So, what I do here is create an int-type array, whose size we set to 5. I’m not going to explain here what an array is.
اسلام علیکم فرینڈز ویلکم تو ٹیکنیکل امار سو میں کیا کرتا ہوں یہاں پہ انٹ ٹائپ کا ایک ایرے بناتا ہوں جس کا ہم سائز رکھتے ہیں 5 سو میں آپ کو یہاں پہ یہ نہیں بتانے والا کہ ایرے کیا ہوتا ہے
0:45
How we can declare an array and how we can use an array.
ایرے کو ہم کس طرح سے ڈیکلیئر کر سکتے ہیں ایرے کو ہم کس طرح سے یوز کر سکتے ہیں
0:51
because I've already made a complete video about that. You'll find its link in the description and in the i button.
کیونکہ اس پہ میں ایک کمپلیٹ ویڈیو بنا چکا ہوں جس کا لنک آپ کو ڈسکرپشن میں بھی مل جائے گا اور آئی بٹن میں بھی مل جائے گا
0:59
Believe me, if you watch that video, you won't need to watch any other videos related to arrays.
یقین مانے اگر آپ اس ویڈیو کو دیکھ لیتے ہیں تو آپ کو ایرے سے لیٹڈ اور کوئی بھی ویڈیو دیکھنے کی ضرورت نہیں پڑے گی
1:07
So what we do here is show the user a message.
سو ہم کیا کرتے ہیں یہاں پہ یوزر کو ایک میسج شو کرواتے ہیں
1:13
Enter array elements
انٹر ایرے ایلیمنٹس
1:21
So, we'll store the elements the user enters inside the array.
سو یوزر یہاں پہ جو elements enter کرے گا انہیں ہم رکھائیں گے array کے اندر
1:26
Then we'll create a variable named i and use it in a loop here.
تو ہم کیا کرتے ہیں یہاں پہ ایک variable بناتے ہیں i کے نام سے ہم یہاں پہ لگائیں گے loop
1:32
Our loop will start at 0, because array indexes start at 0.
اور loop ہمارا start ہوگا 0 سے کیونکہ array کے جو indexes ہوتے ہیں وہ 0 سے start ہوتے ہیں
1:39
And our loop will run up to less than or equal to 4,
اور ہمارا loop یہاں پہ چلے گا less are equal to 4 تک
1:44
because array indexes go up to n-1.
کیونکہ ہمارے پاس array کے جو indexes ہوتے ہیں وہ کہاں تک جاتے ہیں n-1 تک
1:50
So, what is our size here? 5. So, the indexes go up to 4.
تو یہاں پہ ہمارے پاس size کیا ہے 5 تو یہاں پہ indexes کہاں تک جائیں گے 4 تک
1:55
After that, I'll increment i here with i++.
اس کے بعد میں کیا کرتا ہوں یہاں پہ i++ کر دیتا ہوں
2:01
Then we'll get a value from the user here using cin.
اس کے بعد ہم کیا کریں گے یہاں پہ user سے value لیں گے cn کی مدد سے
2:07
And here we’ll write “i = 0.” So when the loop runs here, the value of i will be zero. So what will happen here? i will be zero.
اور یہاں پہ ہم لکھیں گے اے آئی سو فاسٹ ایم جب یہاں پہ لوپ چلے گا تو اے کی ویلیو ہوگی زیرو تو یہاں پہ کیا ہوگا اے زیرو
2:16
That is, here we’ll get the value in the first element.
یعنی کہ فاسٹ ایلیمنٹ میں ہمارے پاس یہاں پہ ویلیو آئے گی
2:20
You need to remember one thing here: when we declare an array
آپ نے یہاں پہ ایک بات یاد رکھنی ہے کہ جب ہم ایرے
2:23
the brackets
کو ڈیک لیئر کرتے ہیں اس وقت جو بریکٹس
2:27
that we write in are the size of the array.
میں ہم لکھتے ہیں وہ ایرے کا سائز ہوتا ہے اس
2:30
that, whenever we use the array,
کے بعد جب بھی ہم ایرے کو یوز کرتے ہیں اس
2:33
When we write it in brackets during declaration, that is the array size: an array with 5 elements, or 5 variables.
وقت جب ہم بریکٹس میں لکھتے ہیں تو وہ ایرے کا انڈیکس ہوتا ہے ڈیکلیئر کرتے وقت سائز ہوگا یعنی کہ یہ 5 elements والا ایک ایرے ہے 5 variables والا ایک ایرے ہے
2:45
When we use it later, whatever we write in brackets is its index, its position.
بات جب ہم اسے بعد میں یوز کرتے ہیں بعد میں ہم جب بھی اسے یوز کریں گے تو اس وقت بریکٹس میں جو ہم لکھیں گے وہ اس کا index ہوگا وہ اس کی position ہوگی
2:55
So here it will be zero, meaning the first element of the array, the first variable.
کہ یہاں پہ zero ہوگا تو مطلب first element of array یعنی کہ first variable
3:01
So the i value starts at zero here. What will it be? Zero.
تو یہاں پہ iq value zero سے start ہوگی تو یہاں پہ کیا ہوگا zero
3:05
The variable for that position—the first element—will get a value. Then the loop will run again.
position والا یعنی کہ first element والا جو ہمارے پاس variable ہوگا اس میں value آئے گی اس کے بعد کیا ہوگا loop دوبارہ چلے گا
3:14
The i value will increase to one. The less-than-or-equal-to-four condition will be true, so we’ll enter the loop.
iq value increase ہوگے ہو جائے گی one less or equal to four condition true ہوگی تو ہم loop کے اندر آئیں گے
3:23
And we’ll get a value from the user for a1, the second element. In the same way, i will increase.
اور a1 یعنی کہ دوسرے element میں ہم value لیں گے user سے اسی طرح equivalent increase ہوگی
3:30
It will become 2, and we’ll get a value for the third element. We’ll keep getting values from the user as long as this loop runs.
2 ہو جائے گی تو ہم تیسرے element میں value لے لیں گے اور اسی طرح سے جب تک یہ loop چلتا رہے گا ہم user سے value لیتے رہیں گے
3:38
So, I’ll copy this from here.
سو میں کیا کرتا ہوں اسے یہاں سے copy کرتا ہوں
3:43
And paste it here. Now we’ll display a message here.
اور یہاں پہ paste کر دیتا ہوں اب ہم کیا کریں گے یہاں پہ message show کرائیں گے
3:50
“Array elements are…” And here I’ll print the array elements using cout.
array elements are اور یہاں پہ میں کیا کروں گا array کے elements کو print کراؤں گا cout کی مدد سے
4:01
And we’ll add a little space here. So, the first time this loop runs, the value of i will be 0.
اور یہاں پہ ہم تھوڑی سی space بھی دے دیتے ہیں so first time جب یہ loop چلے گا تو i کی value ہمارے پاس ہوگی 0
4:10
So here, the value of a0, the first element, will be printed.
تو یہاں پہ کیا ہوگا a0 یعنی کہ first element کی value print ہوگی
4:14
Then the loop will run again, and the value of i will increase
اس کے بعد کیا ہوگا loop دوبارہ چلے گا تو i کی value increase
4:17
and become one, and here
ہو کے ہو جائے گی one اور یہاں
4:21
the condition will be checked: one less than or equal to four.
پہ condition check ہوگی one less or equal to four
4:24
The condition is true, so here a1
condition true ہے تو یہاں پہ کیا ہوگا اے 1
4:27
will also be printed. Similarly, i will increase to two. The condition will be checked: two less than or equal to four. It will be true, so the value of a2 will also be printed.
کی value بھی print ہو جائے گی اسی طرح i کی value increase ہو کے two ہوگی condition check ہوگی two less or equal to four condition true ہو جائے گی تو یہاں پہ اے 2 کی بھی value print ہو جائے گی
4:39
Now, if we compile and run it,
اب اگر ہم اسے compile and run کریں
4:43
we see “Enter array element.” I’ll enter the array elements here.
سو ہمیں یہاں پہ show رہا ہے enter array element میں کیا کرتا ہوں یہاں پہ array کے elements کو enter کرتا ہوں
4:54
So you can see it shows: “Array elements are 10, 20, 30, 40 and 50.”
سو آپ یہاں پہ دیکھ سکتے ہیں ہمیں show رہا ہے array elements are 10, 20, 30, 40 and 50
4:59
But we wanted the array elements to be shown in reverse order.
بٹ ہم کیا چاہتے تھے کہ array کے elements ہمیں reverse order میں show ہوں
처음 5분까지만 무료로 볼 수 있어요. 이어서 보려면 앱이나 확장 프로그램을 설치하세요.
다운로드다른 언어로 요청하기

![[DICON] 코르티스는 칭구칭긔🫶 | D-PASS (CORTIS)](https://img.youtube.com/vi/fjxWrommKE4/mqdefault.jpg)

![Humsafar - Episode 02 - [ HD ] - ( Mahira Khan - Fawad Khan ) - HUM TV Drama](https://img.youtube.com/vi/H39iyu0SZJ0/mqdefault.jpg)

