Skip to main content

Posts

Introduction To C++ Programming - Part 9.

C++ Program To Add Two Matrices Using Multi-dimensional Arrays #include<iostream> #include<cstdlib> using namespace std; int main() { int A[10][10],B[10][10],c[10][10]; int i,j,m,n,p,q; cout << "Number Of Rows & Columns Of Matrix A: " << endl; cin >> m >> n; cout << "\nNumber Of Rows & Columns Of Matrix B: " << endl; cin >> p >> q; if(m==p&&n==q) cout << "\n\nMatrices Can Be Added."; else { cout << "\nMatrices can Not Be Added Because They're Not The Same Size..\n"; exit(0); } cout<<"\nEnter Matrix A: " << endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) cin >> A[i][j]; } cout<<"\nMatrix A:\n"; for(i=0;i<m;i++) { for(j=0;j<n;j++) cout << A[i][j] <<" "; cout << "\n"; } cout << "\nEnter Matrix B: " << endl; for(i=0;i<m;i++) { for(j...

C++ Program To Implement Casino Number Guessing Game.

#include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; void drawLine(int n, char symbol); void rules(); int main() { string playerName; int amount; int bettingAmount; int guess; int dice; char choice; srand(time(0)); drawLine(70,'_'); cout << "\n\n\n\t\tCASINO GAME\n\n\n\n"; drawLine(70,'_'); cout << "\n\nEnter Your Name : "; getline(cin, playerName); cout << "\n\nEnter Deposit Amount To Play Game : $"; cin >> amount;

Inside A System Unit Of Desktop Computer

Have you ever looked inside a computer case, or seen pictures of the inside of one? The small parts may look complicated, but the inside of a computer case isn't really all that mysterious. This lesson will help you master some of the basic terminologies and understand a bit more about what goes on inside a computer. Watch the video below to learn about what's inside a desktop computer.

What Is A computer?

A computer is a device that accepts information (in the form of digitized data) and manipulates it for some result based on a program or sequence of instructions on how the data is to be processed. Complex computers also include the means for storing data (including the program, which is also a form of data) for some necessary duration. A program may be invariable and built into the computer (and called logic circuitry as it is on microprocessors) or different programs may be provided to the computer (loaded into its storage and then started by an administrator or user). Today's computers have both kinds of programming. Watch the video below to learn about different types of computers.

C++ Program To Implement Hangman Game.

#include <iostream> #include <cstdlib> #include<ctime> #include <string> using namespace std; const int MAX_TRIES=5; int letterFill (char, string, string&); int main () { string name; char letter; int num_of_wrong_guesses=0; string word; string words[] = { "india", "pakistan", "nepal", "malaysia", "philippines", "australia", "iran", "ethiopia", "oman", "indonesia" }; srand(time(NULL)); int n=rand()% 10; word=words[n];

Introduction To C++ Programming - Part 8.

C++ Program To Multiply Two Matrices Using Multi-dimensional Arrays #include <iostream> using namespace std; int main() { int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k; cout << "Enter No. Of Rows & Columns For First Matrix:\n"; cin >> r1 >> c1; cout << "\nEnter No. Of Rows & Columns For Second Matrix:\n"; cin >> r2 >> c2; while (c1!=r2) { cout << "\nError! Column Of First Matrix Is Not Equal To Row Of Second Matrix.\n"; cout << "\nEnter No. Of Rows & Columns For First Matrix:\n"; cin >> r1 >> c1; cout << "\nEnter No. Of Rows & Columns For Second Matrix:\n"; cin >> r2 >> c2; } cout << endl << "\nEnter The Elements Of Matrix 1:" << endl; for(i=0; i<r1; ++i)

C++ Program To Implement Student Report Card System.

#include<iostream> #include<fstream> #include<iomanip> #include <cstdlib> using namespace std; class student { int rollno; char name[50]; int p_marks, c_marks, m_marks, e_marks, cs_marks; double per; char grade; void calculate(); public: void getdata(); void showdata() const; void show_tabular() const; int retrollno() const; }; void student::calculate() { per=(p_marks+c_marks+m_marks+e_marks+cs_marks)/5.0; if(per>=60) grade='A'; else if(per>=50)  grade='B'; else if(per>=33) grade='C'; else grade='F'; }

C++ Program To Implement Tic Tac Toe Game.

