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 find a prime number , an armstrong number , to compare two strings

इससे पहले के article मे कई उदाहरनो को discuss किया जाता है अब इस article मे , हम कई उदाहरनो को discuss करेगे जिससे आपके c++ के concept को discuss करगे | सबसे पहले डट type और variable देक्लार्तिओं और looping के उदाहरनो को discuss करेगे |उदाहरन -1
Write a program to find a prime number.
इस उदाहरनो मे ,  prime number को find किया जाता है |
explantion
सबसे पहले यूजर द्वारा value को input किया जाता है जिसको variable ‘a’ को assign किया जाता है |
उसके बाद condition को check किया जाता है | condition मे , अगर value किसी number से divide होता जो की ‘2’ से start होते है तब ये value prime number होती है |
अन्यथा ये number prime number नहीं होती है |
इसके बाद प्रोग्राम को end कर देते है |
source code
#include<iostream.h>
#include<conio.h>
int prime (int);
void main()
{
int a,c;
cout<<“Enter a :”<<endl;
cin>>a;
c= prime(a);
if(c==1)
{
cout<<a<<“is Prime number.”;
}
else
{
cout<<a<<“is not Prime number.”;
}
}
getch();
}
int compare (int e)
{
int i ;
if(e<=1)
{
return 0;
}
int count ;
for(i=2;i<=e/2;i++)
{
if((e%i)==0)
{
return 1;
break;
}
}
}

उदाहरन -2
Write a program to find an armstrong number.
इस उदाहरनो मे ,  armstrong number को find किया जाता है |
explantion
armstrong number ये number होते है जीके लिए निन्म condition फॉलो होते है :-
अगर number = 123 होती है  तब  123 = (1*1*1)+(2*2*2)+(3*3*3)
जब इस condition true होती है तब value armstrong number होगी अन्यथा value armstrong number नहीं है |
सबसे पहले यूजर द्वारा value को input किया जाता है जिसको variable ‘a’ को assign किया जाता है |
उसके बाद value से last डिजिट को find किया जाता है जिसके cube को sum मे add किया जाता है | और फिर second digit के cube को sum मे add किउया जाट है |
उसके बाद पहली डिजिट के cube को sum मे add किये जाता है |
अगर sum = value हो ती है तब value को armstrong number होगी |
अन्यथा value armstrong number नहीं होगी |
source code
#include<iostream.h>
#include<conio.h>
int armstrong (int);
void main()
{
int a,c;
cout<<“Enter a :”<<endl;
cin>>a;
c=  armstrong (a);
if(c==a)
{
cout<<a<<“is armstrong number .”;
}
else
{
cout<<a<<“is not armstrong number .”;
}
}
getch();
}
int armstrong (int e)
{
int sum =0;
int i=e ;
while(i>0)
{
r=i%10;
sum = sum + (i*i*i);
i=i/10;
}
return (sum);
}

उदाहरन -3
Write a program to compare two strings .
इस उदाहरनो मे ,  दो string को compare किया जाता है |
explantion
सबसे पहले दो string variable को declare किया जाता है |
उसके बाद यूजर द्वारा string value को input किया जाता है | इसे string variables मे assign कर दिया जाता है |
looping की जाती है |
जब i=0 होती है तब दोनों string के first elements को compare किया जाता है |
जब i=1 होती है तब दोनों string के second elements को compare किया जाता है |
जब i=2 होती है तब दोनों string के third elements को compare किया जाता है |
जब i=3 होती है तब दोनों string के fourth elements को compare किया जाता है |
जब i=4 होती है तब दोनों string के  fifth elements को compare किया जाता है |
जब i=5 होती है तब दोनों string के  sixth  elements को compare किया जाता है |
ये loop तब तक चलता है जब तक string मे  ‘\0’ pointer नहीं आ जाता है |
अगर string मे character मे match नहीं होता है तब Both string are not same. अन्यथा  Both string are same. massage display होगा |
source code
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
string a,b;
cout<<“Enter string :”<<endl;
cin>>a;
cout<<“Enter string :”<<endl;
cin>>b;
for(i=0;a[i]!=”\0″ && b[i]!=”\0” ; i++ )
{
if(a[i]==b[i])
{
count =0;
}
else
{
count =1 ;
}
}
if(count==0)
{
cout<<“Both string are same.”;
}
else
{
cout<<“Both string are not same.”;
}
getch();
}

उदाहरन -4
Write a program to add two strings .
इस उदाहरनो मे ,  दो string को add किया जाता है |
explantion
सबसे पहले दो string variable को declare किया जाता है |
उसके बाद यूजर द्वारा string value को input किया जाता है | इसे string variables मे assign कर दिया जाता है |
उसके बाद string class मे उपस्थित strcat() function से string को जोड़ा जाता है | इसके लिए merge string को एक नए string मे assign किया जाता है |
इसके बाद इस string variable को display किया जाता है |
source code
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
string a,b,c;
cout<<“Enter string :”<<endl;
cin>>a;
cout<<“Enter string :”<<endl;
cin>>b;
c=strcat(a,b);
cout<<“Merge string : “<<c<<endl;
getch();
}

उदाहरन -5
Write a program to display a fibbocaci series .
इस उदाहरनो मे ,  fibbocaci seriesफी को display किया जाता है |
explantion
fibbocaci series निन्म होती है
0 1 1 2 3 5 8 13 21
इसके लिया यूजर द्वारा fibbocaci series के range को input किया जाता है जिसके use fibbocaci series की limit को display किया जाता है |
इसके बाद loop चलाया जाता है | इसमें
अगर i की  value ‘1’ के सामान और छोटी होती है तब fibbocaci series series के  element , i की value को display किया जाता है |
अन्यथा c= first + second display होता है |
source code
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
int  a=0,b=1,c;
int range ;
cout<<“enter range :”;
cin>>range;
for(i=0;i<range;i++)
{
if(i<=1)
{
b=i;
}
else
{
c=a+b;
a=b;
b=c;
}
cout<<c;
};

Sbistudy

Recent Posts

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

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

1 day ago

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

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

3 days ago

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

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

5 days ago

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

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

5 days ago

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

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

5 days ago

FOURIER SERIES OF SAWTOOTH WAVE in hindi आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित

आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित FOURIER SERIES OF SAWTOOTH WAVE in…

1 week 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