हिंदी माध्यम नोट्स
Class 6
Hindi social science science maths English
Class 7
Hindi social science science maths English
Class 8
Hindi social science science maths English
Class 9
Hindi social science science Maths English
Class 10
Hindi Social science science Maths English
Class 11
Hindi sociology physics physical education maths english economics geography History
chemistry business studies biology accountancy political science
Class 12
Hindi physics physical education maths english economics
chemistry business studies biology accountancy Political science History sociology
English medium Notes
Class 6
Hindi social science science maths English
Class 7
Hindi social science science maths English
Class 8
Hindi social science science maths English
Class 9
Hindi social science science Maths English
Class 10
Hindi Social science science Maths English
Class 11
Hindi physics physical education maths entrepreneurship english economics
chemistry business studies biology accountancy
Class 12
Hindi physics physical education maths entrepreneurship english economics
chemistry business studies biology accountancy
C++ : For loop in hindi , what is for loop in c++ language , how to write program for loop example
looping मे किसी task को बार बार repeat करने के लिए use किया जाता है | इस तरह के operation के लिए निन्म loops को use किया जाता है |
1.for looping
2.while looping
3.Do-while looping
इस article मे for looping को discuss किया जाता है | for loop को समजने के लिए निन्म उदाहरण को consider किया जाता है |
#include<iostream.h>
#include<conio.h>
void main()
{
using nameapce std;
int a[5];
cout<<“Enter Data : “<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];}
getch();
}
इस उदाहरण मे , array को declare किया जाता है जिसका size ‘5’ है | इसमें array के element को यूजर से input किया जाता है | बाद मे for loop से इन data values को array के index मे assign किया जाता है | अतः इस लूप्मै cin statement 5 बार चलता है |
for loop मे i की value ‘0’ से initial किया जाता है | और i की value जब 5 से छोटी होगी तब तक cin statement को perform किया जाता है | इस loop मे increament को use किया जाताहै |प्रत्येक cin statement के बाद i की value मे increamnet किया जाता है |
Parts of For Looping
for loop मे निन्म steps होती है |
1.Value को initial किया जाता है |
2.condition को check किया जाता है |
3.loop की body को execute किया जाताहै |
4.value को update किया जाता है |
for loop के syntax मे initial , condition और updation को एक ही () मे क्लोज किया जाता है | ये तीन अलग अलग statement होते है जिसे semicolon से अलग अलग किया जाता है | और for loop की body को {} मे लिखा जाता है | for loop की body को test condition के true होने पर execute कियाजाता है |
अतः
for(initial ; condition ; Updation)
{
function body ;
}
c++ मे for loop की body मे एक या एक से अधिक statements को contain कर सकता है | जो की एक task को perform करते है |
c++ मे केवल एक ही initial स्त्स्तेमेंट होता है | जिसमे control variable को किसी value को initial किया जाता है | control variable को loop को control करने एक लिए किया जाता है |
test condition को भी loop को control करने के लिए किया जाता है| ये usually reletion expression होता है |जिसमे दो values को compare किया जाता है | उदाहरण के लिए i<5 जिसमे i की value को ‘5’ से compare किया जाता है | जब इस expression को check किया जाता है | अगर condition की value true होती है तब for loop body को execute किया जाता है |
उदाहरण के लिए :
#include<iostream.h>
#include<conio.h>
void main()
{
using nameapce std;
int a[5];
cout<<“Enter Data : “<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];}
for(i=0;i<5;i++)
{
cout<<“a[“<<i<<“]”<<a[i];
}
getch();
}
इस उदाहरण मे दो फिर loop को use किया जाता है | जिसमे एक array element को read किया जाताहै | और दुसरे for loop से array element को display किया जाता है |
जब i =0 होती तब array ‘a’ के index ‘0’ पर पहली value ’12’ assign हो जाती है |
जब i =1 होती तब array ‘a’ के index ‘1’ पर पहली value ‘123’ assign हो जाती है |
जब i =2 होती तब array ‘a’ के index ‘2’ पर पहली value ’34’ assign हो जाती है |
जब i =3 होती तब array ‘a’ के index ‘3’ पर पहली value ’11’ assign हो जाती है |
जब i =4 होती तब array ‘a’ के index ‘4’ पर पहली value ‘189’ assign हो जाती है |
जब दुसरे loop को consider किया जाता है |तब
जब i =0 होती तब array ‘a’ के index ‘0’ की value ’12’ display हो जाती है |
जब i =1 होती तब array ‘a’ के index ‘1’ की value ‘123’ display हो जाती है |
जब i =2 होती तब array ‘a’ के index ‘2’ की value ’34’ display हो जाती है |
जब i =3 होती तब array ‘a’ के index ‘3’ की value ’11’ display हो जाती है |
जब i =4 होती तब array ‘a’ के index ‘4’ की value ‘189’ display हो जाती है |
Expression or Statement
for loop मे तीन expression होता है | c++ मे syntax मे कई सारे quality होती है | ये expression मे value और values की combination जो की operators को भी contain हो सकती है | उदाहरण के लिए
120;
120+232;
इस Expression मे पहली Expression से 120 value है और दूसरी Expression से 352 value है |अतः दुसरे Expression मे दो value को add किया जाता है | जो की किसी फाइनल value को assign किया जाता है |
इसके अलावा
int a=20;
ये Expression है जो की एक value और variable ‘a’ और assignment operator को use किया जाता है | assignment operator से value 20 को variable ‘a’ के address पर store किया जाता है |
इसके लावा
int a= (b+3)*3;
ये भी Expression होता है |
इसके अलावा
int a = (int b =5)+3;
ये भी Expression है जिसमे value ‘5’ , variable b मे assign किया जाता है | और इस value को ‘3’ से add किया जाता है | c++ मे ये Expression को allow किया जाता है | लेकिन इस Expression को कम ही use किया जाता है |
इसके अलावा
a=b=c=0;
जब दो या दो से अचिक variable को initial किया जाता है तब इस statement को use किया जाता है |
इस article मे for loop के basic को discuss किया है अब age C++ : For Looping(Advance) मे for loop के advance topics को discuss करेगे |
Recent Posts
द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन क्या हैं differential equations of second order and special functions in hindi
अध्याय - द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन (Differential Equations of Second Order…
नियत वेग से गतिशील बिन्दुवत आवेश का विद्युत क्षेत्र ELECTRIC FIELD OF A POINT CHARGE MOVING WITH CONSTANT VELOCITY in hindi
ELECTRIC FIELD OF A POINT CHARGE MOVING WITH CONSTANT VELOCITY in hindi नियत वेग से…
four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं
चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…
Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा
आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…
pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए
युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…
THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा
देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…