C-and-C++/C2/Scope-Of-Variables/Gujarati

From Script | Spoken-Tutorial
Revision as of 13:06, 9 July 2013 by Jyotisolanki (Talk | contribs)

Jump to: navigation, search
Time' Narration
00.01 C અને C++ માં વેરિયેબલ ના સ્કોપ પરના આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.
00.08 આ ટ્યુટોરીયલ માં આપણે શીખીશું.
00.11 વેરિયેબલના સ્કોપ શું છે?
00.13 વૈશ્વિક વેરિયેબલ શું છે?
00.16 સ્થાનિક વેરિયેબલ શું છે?
00.19 થોડા ઉદાહરણો.
00.22 આપણે કેટલીક સામાન્ય એરર અને તેના ઉકેલો પણ જોશું.
00.27 આ ટ્યુટોરીયલ રેકોર્ડ કરવા માટે હું
00.30 ઉબુન્ટુ ઓપરેટીંગ સીસ્ટમ આવૃત્તિ 11.04, 'કમ્પાઈલર આવૃત્તિ gcc અને g++ 4.6.1 ઉપયોગ કરી રહ્યી છું.
00.41 ચાલો વેરિયેબલના સ્કોપના પરિચય સાથે શરુ કરીએ.
00.47 આ એવા વિભાગનો કોડ છે જે વેરિયેબલ વાપરી શકે છે.
00.54 જાહેરાત તેના પ્રકાર અને સ્થળ પર આધારીત છે તે બે વર્ગોમાં વિભાજિત થાય છે
00.59 વૈશ્વિક વેરિયેબલ અને
01.02 સ્થાનિક વેરિયેબલ.
01.05 હવે આપણે, ઉદાહરણ જોશું.
01.07 મેં પહેલેથી જ એડિટર પર પ્રોગ્રામ ટાઈપ કર્યો છે.
01.10 ચાલો હું આ ખોલું.
01.14 નોંધ લો કે આપણી ફાઈલનું નામ scope.c.છે.
01.19 ચાલો હું હમણાં કોડ સમજાવું.
01.23 આ આપણી header file.છે
01.26 અહીં અમે બે વૈશ્વિક વેરિયેબલ્સ જાહેર કરી છે a અને b.
01.32 અને આપણે તેને 5 અને 2. વેલ્યુ સોપીને ઇનિશલાઇજડ કર્યું છે.
01.39 વૈશ્વિક વેરિયેબલ તમારા પ્રોગ્રામમાં બધા ફંક્શન્સ પર ઉપલબ્ધ છે..
01.44 આ મુખ્ય ફંક્શન ઉપર કોઇ ફંક્શન્સ બહાર જાહેર કરવામાં આવ્યું છે.
01.51 આ એક વૈશ્વિક સ્કોપ ધરાવે છે.
01.53 અહીં આપણે આર્ગ્યુમેન્ટ વગર add '' ફંક્શન જાહેર કર્યું છે.
01.59 અહીં sumએ સ્થાનિક વેરિયેબલ છે તે ફંક્શન એડ અંદર જાહેર કરવામાં આવે છે.


