words per minute

5

AkshayYadav1


00:00

Speed

#include <iostream> #include <string> using namespace std; class binary { private: string s; void chk_bin(void); public: void read(void); void ones_compliment(void); void display(void); }; void binary::read(void) { cout << "Enter a binary number" << endl; cin >> s; } void binary::chk_bin(void) { for (int i = 0; i < s.length(); i++) { if (s.at(i) != '0' && s.at(i) != '1') { cout << "Incorrect binary format" << endl; exit(0); } } } void binary::ones_compliment(void) { chk_bin(); for (int i = 0; i < s.length(); i++) { if (s.at(i) == '0') { s.at(i) = '1'; } else { s.at(i) = '0'; } } } void binary::display(void) { cout<<"Displaying your binary number"<<endl; for (int i = 0; i < s.length(); i++) { cout << s.at(i); } cout<<endl; } int main() { binary b; b.read(); // b.chk_bin(); b.display(); b.ones_compliment(); b.display(); return 0; } #include <iostream> using namespace std; class Shop { int itemId[100]; int itemPrice[100]; int counter; public: void initCounter(void) { counter = 0; } void setPrice(void); void displayPrice(void); }; void Shop ::setPrice(void) { cout << "Enter Id of your item no " << counter + 1 << endl; cin >> itemId[counter]; cout << "Enter Price of your item" << endl; cin >> itemPrice[counter]; counter++; } void Shop ::displayPrice(void) { for (int i = 0; i < counter; i++) { cout << "The Price of item with Id " << itemId[i] << " is " << itemPrice[i] << endl; } } int main() { Shop dukaan; dukaan.initCounter(); dukaan.setPrice(); dukaan.setPrice(); dukaan.setPrice(); dukaan.displayPrice(); return 0; } #include <iostream> using namespace std; class Employee { int id; static int count; public: void setData(void) { cout << "Enter the id" << endl; cin >> id; count++; } void getData(void) { cout << "The id of this employee is " << id << " and this is employee number " << count << endl; } static void getCount(void){ // cout<<id; // throws an error cout<<"The value of count is "<<count<<endl; } }; // Count is the static data member of class Employee int Employee::count; // Default value is 0 int main() { Employee akshay, piyush, priya; // akshay.id = 1; // akshay.count=1; // cannot do this as id and count are private akshay.setData(); akshay.getData(); Employee::getCount(); piyush.setData(); piyush.getData(); Employee::getCount(); priya.setData(); priya.getData(); Employee::getCount(); return 0; }
words per minute
0
wpm
accuracy
0%
Text Practice - Time 1117 - English

words per minute