हिंदी माध्यम नोट्स
Write a program to print SD and Average using class , find maximum और minimum using class
Write a program to print SD and Average using class
Explanation
र्सबसे पहले class math को declare किया जाता है | इस class मे तीन variable avg, variance और Standard_devation को calculate किया जाता है in सभी variable का access mode public है अतः इन variable को main() और class math मे use किया जा सकता है |
class math मे तीन function को देकाल्रे किया जाता है |
avg() : इसका access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
variance() : इसका भी access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
SD(): इसका access mode private है अतः इसे केवल class मे ही use किया जा सकता है |
int avg() मे array और size को pass किया जा सकता है |
इस function मे , array के element को addition किया जाता है | इसे sum variable मे assign किया जाता है |
इसके बाद avg= sum / size से average को calculate किया जाता है |
इस avg को print किया जाता है |
void variance () मे , int avg , array और size को pass किया जाता है | इसमें main() function से class math से variable avg को भी पास किया जाता है |
इसके बाद variance को calcualte किया जाता है |
और variance की value print किया जाता है |
void SD() मे , variance को पास किया जाता है |इस function को main() function मे call नही किया जाता है |
जब variance को call किया जाता है तब variance और Standard_devation को calcualte किया जाता है |
#include<iostream.h>
#include<conio.h>
class math{
public :
int avg;
float variance , Standard_devation ;
public:
void avg(int a[],size)
{
for(i=1;i<size;i++)
{
int sum = sum + a[i];
}
avg= sum /size;
cout<<“Averge :”<<avg;
}
void variance ( int mean , int a[], int size )
{
int b[size];
for(i=1;i<size;i++)
{
b[i]=mean-a[i];
}
for(i=1;i<size;i++)
{
int sum = sum + b[i] * b[i];
}
variance = sum / size;
cout<<“Variance :”<<variance;
cout<<“Standard Deviation”<<SD(variance);
}
private :
int SD( float var)
{
Standard_devation = sqrt(var);
return Standard_devation;
}
};
void main()
{
math m;
int array[10];
cout<<“Array Element :”<<endl;
for(int i =0 ; i<10;i++)
{
cin>>array[i];
}
m.avg(array ,10 );
m.variance(m.avg , array , 10);
getch();
}
उदहारण -2
Write a program to find maximum और minimum using class
Explanation
र्सबसे पहले class math को declare किया जाता है | इस class मे maximum और minimum element को find किया जाता है | variable m का access mode public है अतः इन variable को main() और class math मे use किया जा सकता है |
class math मे दो function को discuss किया जाता है |
minimum () : इसका access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
maximum () : इसका भी access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
void maximum () मे array और size को pass किया जा सकता है |
इस function मे , variable ‘m’ को array के first element से initial किया जाता है |
उसके बाद loop चलाया जाता है |
loop की body मे m का comparsion array के element से करवाते है | अगर m की value array के element से छोटी होती है तब m और array के value मे swaping हो जाता है |
इस loop के end मे m की value array मे उपस्थित सभी elements मे सबसे बड़ी value को hold करता है |
void minimum () मे array और size को pass किया जा सकता है |
इस function मे , variable ‘m’ को array के first element से initial किया जाता है |
उसके बाद loop चलाया जाता है |
loop की body मे m का comparsion array के element से करवाते है | अगर m की value array के element से बड़ी होती है तब m और array के value मे swaping हो जाता है |
इस loop के end मे m की value array मे उपस्थित सभी elements मे सबसे बड़ी value को hold करता है |
#include<iostream.h>
#include<conio.h>
class math{
public :
int m ;
public:
void maximum(int a[],size)
{
m=a[1];
for(i=1;i<=size;i++)
{
if(m< a[i])
{
int temp;
temp = a[i];
a[i] = m;
m = temp ;
}
cout<<“Maximum Element :”<<m;
}
void minimum (int a[],size)
{
m=a[1];
for(i=1;i<=size;i++)
{
if(m > a[i])
{
int temp;
temp = a[i];
a[i] = m;
m = temp ;
}
cout<<“Minimum Element :”<<m ;
}
};
void main()
{
math c;
int array[10];
cout<<“Array Element :”<<endl;
for(int i =0 ; i<10;i++)
{
cin>>array[i];
}
c.minimum(array ,10 );
c.maximum(array , 10);
getch();
}
उदहारण -3
Write a program to find addition और subtraction of two matrix using class
Explanation
र्सबसे पहले class math को declare किया जाता है | इस class मे addition और subtraction element को find किया जाता है |
class math मे दो function को discuss किया जाता है |
addition () : इसका access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
subtraction () : इसका भी access mode public है | अतः इसे main() के साथ class मे भी use किया जा सकता है |
void addition () मे दोनों array और size को pass किया जा सकता है |
इस function मे , variable ‘c’ मे array के elements को add किया जाता है |
void subtraction () मे दोनों array और size को pass किया जा सकता है |
इस function मे , variable ‘c’ मे array के elements को subtract किया जाता है |
#include<iostream.h>
#include<conio.h>
class math{
public:
void addition (int a[],int b[] , int size )
{
int c[size][size];
for(i=1;i<=size;i++)
{
for(j=1;j<size;j++)
{
c[i][j] = a[i][j]+b[i][j];
}
}
for(i=1;i<=size;i++)
{
for(j=1;j<size;j++)
{
cout<<c[i][j];
}
cout<<endl;
}
}
void subtraction(int a[],int b[] ,int size )
{
int c[size][size];
for(i=1;i<=size;i++)
{
for(j=1;j<size;j++)
{
c[i][j] = a[i][j]-b[i][j];
}
}
for(i=1;i<=size;i++)
{
for(j=1;j<size;j++)
{
cout<<c[i][j];
}
cout<<endl;
}
}
};
void main()
{
math m;
int a[3][3],b[3][3];
cout<<“Enter elements of first array :”<<endl;
for(i=0;i<3;i++)
{
for(j=0;j=3;j++)
{
cin>>a[i][j];
}
}
cout<<“Enter elements of second array :”<<endl;
for(i=0;i<3;i++)
{
for(j=0;j=3;j++)
{
cin>>a[i][j];
}
}
m.addition(a,b);
m.subtraction(a,b);
getch();
}
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…