November 2021 - .OnlineGuruji

.OnlineGuruji

Provides E-Notes,Video Tutorials And Download Links For Students In hindi

*********************************************************

*********************************************************
********************************************************************************

Breaking

Ramchandicollege Saraipali

Technology Jobs

OnlineGuru Blog मे आपका स्वागत है ब्लॉग से संबन्धित जानकारी के लिए संपर्क करें मो ॰ नम ।-9826026747(सपन कुमार दास) अपने विषय से संबन्धित अपडेट प्राप्त करने के लिए ब्लॉग पे दिये गए Bell Icon को press करें कम्प्युटर,Science,English Grammer से संबन्धित विषय की अधिक जानकारी के लिए हमारे ब्लॉग अथवा यू ट्यूब चैनल को सब्क्राइब करे ..

Monday, November 29, 2021

November 29, 2021

Loops In C Language By:-Sapan Das

Loops In C Language

इस ब्लॉग में हम c language में पाए जाने वाले विभिन्न लूप के बारे में पढेंगे

What Is Loops In C :-----

लूप कि सहायता से हम प्रोग्राम में sequence ऑफ़ statement को तब तक एक्सीक्यूट करा सकते है जब तक कि वह स्टेटमेंट दिए गए शर्त अथवा condition को पूरा नहीं करता 

प्रोग्रामिंग लूप के दो भाग होते है पहला body of loop और दूसरा control statement  जिसमे control स्टेटमेंट दिए गए condition को चेक  करता है अगर condition सही होता है तो body of loop execute होते रहता है |

लूप में control के स्थिति के आधार पर इसे दो वर्गों में विभाजित किया गया है 

1. Entry level Loop 

एंट्री control लूप में पहले condition टेस्ट होता है अगर condition सही होता है तभी body of loop एक्सीक्यूट होता है इसे हम top tested loop के नाम से भी जानते है 

2. Exit level Loop

एग्जिट  control लूप में पहले body of loop एक्सीक्यूट होता है फिर condition टेस्ट होता है अगर condition सही होता है तो फिर से body of loop एक्सीक्यूट होता है   इसे हम Bottom  tested loop के नाम से भी जानते है 


 






किसी Looping Process में मुख्यतः चार  स्टेप होते है 

1. कंडीशनल अथवा काउंटर variable को set तथा इनिशियलाइज़ करना

2. specified value को  दिए गए कंडीशन के साथ टेस्ट करते है 

3.body of loop को एक्सीक्यूट करते है 

4. Counter वेरिएबल को    Increament/ Decreament  कर update करते है 

C Language में मुख्यतः टीम प्रकार के loop पाए जाते है 

1 FOR LOOP

2. While loop

3. Do While Loop

1. for loop :--

for loop क लैंग्वेज में entry controlled loop के अंतर्गत आता है यह तीनो loop में shortest loop है क्यूंकि

इसमें loop के सभी स्टेप सिंगल लाइन में हो जाता है अर्थात initialization ,increment/ decrement और test condition एक ही लाइन में होता है 

Syntax;-

for( initialization; test-condition; increment/decrement)
{
body of the loop;
}











Prog:- Write a program to print the series from o to 10 using for loop

#include<stdio.h>

#include<conio.h>

void main()

{

int i;

clrscr();

for(i=0;i<=10;i++)

{

printf("%d\n",i);

}

getch();

}










Prog:- Write a programe to calculate the factorial of given number

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i;

int fact=1;

printf("Enter any number");

scanf("%d",&n);

if(n<=0)

{

printf("Error!Factorial of Negative or zero Number does not exist");

}

else

{

for(i=1;i<=n;i++)

{

fact=fact*i;

}

printf("factorial of %d=%d",n,fact);

}

getch();

}

Output:--





Saturday, November 27, 2021

November 27, 2021

Switch Case Statement By: Sapan Das

 


C लैंग्वेज में स्विच केस स्टेटमेंट का उपयोग दिए गए विकल्पों में से किसी एक विकल्प को चुनने के लिए किया जाता है | यह एक कण्ट्रोल स्टेटमेंट स्टेटमेंट है जो हमें कई विकल्पों में से चुनने का सुविधा प्रदान करता है |

