Skip to main content

Posts

Showing posts from January, 2017

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);