JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

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

Home science Geography

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

Categories: c++ language in hindi

Write a program to check a number Armstrong , palindrome condition by using class , even – odd

इससे पहले के article मे , class के उदाहरनो को discuss किया तह | लेकिन अब इस article मे कुछ advance उदाहरानो को discuss करेगे जिसे आप  सभी को पहले खुद try करना चाहिए | जिससे आप सभी के c++ language के सबसे महतवपूर्ण concept class + object को मजबूत हो सके  |
उदहारण -1
Write a program to check a number Armstrong , palindrome condition by using class .
Explanation
सबसे  पहले class check को declare किया जाता है | इस class मे एक variable number को calculate किया जाता है  इन सभी variable का access mode public है अतः इन variable को main() और class check मे use किया जा सकता है |
class check मे दो  functions को declare किया जाता है |
Armstrong() : इसका access mode public है | इसमें Armstrong number की condition को check किया जाता है | इसे main() के साथ class check मे भी use किया जा सकता है |
parlidlom () : इसका भी  access mode public है | इसमें palindrome number की condition को check किया जाता है | इसे main() के साथ check  class मे भी use किया जा सकता है |
parlidlom() mai
सबसे पहले function मे यूजर द्वारा input की गयी number को pass किया जाता है | Armstrong number को check करने के लिए loop को चलाया जाता है |
loop मे control variable को number से initial किया जाता है | ये loop तब तक चलाया जाता अहि जब तक control variable की value ‘0’ नहीं होती है |
loop की body मे , remainder = i % 10 ; से remainder को calculate किया जाता है | इसके बाद check variable मे  check + remainder *10  को assign किया जाता है |
इसके बाद control variable को number /10 से update किया जाता है |
इसके बाद number और check की value को check किया जाता है |
अगर दोनों की value सामान होती है तब number is parlidlom का message print हो जाता है | अन्यथा  number is not parlidlom. display होगा |
Armstrong() मे ,
सबसे पहले function मे यूजर द्वारा input की गयी number को pass किया जाता है | armstorng number को check करने के लिए loop को चलाया जाता है |
loop मे control variable को number से initial किया जाता है | ये loop तब तक चलाया जाता अहि जब तक control variable की value ‘0’ नहीं होती है |
loop की body मे , remainder = number % 10 ; से remainder को calculate किया जाता है | इसके बाद check variable मे remainder*remainder*remainder को add किया जाता है |
इसके बाद control variable को number /10 से update किया जाता है |
इसके बाद number और check की value को check किया जाता है |
अगर दोनों की value सामान होती है तब number is Armstrong का message print हो जाता है | अन्यथा  number is not Armstrong. display होगा |
palindrome () मे ,
इस function मे यूजर द्वारा input किये गये number को pass करते है |
#include<iostream.h>
#include<conio.h>
class check {
public :
int remainder , check ;
public:
void armstorng(int number )
{
int i =0;
i=number ;
while(i != 0 )
{
remainder = i % 10 ;
check += remainder*remainder*remainder’
i = i /10;
}
if(check == number )
{
cout<<“number is armstorng” ;
}
else
{
cout<<“number is not armstorng “;
}
void parlidlom(int number )
{
int i =0;
i=number ;
while(i != 0 )
{
remainder = i % 10 ;
check = check + remainder *10;
i = i /10;
}
if(check == number )
{
cout<<“number is parlidlom.” ;
}
else
{
cout<<“number is not parlidlom.”;
}
}
};
void main()
{
check.c;
int num;
cout<<“Enter Number :”<<endl;
cin>>num;
c.armstorng(num);
c.parlidlom(num);
getch();
}
उदहारण -2
Write a program to find even – odd  using class within range.
Explanation
र्सबसे पहले class condition को declare किया जाता है | इस class मे  किसी range मे उपस्थित even or odd element को find किया जाता है |
class math मे  दो function को discuss किया जाता है |
even () : इसका access mode public है | अतः इसे main() के साथ class condition  मे भी use किया जा सकता है | इसमें first और last element को pass किया जाता है |
odd () : इसका भी  access mode public है | अतः इसे main() के साथ class condition  मे भी use किया जा सकता है |
void even () मे  first और last को pass किया जा सकता है |
उसके बाद loop चलाया जाता है |
loop मे control variable को first element से initial किया जाता है | ये loop तब तक चलता है जब तक इसकी value last से कम या सामान होती है |
loop की body मे  control variable पर even की condition को check किया जाता है | अगर condition true है तब number print हो जाता है |
इस loop के body को एक बार excute होने के बाद control variable को ‘1’ से update करता है |
void odd() मे  first और last को pass किया जा सकता है |
odd condition की check करने के लिए loop चलाया जाता है |
loop मे control variable को first element से initial किया जाता है | ये loop तब तक चलता है जब तक इसकी value last element से कम या सामान होती है |
loop की body मे  control variable पर odd की condition को check किया जाता है | अगर condition true है तब number print हो जाता है |
इस loop के body को एक बार excute होने के बाद control variable को ‘1’ से update करता है |
#include<iostream.h>
#include<conio.h>
class condition {
public:
void even (int first ,int second )
{
cout<<“Even Number in Range “;
for ( int i = first ; i < = last ; i++)
{
if((i%2)==0)
cout<<i;
}
}
void odd (int first ,int second )
{
cout<<“Odd Number in Range “;
for ( int i = first ; i < = last ; i++)
{
if((i%2)!=0)
cout<<i;
}
}
};
void main()
{
condition c;
int a,b ;
cout<<“Enter first element : “;
cin>>a;
cout<<“Enter last  element : “;
cin>>b;
c.even (a,b);
c.odd(a,b);
getch();
}
Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

2 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

6 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

6 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

6 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now