संदेश

Array in C++ & Programs

चित्र
  Array  " एक ही प्रकार के Data Type के कई variables के sequence (क्रम) को Array कहा जाता है | " Array एक derived data type है | जैसा कि हम जानते हैं कि एक समय पर एक variable में मात्र एक ही value store की जा सकती है, किन्तु Array के माध्यम से एक समय पर एक ही variable में कई values एक साथ store करना संभव है |  C++ Program में array define करने के लिए variable declare करते समय variable के बाद square braces ([ ]) का use किया जाता है तथा Square braces के बीच एक constant number लिखा जाता है, जिसे subscript या index कहा जाता है |  Subscript, Array में create होने वाले variables की संख्या को दर्शाता है अर्थात array में उतनी ही संख्या में variables create होते हैं, जो संख्या subscript के रूप में दी जाती है तथा प्रत्येक variable का एक ही नाम होता है किन्तु variable को identify करने के लिए प्रत्येक variable के index अलग अलग होते हैं | Array के प्रथम variable का index, by default 0 से start होता है |  ex:   उपरोक्त उदहारण में Array variable a का subscript 5 निर्धारित...

Nested Loop in C++, Number Pattern & Star Pattern

चित्र
Nested Loop  जब किसी looping statement के अंदर अन्य loop statement define किया जाता है, ऐसे Looping statement को Nested Loop कहा जाता है |  Syntax: for(... ; ... ; ...) {      for(... ; ... ; ...)      {          ............... ;          ............... ;     } } * Program to print following series - 3     6     9     2     4     6     12     15     18     8     10     12     .     .     .     .     . * Program to print following Number Pattern - 1 23 456 78910 * Program to print following Number Pattern - 1 22 333 4444 55555 * Program to print following Number Pattern -         1       22     333   4444 55555 * Program to print following Number Pattern -       ...

Various Looping Programs in C++

चित्र
  * Program to print table of a given number: Output: * Program to print following series: 3     2     6     4     9     6     12     8     .     .     .     .     .     .     . Output: * Program to print Fibonacci series: 0     1     1     2     3     5     8     13     21     34     .     .     .     .     .     .     . Output: * Program to print following series: 2     6     11     17     24     32     41     51     .     .     .     .     . Output: * Program to find factorial of a given number: Output: * Program to check a given number is Prime or Not: Output: * Pro...

Switch Case and Looping Statements in C++

चित्र
  switch . . . . . case Statement  यह एक Control Statement है | जब C++ program में हम अनेकों options apply करना चाहते हैं, तब switch . . . case statement का use करते हैं, इसीलिए इसे multiple choice statement भी कहा जाता है |  इस Statement का use करने के लिए एक variable में value input कराने के बाद उस variable को switch variable बना दिया जाता है, तथा switch statement के अंदर आवश्यकतानुसार विभिन्न cases define कर दिए जाते हैं | Program execution के दौरान compiler switch variable की value check करता है तथा variable की value से सम्बंधित case को execute कर देता है |   syntax: switch(variable) { case ...: ................. ................. case ...: ................. ................. case n: ................. ................. } * Program to print weekday: Output: Iteration जब C++ program में किसी विशेष statement को या program के किसी निश्चित part को बार बार repeat कराया जाता है, इस process को Iteration कहा जाता है |  Looping Statement  C++ program में Ite...

Control Statements in C++

चित्र
Control Statement  C++ Program में ऐसे statements, जो अन्य statements या program execution के flow को control या handle करते हैं, इन्हे Control Statements कहा जाता है |  दूसरे शब्दों में हम कह सकते हैं कि जिन Statements पर program के कुछ अन्य statements निर्भर करते हैं, उन्हें Control Statements कहा जाता है |  जैसे -  if . . . . . . else  nested if  ladder if  switch . . . . . . case  do . . . . . . .while  while  for  if . . . . else statement यह एक Conditional Statement होता है | जब हम C++ program में कोई Condition apply करना चाहते हैं, तब if . . . . else statement का use करते हैं |  इन Statement का use करने के लिए if के बाद parenthesis () लगाया जाता है तथा parenthesis के अंदर condition लिखी जाती है : if (condition) यदि parenthesis में लिखी हुई condition true होती है, तो if (condition) के बाद लिखे गए statement को execute किया जाता है तथा यदि condition false हो जाती है, तो program, if के बाद लिखे गए statement को jump कर जाता ह...