02.07 સ્થાનિક વેરિયેબલ એ માત્ર એવા ફંક્શન માટે ઉપલબ્ધ છે જેમાં તેજાહેર કરાયા છે.
02.13 આ વેરિયેબલ બ્લોક અંદર જાહેર કરવામાં આવે છે.
02.16 આ સ્થાનિક સ્કોપ ધરાવે છે.
02.19 તો sum a અને b વેરિયેબલ સમમાં સંગ્રહિત કરવા માં આવશે.અહી આપણે સમ ને પ્રિન્ટ કરશું.
02.29 આ આપણુ main function.છે.
02.33 add ફંક્શન કોલ થાય છે અને પછી એક્ઝિક્યુટ થાય છે.
02.38 આ આપણુંreturnસ્ટેટમેન્ટ છે.
02.40 હવે સેવ પર ક્લિક કરો.
02.43 ચાલો આપણે પ્રોગ્રામ એક્ઝેક્યુટ કરીએ.
02.45 તમારા કીબોર્ડ પર Ctrl, Alt અને T કીઓ એકસાથે દબાવી ટર્મિનલ વિન્ડો ખોલો.
02.55 કમ્પાઇલ કરવા માટે ટાઈપ કરો,
02.56 gcc scope.c -o sco અને એન્ટર દબાવો.
03.05 એક્ઝેક્યુટ કરવા માટે
03.06 ./scoટાઈપ કરો,એન્ટર દબાવો
03.10 આઉટપુટ આ રીતે પ્રદર્શિત થાય છે.
03.13 Sum of a and b is 7
03.16 હવે આપણે જોશું સમાન પ્રોગ્રામ C ++ માં કેવી રીતે એક્ઝેક્યુટ કરવું.
03.20 આપણા પ્રોગ્રામ પર પાછા આવો.પ્રથમ તમારા કી બોર્ડ પર એક સાથે Shift Ctrl' અને S દબાવો.
03.31 Now Save the file with an extension .cpp and click on save


03.41 Let us change the header file asiostream.


03.47 Now include the using statement click on save .
03.58 The declaration of global variable and local variable is same in C++
04.03 So no need to change anything
04.07 Now replace the printf statement with the cout statement


04.13 Delete the format specifier and '\n'
04.17 now delete the comma .
04.19 Type two opening angle brackets
04.22 Delete the closing bracket again type two opening angle bracket
04.26 and within the double quotes type backslash n. Now click on save
04.35 Let us execute the program


04.39 Come back to a terminal.
04.42 To compile type, g++ scope.cpp -o sco1,


04.52 Here we have ,./sco1, because We don't want to overight output parameter sco1 file for the scope .c now press enter
05.07 To execute type./sco1 and press enter . the output is displayed as,
05.17 Sum of a and b is 7.
05.19 we can see that it is similar to our C code, Now we will see some common errors which we can come across.
05.31 Come back to our program, Suppose here I will declare a variable a again,
05.41 Type int a ;
05.45 Click on save. We have declared the variable a above the main function and after the add function ,let us see what happens.
05.57 Come back to our terminal.
06.01 Now compile as before ,


06.05 We see errors , Redefinition of inta , int a previously defined here. come back to our program
06.18 a is a global variable.


06.20 It has a global scope.


06.22 We cannot declare the variable twice as it is already declared globally


06.27 We can only declare variable a as a local variable .


06.34 Let us fix the error.
06.36 Delete this .
06.39 Click on save.
06.41 Let us execute again.


06.42 Come back to our terminal.
06.45 Now compile as before, execute as before.
06.49 Yes it is working.


06.52 This brings us to the end of this tutorial.
06.56 let us summarise
06.58 In this tutorial we learn't ,
07.00 Scope of variable,
07.02 Global variable, e.g : int a=s &
07.07 And local variable ,e.g:int sum
07.12 As an assignment,


07.14 Write a program to print the difference of two numbers.
07.19 Watch the video available at the link shown below .


07.22 It summarises the Spoken Tutorial project.


07.25 If you do not have good bandwidth, you can download and watch it.
07.30 The Spoken Tutorial Project Team,


07.32 Conducts workshops using spoken tutorials .


07.35 Gives certificates to those who pass an online test .


07.40 For more details, please write to,contact@spoken-tutorial.org
07.47 Spoken Tutorial Project is a part of the Talk to a Teacher project.


07.52 It is supported by the National Mission on Education through ICT, MHRD, Government of India.


08.00 More information on this Mission is available at: http://spoken-tutorial.org\NMEICT-Intro.
08.04 This is Ashwini Patil from IIT Bombay signing off


08.08 Thank You for watching.

Contributors and Content Editors

Jyotisolanki, Krupali, PoojaMoolya, Pratik kamble