Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uvall#include<iostream>
- using namespace std;
- class PreMidXam {
- private:
- int num1,G=0,S=0;
- char coin;
- int n,sum=0;
- int num3,rem=0,div=0,multi=0;
- int num4,ram=0,rev=0,counter=0;
- float s=0,avg;
- int N;
- public:
- void number1() {
- cout<<"Enter how many coin u want to calculate : ";
- cin>>num1;
- for(int i=1; i<=num1; i++)
- {cout<<"Enter coin : ";
- cin>>coin;
- while(coin!='G' && coin!='S')
- {
- cout<<"Enter valid coin : ";
- cin>>coin;
- }
- if (coin=='G'){
- G++;
- }
- if(coin=='S')
- {
- S++;
- }
- }
- cout<<"Gold : "<<G<<endl;
- cout<<"Silver : "<<S<<endl;
- }
- void number2() {
- cout<<"Enter a positive num : ";
- cin>>n;
- for(int i=1; i<n/2;i++)
- {
- sum+=i;
- }
- for(int i=n/2 ;i<=n; i++)
- {
- sum=sum+i;
- }
- cout<<"The Sum of the First "<<n<<" integers is "<<sum<<endl;
- }
- void number3 (){
- cout<<"Enter a Number for check multiple output : ";
- cin>>num3;
- for(int i=1; i<=100; i++)
- {
- rem=0;
- div=0;
- rem=i%10;
- div=i/10;
- multi=rem*div;
- if(multi==num3)
- {
- cout<<i<<endl;
- break;
- }
- if(i>=100) {
- if(multi==num3)
- {
- cout<<i<<endl;
- break;
- }
- else cout<<"No Multiple output "<<endl;;
- }
- }
- }
- void number4 (){
- cout<<"Enter a Number for Reverse : ";
- cin>>num4;
- while(num4!=0)
- {
- ram=num4%10;
- num4=num4/10;
- counter++;
- rev=rev*10+ram;
- s=s+ram;
- }
- avg=s/counter;
- cout<<"Reverse : "<<rev<<endl;
- cout<<"Average : "<<avg <<endl;
- }
- void number5() {
- cout<<"Enter Pattern Size : ";
- cin>>N;
- for(int i=1; i<=N; i++)
- {
- for(int j=1; j<=i; j++)
- {
- cout<<i*j<<" ";
- }
- cout<<endl;
- }
- }
- };
- int main () {
- PreMidXam obj;
- obj.number1();
- cout<<endl;
- obj.number2();
- cout<<endl;
- obj.number3();
- cout<<endl;
- obj.number4();
- cout<<endl;
- obj.number5();
- cout<<endl;
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment