write a program to calculate notes in the amount using class , valid entry or angles of the triangle using class

इससे से पहले के article मे class के  उदाहरनो को discuss किया था | अब इस article मे class मे कुछ और उदाहरनो को discuss करेगे जिससे आप सभी c++ language के class syntax मे बहुत ही अच्छी तरह से समज  सके  |1.Program 1
write a program to calculate notes in the amount using class .

Explanation
सबसे पहले यूजर द्वारा amount को input करता है |
इसके बाद object a के function check () मे amount को pass किया जाता है और call किया जाता है |
class amount मे function check () मे ,
इसके बाद यूजर द्वारा declare किये गये amount variable मे assign किया जाता है |
अगर amount की value 2000 से बड़ी होती है तब 2000 के note की  value को  amount को  2000  से  डिवाइड करके  calculate किया जाता है | इसके बाद amount को amount – note2000*2000 update किया जाता है |
अगर amount की value 500 से बड़ी होती है तब 500 के note की  value को  amount को  500   से  डिवाइड करके calculate किया जाता है | इसके बाद amount को amount – note500*500 update किया जाता है |
अगर amount की value 50 से बड़ी होती है तब 50 के note की  value को  amount को  50   से  डिवाइड करके calculate किया जाता है | इसके बाद amount को amount – note50*50 update किया जाता है |
अगर amount की value 100 से बड़ी होती है तब 100 के note की  value को  amount को   100  से  डिवाइड करके calculate किया जाता है | इसके बाद amount को amount – note100*100 update किया जाता है |
अगर amount की value 200 से बड़ी होती है तब 200 के note की  value को  amount को    200  से  डिवाइड करके calculate किया जाता है | इसके बाद amount को amount – note200*200 update किया जाता है |
अगर amount की value 20 से बड़ी होती है तब 20 के note की  value को  amount को    20  से  डिवाइड करके calculate किया जाता है | इसके बाद amount को amount – note20*20 update किया जाता है |

Source Code :
#include<iostream.h>
#include<conio.h>
class amount ()
{
private :
int note2000,note500,note200,note100,note20,note50;
public :
void check(int amount)
{
if(amount>2000)
{
note2000=amount/2000;
amopunt = amount – note2000*2000;
}
if(amount>2000)
{
note2000=amount/2000;
amopunt = amount – note2000*2000;
}
if(amount>500)
{
note500=amount/500;
amopunt = amount – note500*500;
}
if(amount>200)
{
note200=amount/200;
amopunt = amount – note200*200;
}
if(amount>100)
{
note100=amount/100;
amopunt = amount – note100*100;
}
if(amount>50)
{
note50=amount/50;
amopunt = amount – note50*50;
}
cout<<“Note od Rs 2000 : “<<note2000<<endl;
cout<<“Note od Rs 500 : “<<note500<<endl;
cout<<“Note od Rs 200 : “<<not200<<endl;
cout<<“Note od Rs 100 : “<<note100<<endl;
cout<<“Note od Rs 50 : “<<note50<<endl;
}
};
void main()
{
amount.a;
int amount ;
cout<<“Enter Amount : “<<endl;
cin>>amount;
a.check(amount);
getch();
}

2.Program 2
write a program to check valid entry or sides of the triangle.

Explanation
1.सबसे पहले header feild मे  class check को define किया जाता है |इस class math मे   तीन data variables को declare किया गया है | इन variables का access mode private है इसका मतलब इन variables केवल class मे use किया जाता है | इसके अलावा function condition ( ) को भी define किया जाता है | दोनों functions का access mode public है |
condition() मे ,
1.i-सबसे पहले function definition मे  condition को define किया जाता है | यह पर ‘ p’ , ‘q’ और ‘r’ formal parameter है जिसमे actual parameter ‘a’,’b’ और ‘c’ से intial किया जाता है |
1.ii-उसके  बाद (a+b>c) और (a+c>b) और ( b+c>a)  को check किया जाता  है |
1.iii- अगर condition true है तब  sides are perfect , print किया जाता है |
1.iv- अगर condition false है तब sides are not perfect , print होगा |

2.उसके बाद  main() function मे   check class के लिए एक object c को declare किये जाता है | एक variable ‘a’,’b’ और ‘c’ को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा  value को input करा लेते है और इन value को  variable ‘a’,’b’ और ‘c’ मे assign करा देते है |
4. जिसमे class math के functions check() को call किया जाता है |