#include <iostream> #include<cstdlib> using namespace std; char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; int checkwin(); void board(); int main() { int player = 1,i,choice; char mark; do { board(); player=(player%2)?1:2; cout << "Player " << player << ", Enter A Number: "; cin >> choice; mark=(player == 1) ? 'X' : 'O'; if (choice == 1 && square[1] == '1') square[1] = mark; else if (choice == 2 && square[2] == '2') square[2] = mark; else if (choice == 3 && square[3] == '3') square[3] = mark; else if (choice == 4 && square[4] == '4') square[4] = mark;

Introduction To C++ Programming - Part 7.

C++ Program To Check Whether A Number Is The Sum Of 2 Prime Numbers #include <iostream> using namespace std; int check_prime(int n); int main() { int n, i, flag=0; cout << "Enter A Positive Integer: "; cin >> n; for(i=2; i<=n/2; ++i) { if (check_prime(i)==0){ if ( check_prime(n-i)==0) { cout << endl<< n << " = " << i << " + " << n-i << endl; flag=1; }}} if (flag==0) cout << endl << n << " Can't Be Expressed As Sum Of Two Prime Numbers." << endl; return 0; } int check_prime(int n) /*check prime number*/ { int i, flag=0; for(i=2;i<=n/2;++i) { if(n%i==0) { flag=1; break; }} return flag; }

Introduction To C++ Programming - Part 6.

C++ Program To Calculate Standard Deviation Of Given Numbers #include <iostream> #include <cmath> using namespace std; int main() { int n , j ,y; double _sum=0 , variance; cout << "How Many Numbers To Type? "; cin >> y; cout << endl; double max[y]; for(n=0;n<=y-1;n++) { cout << "Enter Number " << n+1 << " : "; cin >> max[n]; } n=0; cout << endl; cout << "\nSo The Numbers Are:\t"; for(j=0;j<=y-1;j++) { cout << max[n] << "\t"; _sum+=max[n]; n++; }

C++ Program To Implement Bank Management System.

#include<iostream> #include<fstream> #include<cctype> #include<iomanip> #include <cstdlib> using namespace std; class account { int acno; char name[50]; int deposit; char type; public: void create_account(); //function to get data from user void show_account() const; //function to show data on screen void modify(); //function to add new data void dep(int); //function to accept amount and add to balance amount void draw(int); //function to accept amount and subtract from balance amount void report() const; //function to show data in tabular format int retacno() const; //function to return account number int retdeposit() const; //function to return balance amount char rettype() const;  //function to return type of account }; void account::create_account() { cout<<"\nEnter The Account No. : "; cin>>acno; cout<<"\n\nEnter The Name Of The Account Holder : "; cin.ig...

Introduction To C++ Programming - Part 5.

C++ Program To Remove All Characters In A String Except Alphabet #include<iostream> #include<cstring> using namespace std; int main() { char line[150]; int i,j; cout << "Enter A String: "; cin.getline(line, 150); for(i=0; line[i]!='\0'; ++i) { while (!((line[i]>='a'&&line[i]<='z')|| (line[i]>='A'&&line[i]<='Z'|| line[i]=='\0'))) { for(j=i;line[j]!='\0';++j) { line[j]=line[j+1]; } line[j]='\0'; }} cout << "\nOutput String: " << line; return 0; } C++ Program To Find The Number Of Vowels, Consonants, Digits And White Spaces In A String #include<iostream> #include<cstring> using namespace std; int main() { char line[150]; int i,v,c,ch,d,s,o; o=v=c=ch=d=s=0; cout<<"Enter A Sentence: "; cin.getline(line, 150);

Introduction To C++ Programming - Part 4.

C++ Program To Calculate Determinant Of A Matrix #include<iostream> #include<math.h> using namespace std; double d = 0; double det(int n, double mat[10][10]); double det(int n, double mat[10][10]){ double submat[10][10]; if (n == 2) // set the matrix (must be square) to find determinant. return ((mat[0][0] * mat[1][1]) - (mat[1][0] * mat[0][1])); else { for (int c = 0; c < n; c++) { int subi = 0; for (int i = 1; i < n; i++) { int subj = 0; for (int j = 0; j < n; j++) { if (j == c) continue; submat[subi][subj] = mat[i][j]; subj++; } subi++; } d = d + (pow(-1, c) * mat[0][c] * det(n - 1, submat)); }} return d; }