स्विच में एक expression पास किया जाता है जिसे भिन्न भिन्न केस में दिए गए विकल्पों के साथ तुलना किया जाता है और जिस भी केस विकल्प के साथ स्विच का expression match होता है उसी केस का स्टेटमेंट एक्सीक्यूट होता है यदि कोई भी केस वैल्यू स्विच expression से match नहीं होता है तो डिफ़ॉल्ट स्टेटमेंट एक्सीक्यूट होता है |

syntax:-

switch(expression)

{

case constant-1:

statement-1;

break;

case constant-2:

statement-2;

break;

case constant-3:

statement-3;

break;

-----------

..............

case constant-n:

statement-n;

break;

default :

statement;

}

उपर दिए गए syntax में constant या तो character हो सकता है या integer हो सकता है |

जब स्विच स्टेटमेंट को एक्सीक्यूट किया जाता है तो expression का मूल्यांकन किया जाता है और जिसका केस वैल्यू expression से match होता है  कण्ट्रोल को सीधे उस  स्टेटमेंट के समूह में ट्रान्सफर किया जाता है |

अगर कोई भी केस वैल्यू expression से match नहीं करता है तो default ब्लाक execute होता है  और अगर कोई भी केस वैल्यू expression से match नहीं खता है और साथ में default ब्लाक भी नहीं है तो switch द्वारा कोई भी action नहीं लिया जाता है और control स्विच से बहार ट्रान्सफर हो जाता है |

Flowchart:-



Example:-
#include<stdio.h>

#include<conio.h>

void main()

{

int n1,n2;

char oper;

printf("Enter Any Arithmatic Operator\n");

scanf("%c",&oper);

printf("Enter Any Number");

scanf("%d%d",&n1,&n2);

switch(oper)

{

 case '+':

 printf("%d+%d= %d",n1,n2,n1+n2);

 break;

case '-':

 printf("%d-%d=%d",n1,n2,n1-n2);

 break;

case '*':

 printf("%d*%d=%d",n1,n2,n1*n2);

 break;


case '/':

 printf("%d/%d=%d",n1,n2,n1/n2);

 break;

   default:

   printf("Invalid Operator");

}

getch();

}

OUTPUT:-






Prog:-Write a Menu Driven Program using Switch case for find sum of two number, area of circle and simple interest through user choice

#include<stdio.h>

#include<conio.h>

void main()

{

int choice;

Float rd,area;

int n1,n2,n;

int si,p,r,t;

clrscr();

printf("Press 1 for addition of two number\n");

printf("Press 2 for Simple Interest\n");

printf("Press 3 for Area of Circle\n");

switch(choice)

{

 case 1:

 printf("Enter any two number");

 scanf("%d%d",&n1,&n2);

 n=n1+n2;

 printf("Sum of two number=%d",n);

 break;

 case 2:

 printf("Enter any two number");

 scanf("%d%d%d",&p,&r,&t);

 si=(p*r*t)/100;

 printf("Simple Interest=%d",si);

 break;

Case 3:

printf (" Enter Radious");

scanf ("%f",&rd);

area=3.14*rd*rd;

printf ("Area of Circle=%f",area);

Break;

default:

printf("Invalid Entry");

}

 getch();

}







Prog 3:- Wriite a program to calculate consonent and vowel for given character using switch case

#include<stdio.h>

#include<conio.h>

void main()

{

 char c;

 clrscr();

 printf("Enter any character\n");

 scanf("%c",&c);

 switch(c)

{

 case 'a':

 case 'A' :

 printf("Enter character is vowel");

 break;

  case 'e' :

  case 'E' :

 printf("Enter character is vowel");

 break;

 case 'i':

 case 'I' :

 printf("Enter character is vowel");

 break;

 case 'o':

 case 'O' :

 printf("Enter character is vowel");

 break;

 case 'u':

 case 'U' :

 printf("Enter character is vowel");

break;


 default :

 printf("Enter character is consonent");

}

 getch();

 }