Difference between revisions of "C-and-C++/C2/Nested-If-And-Switch-Statement/Gujarati"
From Script | Spoken-Tutorial
Jyotisolanki (Talk | contribs) |
|||
(7 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | | | + | | C અને C++ નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટ પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
|- | |- | ||
| 00:07 | | 00:07 | ||
− | | | + | | આ ટ્યુટોરીયલમાં આપણે શીખીશું, |
|- | |- | ||
| 00:09 | | 00:09 | ||
− | | | + | | નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટને |
|- | |- | ||
| 00:12 | | 00:12 | ||
− | | | + | |કેવી રીતે વાપરવું. |
|- | |- | ||
| 00:13 | | 00:13 | ||
− | | | + | | આપણે આ કેટલાક ઉદાહરણોની મદદથી કરીશું. |
|- | |- | ||
| 00:17 | | 00:17 | ||
− | | | + | | આ ટ્યુટોરીયલ રેકોર્ડ કરવા માટે હું વાપરી રહ્યી છું, |
|- | |- | ||
| 00:20 | | 00:20 | ||
− | | | + | | ઉબુન્ટુ ઓપરેટીંગ સિસ્ટમ આવૃત્તિ 11.10 |
|- | |- | ||
| 00:24 | | 00:24 | ||
− | | gcc | + | |ઉબુન્ટુ ઉપર gcc અને g++ કમ્પાઈલર આવૃત્તિ 4.6.1. |
|- | |- | ||
| 00:30 | | 00:30 | ||
− | | | + | | પ્રથમ આપણે, નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટને કેવી રીતે લખવું તે ઉદાહરણ સાથે શીખીશું. |
|- | |- | ||
| 00:36 | | 00:36 | ||
− | | | + | | મેં પહેલાથી પ્રોગ્રામ લખ્યો છે. |
|- | |- | ||
| 00:39 | | 00:39 | ||
− | | | + | | ચાલો જોઈએ. |
+ | |||
|- | |- | ||
| 00:40 | | 00:40 | ||
− | | | + | | આ પ્રોગ્રામમાં આપણે ઈન્ટીજર ની શ્રેણી તપાસવાનું શીખીશું. |
+ | |||
|- | |- | ||
| 00:45 | | 00:45 | ||
− | | | + | | નોંધ લો કે આપણી ફાઈલનું નામ '''nested-if.c''' છે. |
|- | |- | ||
| 00:50 | | 00:50 | ||
− | | | + | | ચાલો હું હવે કોડ સમજાવું. |
|- | |- | ||
| 00:52 | | 00:52 | ||
− | | | + | | આ આપણી હેડર ફાઈલ છે. |
− | + | ||
|- | |- | ||
| 00:54 | | 00:54 | ||
− | | | + | | આ આપણું મેઈન ફન્કશન છે. |
− | |||
|- | |- | ||
| 00:56 | | 00:56 | ||
− | | | + | | મેઈન ફન્કશન અંદર આપણે બે ઈન્ટીજર વેરિયેબલ જાહેર કર્યા છે, ''''x અને y''''. |
|- | |- | ||
| 01:02 | | 01:02 | ||
− | | | + | |અહીં આપણે યુઝરને '''0 થી 39''' ની શ્રેણી વચ્ચે નંબર દાખલ કરવા માટે પ્રોમ્પ્ટ કરીએ છીએ. |
+ | |||
|- | |- | ||
| 01:08 | | 01:08 | ||
− | | | + | | આપણે '''y''' ની વેલ્યુ યુઝર પાસેથી ઈનપુટ તરીકે લઈએ છીએ. |
|- | |- | ||
| 01:12 | | 01:12 | ||
− | | | + | | આ આપણી if કન્ડીશન છે. |
|- | |- | ||
| 01:14 | | 01:14 | ||
− | | | + | | અહીં આપણે તપાસીશું કે y/10=0 છે કે નહી. |
|- | |- | ||
| 01:19 | | 01:19 | ||
− | | | + | | જો કન્ડીશન true હોય તો, |
|- | |- | ||
| 01:20 | | 01:20 | ||
− | | | + | |આપણે પ્રિન્ટ કરીશું, '''"you have entered a number in the range of 0-9.''' |
|- | |- | ||
| 01:25 | | 01:25 | ||
− | | | + | | આ આપણી else-if કન્ડીશન છે. |
|- | |- | ||
| 01:28 | | 01:28 | ||
− | | | + | | અહીં આપણે y/10=1 તપાસ કરીશું. |
+ | |||
|- | |- | ||
| 01:32 | | 01:32 | ||
− | | | + | |જો કન્ડીશન true હોય તો, |
|- | |- | ||
| 01:34 | | 01:34 | ||
− | | | + | | આપણે પ્રિન્ટ કરીશું, '''you have entered a number in the range of 10-19.''' |
|- | |- | ||
| 01:39 | | 01:39 | ||
− | | | + | |આ else if કન્ડીશનમાં આપણે તપાસ કરીશું કે નમ્બર 20 થી 29 ની શ્રેણી વચ્ચે છે કે નહિ. |
+ | |||
|- | |- | ||
| 01:45 | | 01:45 | ||
− | | | + | | અને અહીં આપણે જોઈશું કે નમ્બર 30 થી 39 ની શ્રેણી વચ્ચે છે કે નહિ. |
+ | |||
|- | |- | ||
| 01:51 | | 01:51 | ||
− | | | + | |આ આપણી else કન્ડીશન છે. |
− | + | ||
|- | |- | ||
| 01:53 | | 01:53 | ||
− | | | + | |જો ઉપરની બધી કન્ડીશન false હોય તો, |
|- | |- | ||
− | | | + | | 01:55 |
− | | | + | | આપણે પ્રિન્ટ કરીશું,''' number not in range.''' |
|- | |- | ||
− | | | + | | 01:58 |
− | | | + | | અને આ આપણું રીટર્ન સ્ટેટમેન્ટ છે. |
+ | |||
|- | |- | ||
− | | 02: | + | | 02:01 |
− | | | + | |હવે ચાલો પ્રોગ્રામ એકઝીક્યુટ કરીએ. |
|- | |- | ||
− | | 02: | + | | 02:03 |
− | | | + | | તમારા કીબોર્ડ પર એકસાથે Ctrl + Alt + T દબાવીને, ટર્મિનલ વિન્ડો ખોલો. |
|- | |- | ||
− | | 02: | + | | 02:12 |
− | | | + | |એકઝીક્યુટ કરવા માટે , ટાઇપ કરો, “gcc” સ્પેસ “nested-if.c” સ્પેસ હાયફન “-o” સ્પેસ “nested”. એન્ટર ડબાઓ. |
|- | |- | ||
− | | 02: | + | | 02:23 |
− | | | + | | ડોટ સ્લેશ “nested” ટાઇપ કરો. એન્ટર ડબાઓ. |
|- | |- | ||
− | | | + | | 02:28 |
− | | | + | | આપણે જોઈશું,Enter a number between 0 to 39. |
|- | |- | ||
− | | | + | | 02:32 |
− | | | + | |હું '''12''' દાખલ કરીશ. |
|- | |- | ||
− | | | + | | 02:34 |
− | | | + | |આઉટપુટ આ પ્રમાણે દર્શાવે છે: |
|- | |- | ||
− | | | + | | 02:35 |
|''' you have entered the number in the range of 10-19'''. | |''' you have entered the number in the range of 10-19'''. | ||
|- | |- | ||
− | | | + | | 02:40 |
− | | | + | | ચાલો બીજો નમ્બર દાખલ કરીએ. |
+ | |||
|- | |- | ||
− | | | + | | 02:42 |
− | | | + | |ચાલો ફરીથી એક્ઝીક્યુટ કરીએ. અપ એરો કી ડબાઓ, એન્ટર ડબાઓ. |
|- | |- | ||
− | | | + | | 02:48 |
− | | | + | | આ વખતે હું ''' 5''' આપીશ. |
|- | |- | ||
− | | | + | | 02:50 |
− | | | + | | આપણે આઉટપુટ આ પ્રમાણે જોઈશું : |
|- | |- | ||
− | | | + | | 02:52 |
| you have entered the number in the range of 0-9. | | you have entered the number in the range of 0-9. | ||
+ | |||
|- | |- | ||
− | | | + | | 02:56 |
− | | | + | |કંડીશનલ એક્ઝેક્યુશન બીજી રીતે પણ કરી શકાય છે. |
|- | |- | ||
− | | 03: | + | | 03:00 |
− | | | + | | '''switch statement ''' ના ઉપયોગ દ્વારા. |
|- | |- | ||
− | | 03: | + | | 03:02 |
− | | | + | | ચાલો જોઈએ એ કેવી રીતે કરવું. |
|- | |- | ||
− | | 03: | + | | 03:05 |
− | | | + | | આપણે સમાન પ્રોગ્રામ '''switch''' ના ઉપયોગ સાથે જોઈશું. |
|- | |- | ||
− | | 03: | + | | 03:08 |
− | | | + | |મેં પહેલાથી પ્રોગ્રામ ખોલ્યો છે. |
+ | |- | ||
+ | | 03:10 | ||
+ | | આપણા એડિટર પર પાછા જઈએ. | ||
|- | |- | ||
− | | 03: | + | | 03:13 |
− | | | + | |મેં આ અગાઉના પ્રોગ્રામ સમજાવ્યું છે. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | 03:16 |
− | | | + | |તો હું '''Switch statements''' ઉપર જઈશ. |
− | + | ||
|- | |- | ||
− | | | + | | 03:20 |
− | || | + | ||અહીં, આપણે ઇનપુટ્સને વિભાજિત કરીશું, એટલે કે, '''y''' ભાગ્યા 10 અને પરિણામ '''x''' વેરિયેબલમાં સંગ્રહીશું. |
|- | |- | ||
− | | | + | |03:28 |
− | | | + | | એનો અર્થ એ થાય કે ભાગાકાર નું ફળ X માં સંગ્રહિત કરવામાં આવશે. |
|- | |- | ||
− | | | + | | 03:32 |
− | | | + | | આ ભાગાકાર ના ફળ ની મદદથી આપણે નંબર શ્રેણી ઓળખી શકીએ છીએ. |
|- | |- | ||
− | | | + | | 03:36 |
− | | | + | | અહીં, આપણે સ્વીચ કમાન્ડને કહીએ છીએ કે ચેક કરવા માટેનો વેરિયેબલ '''x''' છે. |
|- | |- | ||
− | | | + | | 03:41 |
− | | | + | |આ '''case 0''' છે. જો case 0 બરાબર છે |
|- | |- | ||
− | | | + | | 03:45 |
− | | | + | | તો આપણે પ્રિન્ટ કરીશું, '''you have entered the number in the range of 0-9.''' |
|- | |- | ||
− | | | + | | 03:51 |
− | | | + | |જો કેસ બરાબર હોય તો લૂપમાંથી બહાર નીકળવા માટે આપણે '''break''' ઉમેરીશું. |
|- | |- | ||
− | | | + | | 03:55 |
− | | | + | | આપણે લુપને દરેક વખતે બ્રેક કરવું પડશે. |
|- | |- | ||
− | | | + | | 03:58 |
− | | | + | | કારણ કે, એક સમયે ફક્ત એક જ કન્ડીશન true હોઈ શકે. |
|- | |- | ||
− | | | + | | 04:03 |
− | | | + | |આ “case 1” છે. “case 1” એટલે કે “જો '''x ''' ની વેલ્યુ 1 હોય, |
− | |||
|- | |- | ||
− | | | + | | 04:08 |
− | | | + | |તો આપણે પ્રિન્ટ કરીશું, '''you have entered a number in the range of 10-19.''' |
|- | |- | ||
− | | | + | | 04:12 |
− | | | + | | આ “case 2” છે. |
|- | |- | ||
− | | | + | | 04:14 |
− | | | + | |અહીં આપણે પ્રિન્ટ કરીશું, '''you have entered a number in the range of 20-29.''' |
|- | |- | ||
− | | | + | | 04:20 |
− | | | + | |અને આ case 3 છે, અહીં આપણે તપાસ કરીશું કે નમ્બર 30-39 ની શ્રેણીમાં છે કે નહી. |
|- | |- | ||
− | | | + | | 04:26 |
− | | | + | | આ ડીફોલ્ટ કેસ છે. ડિફૉલ્ટ કેસ, ઉપરના કોઈ પણ કેસો બરાબર ન હોય તો શું કરવાની જરૂર છે તે સ્પષ્ટ કરે છે. |
|- | |- | ||
− | | | + | | 04:36 |
− | | | + | |અહીં આપણે પ્રિન્ટ કરીશું, "number not in range" |
+ | |- | ||
+ | | 04:39 | ||
+ | |અને આ આપણું રીટર્ન સ્ટેટમેન્ટ છે. | ||
|- | |- | ||
− | | | + | | 04:41 |
− | | | + | | ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ. |
|- | |- | ||
− | | | + | | 04:43 |
− | | | + | |ટર્મિનલ પર પાછા જઈએ. |
+ | |- | ||
+ | | 04:46 | ||
+ | |ટાઇપ કરો gcc space switch.c space -o space switch. એન્ટર ડબાઓ. | ||
|- | |- | ||
− | | | + | |04:55 |
− | | | + | | ટાઇપ કરો: ./switch. એન્ટર ડબાઓ. |
|- | |- | ||
− | | | + | | 05:00 |
− | | | + | | Enter a number between of 0 to 39. હું 35 દાખલ કરીશ. |
|- | |- | ||
− | | 06 | + | | 05:06 |
− | | | + | | આઉટપુટ આ પ્રમાણે દર્શાવે છે,“you have entered the number in the range of 30 to 39”. |
+ | |- | ||
+ | | 05:10 | ||
+ | | હવે આપણે જોઈશું C++ માં પ્રોગ્રામ કેવી રીતે એક્ઝીક્યુટ કરવું. | ||
|- | |- | ||
− | | | + | | 05:16 |
− | | | + | |ટેક્સ્ટ એડિટર પર ફરીથી જાઓ. |
|- | |- | ||
− | | | + | | 05:18 |
− | | | + | | નોંધ લો કે આપણી ફાઈલનું નામ nested-if.cpp છે. |
|- | |- | ||
− | | | + | | 05:23 |
− | | | + | | અહીં લોજીક અને અમલીકરણ સમાન છે. |
+ | |||
|- | |- | ||
− | | | + | | 05:27 |
− | | | + | | અહીં કેટલાક ફેરફાર છે, જેવા કે: |
+ | |||
|- | |- | ||
− | | | + | | 05:30 |
− | | | + | | stdio.h ના બદલે હેડર ફાઈલ iostream છે. |
+ | |||
|- | |- | ||
− | | | + | | 05:35 |
− | | | + | |અહીં આપણે using સ્ટેટમેન્ટ ઉમેર્યું છે. |
|- | |- | ||
− | | | + | | 05:39 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|Using namespace std | |Using namespace std | ||
|- | |- | ||
− | | | + | | 05:41 |
− | | | + | |અને printf અને scanf ના બદલે cout અને cin ફન્કશન છે. |
+ | |||
|- | |- | ||
− | | | + | | 05:46 |
− | | | + | |તમે જોઈ શકો છો કે બાકીનો કોડ આપણા C પ્રોગ્રામ સમાન જ છે. |
|- | |- | ||
− | | | + | | 05:51 |
− | | | + | |ચાલો કોડ એક્ઝીક્યુટ કરીએ. |
+ | |||
|- | |- | ||
− | | | + | | 05:53 |
− | | | + | |ટર્મિનલ પેર ફરીથી આવો. |
+ | |||
|- | |- | ||
− | | | + | | 05:56 |
− | | | + | |ટાઇપ કરો: g++ space nested-if.cpp space -o space nested1. એન્ટર દબાઓ. |
+ | |||
|- | |- | ||
− | | | + | | 06:07 |
− | | | + | |ટાઇપ કરો: ./nested1. એન્ટર દબાઓ. |
+ | |||
|- | |- | ||
− | | | + | |06:11 |
− | | enter a number between 0 and 39. | + | | enter a number between 0 and 39. હું 40 દાખલ કરીશ. |
+ | |||
|- | |- | ||
− | | | + | | 06:16 |
− | | | + | | આઉટપુટ આ પ્રમાણે દર્શાવે છે : “number not in range” |
+ | |||
|- | |- | ||
− | | | + | | 06:20 |
− | | | + | | હવે ચાલો સ્વીચ પ્રોગ્રામ C++ માં જોઈએ. |
+ | |||
|- | |- | ||
− | | | + | | 06:24 |
− | | | + | | ટેક્સ્ટ એડિટર પર પાછા આવો. |
|- | |- | ||
− | | | + | | 06:27 |
− | | | + | |અહીં પણ લોજીક અને અમલીકરણ સમાન છે. |
+ | |||
|- | |- | ||
− | | | + | | 06:31 |
− | | | + | | તમે જોઈ શકો છો કે હેડર ફાઈલ iostream છે. |
+ | |||
|- | |- | ||
− | | | + | | 06:34 |
− | | | + | | અહીં using સ્ટેટમેન્ટ છે. |
+ | |||
|- | |- | ||
− | | | + | | 06:37 |
− | | | + | | અને આપણે cout અને cin ફન્કશન બદલ્યું છે |
+ | |||
|- | |- | ||
− | | | + | | 06:41 |
− | | | + | | બાકીનો કોડ આપણો switch.c પ્રોગ્રામ સમાન જ છે. |
+ | |||
|- | |- | ||
− | | | + | | 06:45 |
− | | | + | | ચાલો એક્ઝીક્યુટ કરીએ. |
+ | |||
|- | |- | ||
− | | | + | |06:46 |
− | | | + | |ટર્મિનલ પર પાછા આવો. |
+ | |||
|- | |- | ||
− | | | + | | 06:48 |
− | | | + | |ટાઇપ કરો :g++ space switch.cpp space -o space switch1 , એન્ટર ડબાઓ. |
+ | |||
|- | |- | ||
− | | | + | | 06:58 |
− | | | + | | ટાઇપ કરો ./switch1. એન્ટર ડબાઓ. |
+ | |||
|- | |- | ||
− | | | + | | 07:02 |
− | | | + | | 0 અને 39 વચ્ચે નંબર દાખલ કરો |
+ | |||
|- | |- | ||
− | | | + | | 07:05 |
− | | | + | |હું 25 એન્ટર કરીશ. |
+ | |||
|- | |- | ||
− | | | + | | 07:09 |
− | | | + | |આઉટપુટ આ પ્રમાણે દર્શાવે છે: |
+ | |||
|- | |- | ||
− | | | + | | 07:11 |
| “you have entered the number in the range of 20-29” | | “you have entered the number in the range of 20-29” | ||
|- | |- | ||
− | | | + | |07:15 |
− | | | + | | હવે ચાલો આપણી સ્લાઈડ પર ફરીથી જઈએ. |
+ | |||
|- | |- | ||
− | | | + | | 07:18 |
− | | | + | | આપણે સ્વીચ અને નેસ્ટેડ ઇફ વચ્ચેનો તફાવત જોઈશું. |
+ | |||
|- | |- | ||
+ | | 07:23 | ||
+ | | સ્વિચ સ્ટેટમેન્ટ એક્ષપ્રેશનના પરિણામ અનુસાર મૂલ્યાકંન કરવામાં આવ્યું છે. | ||
|- | |- | ||
− | | | + | | 07:28 |
− | | | + | |નેસ્ટેડ ઇફ સ્ટેટમેન્ટ એક્ષપ્રેશનનું પરિણામ સાચું હોય તો જ રન થાય છે. |
+ | |||
|- | |- | ||
− | | | + | | 07:34 |
− | | | + | |સ્વીચમાં આપણે વેરિયેબલની વિવિધ વેલ્યુઝને કેસીસ તરીકે લઈએ છીએ. |
+ | |||
|- | |- | ||
− | | | + | | 07:39 |
− | | | + | |નેસ્ટેડ ઇફમાં વેરિયેબલની દરેક વેલ્યુ માટે આપણે કન્ડીશનલ સ્ટેટમેન્ટ લખવું પડે છે. |
+ | |||
|- | |- | ||
− | | | + | | 07:45 |
− | | | + | |સ્વીચ સ્ટેટમેન્ટ માત્ર ઈન્ટીજર વેલ્યુ ચેક કરે છે. |
|- | |- | ||
− | | | + | | 07:50 |
− | | | + | |નેસ્ટેડ ઇફ પૂર્ણાંક અને અપૂર્ણાંક બંને વેલ્યુ માટે ચકાસણી કરી શકે છે. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | 07:55 |
− | | | + | | અહીં આ ટ્યુટોરીયલ સમાપ્ત થાય છે. |
|- | |- | ||
− | | | + | | 07:58 |
− | | | + | |સારાંશ માટે, |
|- | |- | ||
− | | | + | | 08:00 |
− | | | + | | આ ટ્યુટોરીયલમાં આપણે શીખ્યા , નેસ્ટેડ ઇફ સ્ટેટમેન્ટ.ઉદાહરણ તરીકે :else if( y/10 equals to 0) |
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | 08:08 |
− | | | + | |સ્વીચ સ્ટેટમેન્ટ.ઉદાહરણ તરીકે: Switch(x) |
− | + | ||
|- | |- | ||
− | | | + | | 08:12 |
− | | | + | |અને નેસ્ટેડ ઇફ અને સ્વીચ સ્ટેટમેન્ટ વચ્ચેનો તફાવત. |
− | |||
|- | |- | ||
− | | | + | | 08:16 |
− | | | + | |એસાઈનમેન્ટ તરીકે, |
|- | |- | ||
− | | | + | | 08:17 |
− | | | + | | કર્મચારીઓની ઉંમર 20 થી 60 વર્ષની અંદર છે કે નહી તે તપાસ કરવા માટેનો પ્રોગ્રામ લખો. |
|- | |- | ||
− | | | + | | 08:23 |
− | | | + | | નીચે આપેલ લીંક ઉપર ઉપલબ્ધ વિડીઓ જુઓ. http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial |
|- | |- | ||
− | | | + | | 08:26 |
− | | | + | |તે સ્પોકન ટ્યુટોરીયલ પ્રોજેક્ટ માટે સારાંશ આપે છે. |
|- | |- | ||
− | | | + | | 08:29 |
− | | | + | |જો તમારી પાસે સારી બેન્ડવિડ્થ ન હોય તો, તમે ડાઉનલોડ કરી તે જોઈ શકો છો |
|- | |- | ||
− | | | + | | 08:33 |
− | | | + | |સ્પોકન ટ્યુટોરીયલ પ્રોજેક્ટ ટીમ,સ્પોકન ટ્યુટોરીયલોની મદદથી વર્કશોપ આયોજિત કરે છે. |
− | + | ||
|- | |- | ||
− | | | + | | 08:38 |
− | | | + | |જેઓ ઓનલાઇન પરીક્ષા પાસ કરે છે તેમને પ્રમાણપત્ર આપે છે. |
|- | |- | ||
− | | | + | | 08:42 |
− | | | + | | વધુ વિગતો માટે, contact@spoken-tutorial.org પર સંપર્ક કરો. |
|- | |- | ||
− | | | + | | 08:49 |
− | | | + | | સ્પોકન ટ્યુટોરિયલ પ્રોજેક્ટ એ ટોક ટુ અ ટીચર પ્રોજેક્ટનો એક ભાગ છે. |
|- | |- | ||
− | + | | 08:52 | |
− | + | |જે આઇસીટી, એમએચઆરડી, ભારત સરકાર દ્વારા શિક્ષણ પર નેશનલ મિશન દ્વારા આધારભૂત છે | |
− | + | ||
− | + | ||
− | | | + | |
− | | | + | |
|- | |- | ||
− | | | + | | 08:58 |
− | | | + | | આ મિશન વિશે વધુ માહીતી આ લીંક ઉપર ઉપલબ્ધ છે : : [http://spoken-tutorial.org/ http://spoken-tutorial.org]\NMEICT-Intro |
|- | |- | ||
− | | | + | | 09:04 |
− | | | + | | આઈઆઈટી બોમ્બે તરફથી ભાષાંતર કરનાર હું, કૃપાલી પરમાર વિદાય લઉં છું. જોડાવા બદ્દલ આભાર. |
|} | |} |
Latest revision as of 12:30, 24 March 2017
Time | Narration |
00:01 | C અને C++ નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટ પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
00:07 | આ ટ્યુટોરીયલમાં આપણે શીખીશું, |
00:09 | નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટને |
00:12 | કેવી રીતે વાપરવું. |
00:13 | આપણે આ કેટલાક ઉદાહરણોની મદદથી કરીશું. |
00:17 | આ ટ્યુટોરીયલ રેકોર્ડ કરવા માટે હું વાપરી રહ્યી છું, |
00:20 | ઉબુન્ટુ ઓપરેટીંગ સિસ્ટમ આવૃત્તિ 11.10 |
00:24 | ઉબુન્ટુ ઉપર gcc અને g++ કમ્પાઈલર આવૃત્તિ 4.6.1. |
00:30 | પ્રથમ આપણે, નેસ્ટેડ ઇફ અને સ્વિચ સ્ટેટમેન્ટને કેવી રીતે લખવું તે ઉદાહરણ સાથે શીખીશું. |
00:36 | મેં પહેલાથી પ્રોગ્રામ લખ્યો છે. |
00:39 | ચાલો જોઈએ. |
00:40 | આ પ્રોગ્રામમાં આપણે ઈન્ટીજર ની શ્રેણી તપાસવાનું શીખીશું. |
00:45 | નોંધ લો કે આપણી ફાઈલનું નામ nested-if.c છે. |
00:50 | ચાલો હું હવે કોડ સમજાવું. |
00:52 | આ આપણી હેડર ફાઈલ છે. |
00:54 | આ આપણું મેઈન ફન્કશન છે. |
00:56 | મેઈન ફન્કશન અંદર આપણે બે ઈન્ટીજર વેરિયેબલ જાહેર કર્યા છે, 'x અને y'. |
01:02 | અહીં આપણે યુઝરને 0 થી 39 ની શ્રેણી વચ્ચે નંબર દાખલ કરવા માટે પ્રોમ્પ્ટ કરીએ છીએ. |
01:08 | આપણે y ની વેલ્યુ યુઝર પાસેથી ઈનપુટ તરીકે લઈએ છીએ. |
01:12 | આ આપણી if કન્ડીશન છે. |
01:14 | અહીં આપણે તપાસીશું કે y/10=0 છે કે નહી. |
01:19 | જો કન્ડીશન true હોય તો, |
01:20 | આપણે પ્રિન્ટ કરીશું, "you have entered a number in the range of 0-9. |
01:25 | આ આપણી else-if કન્ડીશન છે. |
01:28 | અહીં આપણે y/10=1 તપાસ કરીશું. |
01:32 | જો કન્ડીશન true હોય તો, |
01:34 | આપણે પ્રિન્ટ કરીશું, you have entered a number in the range of 10-19. |
01:39 | આ else if કન્ડીશનમાં આપણે તપાસ કરીશું કે નમ્બર 20 થી 29 ની શ્રેણી વચ્ચે છે કે નહિ. |
01:45 | અને અહીં આપણે જોઈશું કે નમ્બર 30 થી 39 ની શ્રેણી વચ્ચે છે કે નહિ. |
01:51 | આ આપણી else કન્ડીશન છે. |
01:53 | જો ઉપરની બધી કન્ડીશન false હોય તો, |
01:55 | આપણે પ્રિન્ટ કરીશું, number not in range. |
01:58 | અને આ આપણું રીટર્ન સ્ટેટમેન્ટ છે. |
02:01 | હવે ચાલો પ્રોગ્રામ એકઝીક્યુટ કરીએ. |
02:03 | તમારા કીબોર્ડ પર એકસાથે Ctrl + Alt + T દબાવીને, ટર્મિનલ વિન્ડો ખોલો. |
02:12 | એકઝીક્યુટ કરવા માટે , ટાઇપ કરો, “gcc” સ્પેસ “nested-if.c” સ્પેસ હાયફન “-o” સ્પેસ “nested”. એન્ટર ડબાઓ. |
02:23 | ડોટ સ્લેશ “nested” ટાઇપ કરો. એન્ટર ડબાઓ. |
02:28 | આપણે જોઈશું,Enter a number between 0 to 39. |
02:32 | હું 12 દાખલ કરીશ. |
02:34 | આઉટપુટ આ પ્રમાણે દર્શાવે છે: |
02:35 | you have entered the number in the range of 10-19. |
02:40 | ચાલો બીજો નમ્બર દાખલ કરીએ. |
02:42 | ચાલો ફરીથી એક્ઝીક્યુટ કરીએ. અપ એરો કી ડબાઓ, એન્ટર ડબાઓ. |
02:48 | આ વખતે હું 5 આપીશ. |
02:50 | આપણે આઉટપુટ આ પ્રમાણે જોઈશું : |
02:52 | you have entered the number in the range of 0-9. |
02:56 | કંડીશનલ એક્ઝેક્યુશન બીજી રીતે પણ કરી શકાય છે. |
03:00 | switch statement ના ઉપયોગ દ્વારા. |
03:02 | ચાલો જોઈએ એ કેવી રીતે કરવું. |
03:05 | આપણે સમાન પ્રોગ્રામ switch ના ઉપયોગ સાથે જોઈશું. |
03:08 | મેં પહેલાથી પ્રોગ્રામ ખોલ્યો છે. |
03:10 | આપણા એડિટર પર પાછા જઈએ. |
03:13 | મેં આ અગાઉના પ્રોગ્રામ સમજાવ્યું છે. |
03:16 | તો હું Switch statements ઉપર જઈશ. |
03:20 | અહીં, આપણે ઇનપુટ્સને વિભાજિત કરીશું, એટલે કે, y ભાગ્યા 10 અને પરિણામ x વેરિયેબલમાં સંગ્રહીશું. |
03:28 | એનો અર્થ એ થાય કે ભાગાકાર નું ફળ X માં સંગ્રહિત કરવામાં આવશે. |
03:32 | આ ભાગાકાર ના ફળ ની મદદથી આપણે નંબર શ્રેણી ઓળખી શકીએ છીએ. |
03:36 | અહીં, આપણે સ્વીચ કમાન્ડને કહીએ છીએ કે ચેક કરવા માટેનો વેરિયેબલ x છે. |
03:41 | આ case 0 છે. જો case 0 બરાબર છે |
03:45 | તો આપણે પ્રિન્ટ કરીશું, you have entered the number in the range of 0-9. |
03:51 | જો કેસ બરાબર હોય તો લૂપમાંથી બહાર નીકળવા માટે આપણે break ઉમેરીશું. |
03:55 | આપણે લુપને દરેક વખતે બ્રેક કરવું પડશે. |
03:58 | કારણ કે, એક સમયે ફક્ત એક જ કન્ડીશન true હોઈ શકે. |
04:03 | આ “case 1” છે. “case 1” એટલે કે “જો x ની વેલ્યુ 1 હોય, |
04:08 | તો આપણે પ્રિન્ટ કરીશું, you have entered a number in the range of 10-19. |
04:12 | આ “case 2” છે. |
04:14 | અહીં આપણે પ્રિન્ટ કરીશું, you have entered a number in the range of 20-29. |
04:20 | અને આ case 3 છે, અહીં આપણે તપાસ કરીશું કે નમ્બર 30-39 ની શ્રેણીમાં છે કે નહી. |
04:26 | આ ડીફોલ્ટ કેસ છે. ડિફૉલ્ટ કેસ, ઉપરના કોઈ પણ કેસો બરાબર ન હોય તો શું કરવાની જરૂર છે તે સ્પષ્ટ કરે છે. |
04:36 | અહીં આપણે પ્રિન્ટ કરીશું, "number not in range" |
04:39 | અને આ આપણું રીટર્ન સ્ટેટમેન્ટ છે. |
04:41 | ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ. |
04:43 | ટર્મિનલ પર પાછા જઈએ. |
04:46 | ટાઇપ કરો gcc space switch.c space -o space switch. એન્ટર ડબાઓ. |
04:55 | ટાઇપ કરો: ./switch. એન્ટર ડબાઓ. |
05:00 | Enter a number between of 0 to 39. હું 35 દાખલ કરીશ. |
05:06 | આઉટપુટ આ પ્રમાણે દર્શાવે છે,“you have entered the number in the range of 30 to 39”. |
05:10 | હવે આપણે જોઈશું C++ માં પ્રોગ્રામ કેવી રીતે એક્ઝીક્યુટ કરવું. |
05:16 | ટેક્સ્ટ એડિટર પર ફરીથી જાઓ. |
05:18 | નોંધ લો કે આપણી ફાઈલનું નામ nested-if.cpp છે. |
05:23 | અહીં લોજીક અને અમલીકરણ સમાન છે. |
05:27 | અહીં કેટલાક ફેરફાર છે, જેવા કે: |
05:30 | stdio.h ના બદલે હેડર ફાઈલ iostream છે. |
05:35 | અહીં આપણે using સ્ટેટમેન્ટ ઉમેર્યું છે. |
05:39 | Using namespace std |
05:41 | અને printf અને scanf ના બદલે cout અને cin ફન્કશન છે. |
05:46 | તમે જોઈ શકો છો કે બાકીનો કોડ આપણા C પ્રોગ્રામ સમાન જ છે. |
05:51 | ચાલો કોડ એક્ઝીક્યુટ કરીએ. |
05:53 | ટર્મિનલ પેર ફરીથી આવો. |
05:56 | ટાઇપ કરો: g++ space nested-if.cpp space -o space nested1. એન્ટર દબાઓ. |
06:07 | ટાઇપ કરો: ./nested1. એન્ટર દબાઓ. |
06:11 | enter a number between 0 and 39. હું 40 દાખલ કરીશ. |
06:16 | આઉટપુટ આ પ્રમાણે દર્શાવે છે : “number not in range” |
06:20 | હવે ચાલો સ્વીચ પ્રોગ્રામ C++ માં જોઈએ. |
06:24 | ટેક્સ્ટ એડિટર પર પાછા આવો. |
06:27 | અહીં પણ લોજીક અને અમલીકરણ સમાન છે. |
06:31 | તમે જોઈ શકો છો કે હેડર ફાઈલ iostream છે. |
06:34 | અહીં using સ્ટેટમેન્ટ છે. |
06:37 | અને આપણે cout અને cin ફન્કશન બદલ્યું છે |
06:41 | બાકીનો કોડ આપણો switch.c પ્રોગ્રામ સમાન જ છે. |
06:45 | ચાલો એક્ઝીક્યુટ કરીએ. |
06:46 | ટર્મિનલ પર પાછા આવો. |
06:48 | ટાઇપ કરો :g++ space switch.cpp space -o space switch1 , એન્ટર ડબાઓ. |
06:58 | ટાઇપ કરો ./switch1. એન્ટર ડબાઓ. |
07:02 | 0 અને 39 વચ્ચે નંબર દાખલ કરો |
07:05 | હું 25 એન્ટર કરીશ. |
07:09 | આઉટપુટ આ પ્રમાણે દર્શાવે છે: |
07:11 | “you have entered the number in the range of 20-29” |
07:15 | હવે ચાલો આપણી સ્લાઈડ પર ફરીથી જઈએ. |
07:18 | આપણે સ્વીચ અને નેસ્ટેડ ઇફ વચ્ચેનો તફાવત જોઈશું. |
07:23 | સ્વિચ સ્ટેટમેન્ટ એક્ષપ્રેશનના પરિણામ અનુસાર મૂલ્યાકંન કરવામાં આવ્યું છે. |
07:28 | નેસ્ટેડ ઇફ સ્ટેટમેન્ટ એક્ષપ્રેશનનું પરિણામ સાચું હોય તો જ રન થાય છે. |
07:34 | સ્વીચમાં આપણે વેરિયેબલની વિવિધ વેલ્યુઝને કેસીસ તરીકે લઈએ છીએ. |
07:39 | નેસ્ટેડ ઇફમાં વેરિયેબલની દરેક વેલ્યુ માટે આપણે કન્ડીશનલ સ્ટેટમેન્ટ લખવું પડે છે. |
07:45 | સ્વીચ સ્ટેટમેન્ટ માત્ર ઈન્ટીજર વેલ્યુ ચેક કરે છે. |
07:50 | નેસ્ટેડ ઇફ પૂર્ણાંક અને અપૂર્ણાંક બંને વેલ્યુ માટે ચકાસણી કરી શકે છે. |
07:55 | અહીં આ ટ્યુટોરીયલ સમાપ્ત થાય છે. |
07:58 | સારાંશ માટે, |
08:00 | આ ટ્યુટોરીયલમાં આપણે શીખ્યા , નેસ્ટેડ ઇફ સ્ટેટમેન્ટ.ઉદાહરણ તરીકે :else if( y/10 equals to 0) |
08:08 | સ્વીચ સ્ટેટમેન્ટ.ઉદાહરણ તરીકે: Switch(x) |
08:12 | અને નેસ્ટેડ ઇફ અને સ્વીચ સ્ટેટમેન્ટ વચ્ચેનો તફાવત. |
08:16 | એસાઈનમેન્ટ તરીકે, |
08:17 | કર્મચારીઓની ઉંમર 20 થી 60 વર્ષની અંદર છે કે નહી તે તપાસ કરવા માટેનો પ્રોગ્રામ લખો. |
08:23 | નીચે આપેલ લીંક ઉપર ઉપલબ્ધ વિડીઓ જુઓ. http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial |
08:26 | તે સ્પોકન ટ્યુટોરીયલ પ્રોજેક્ટ માટે સારાંશ આપે છે. |
08:29 | જો તમારી પાસે સારી બેન્ડવિડ્થ ન હોય તો, તમે ડાઉનલોડ કરી તે જોઈ શકો છો |
08:33 | સ્પોકન ટ્યુટોરીયલ પ્રોજેક્ટ ટીમ,સ્પોકન ટ્યુટોરીયલોની મદદથી વર્કશોપ આયોજિત કરે છે. |
08:38 | જેઓ ઓનલાઇન પરીક્ષા પાસ કરે છે તેમને પ્રમાણપત્ર આપે છે. |
08:42 | વધુ વિગતો માટે, contact@spoken-tutorial.org પર સંપર્ક કરો. |
08:49 | સ્પોકન ટ્યુટોરિયલ પ્રોજેક્ટ એ ટોક ટુ અ ટીચર પ્રોજેક્ટનો એક ભાગ છે. |
08:52 | જે આઇસીટી, એમએચઆરડી, ભારત સરકાર દ્વારા શિક્ષણ પર નેશનલ મિશન દ્વારા આધારભૂત છે |
08:58 | આ મિશન વિશે વધુ માહીતી આ લીંક ઉપર ઉપલબ્ધ છે : : http://spoken-tutorial.org\NMEICT-Intro |
09:04 | આઈઆઈટી બોમ્બે તરફથી ભાષાંતર કરનાર હું, કૃપાલી પરમાર વિદાય લઉં છું. જોડાવા બદ્દલ આભાર. |