#include<iostream.h>
#include<conio.h>
int check(int , int ,int );
class condition
{
private :
int p,q,r;
public:
int check(int p,int q,int r)
{
if((p+q>r) && (p+r>q) && (q+r>p))
{
count = 0;
}
else{
count =1;
}
return count;
}
};
void main()
{
int a,b,c;
cout<<“Enter side1 :”<<endl;
cin>>a;
cout<<“Enter side2 :”<<endl;
cin>>b;
cout<<“Enter side3 :”<<endl;
cin>>c;
int count = check(a,b,c);
if(count==1)
{
cout<<“sides are perfect”;
}
else
{
cout<<“sides are not perfect”.<<endl;
}
getch();
}

3.Program 3
write a program to check valid entry or angles of the triangle using class .

Expalnation
1.सबसे पहले header feild मे  class check को define किया जाता है |इस class math मे   तीन data variables को declare किया गया है | इन variables का access mode private है इसका मतलब इन variables केवल class मे use किया जाता है | इसके अलावा function condition ( ) को भी define किया जाता है | दोनों functions का access mode public है |
condition() मे ,
1.i-सबसे पहले function definition मे  condition को define किया जाता है | यह पर ‘ p’ , ‘q’ और ‘r’ formal parameter है जिसमे actual parameter ‘a’,’b’ और ‘c’ से intial किया जाता है |
1.ii-उसके  p+q+r == 180 को check किया जाता  है |
1.iii- अगर condition true होती है तब  angles are perfect print होगा |
1.iv- अगर condition false होता है तब angles are not perfect print होगा |

2.उसके बाद  main()function मे   check class के लिए एक object c को declare किये जाता है | एक variable ‘a’,’b’ और ‘c’ को declare किया गया है |
3. जिसमे class math के functions check() को call किया जाता है जिसमे  ‘a’,’b’ और ‘c’ pass किया जाता है |

#include<iostream.h>
#include<conio.h>
class condition
{
private :
int p,q,r;
public:
int check(int p,int q,int r)
{
if(p+q+r == 180 )
{
count = 0;
}
else{
count =1;
}
return count;
}
};
void main()
{
condition c;
int a,b,c;
cout<<“Enter angle1 :”<<endl;
cin>>a;
cout<<“Enter angle2 :”<<endl;
cin>>b;
cout<<“Enter angle3 :”<<endl;
cin>>c;
int count = c.check(a,b,c);
if(count==1)
{
cout<<“angles are perfect”;
}
else
{
cout<<“angles are not perfect”.<<endl;
}
getch();
}

4.Program 4
write a program to calcualate loss और profit using class .

Expalnation
1.सबसे पहले header feild मे  class math को define किया जाता है |इस class math मे   दो data variables को declare किया गया है | इन variables का access mode private है इसका मतलब इन variables केवल class मे use किया जाता है | इसके अलावा function profit () और loss() को भी define किया जाता है | दोनों functions का access mode public है |
profit() मे ,
1.i-सबसे पहले function definition मे  profit को define किया जाता है | यह पर ‘ cp’ और ‘sp’ formal parameter है जिसमे actual parameter cost_price और sell_price से intial किया जाता है |
1.ii-उसके बाद output = sp-cp; से profit को calculate कर लेते है |
1.iii- इसके बाद output को print किया जाता है |

loss () मे ,
1.i-सबसे पहले function definition मे  loss को define किया जाता है | यह पर ‘ cp’ और ‘sp’ formal parameter है जिसमे actual parameter cost_price और sell_price से intial किया जाता है |
1.ii-उसके बाद output = cp – sp; से profit को calculate कर लेते है |
1.iii- इसके बाद output को print किया जाता है |

2.उसके बाद main() function मे  math class के लिए एक object c को declare किये जाता है | एक variable cost_price और sell_price को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा  value को input करा लेते है और इन value को  variable cost_price और sell_price मे assign करा देते है |
4. फिर condition check की जाती है अगर cp की value sp से ज्यादा होती है तब loss() function को call किया जाता अहि  अन्यथा profit () function को call किया जाता है |

#include<iostream.h>
#include<conio.h>
class math
{
private :
int cp, sp , output;
public:
void profit(int cp , int sp )
{
output = cp – sp;
cout<<“Profit :”<<output;
}
void loss(int cp , int sp )
{
output = sp – cp;
cout<<“Loss :”<<output;
}
};
void main()
{
math m;
int a,b;
cout<<“Enter cost price :”<<endl;
cin>>a;
cout<<“Enter sell price  :”<<endl;
cin>>b;
if(a>b)
{
m.profit(a,b);
}
if(a<b)
{
m.loss(a,b);
}
getch();
}