Simple Program Book Entry Using structure Variable in C++ Programming

#include<iostream.h> #include<stdio.h> struct books { char name[20],author[20]; }a[50]; int main() { int i,n; cout<<“No Of Books[less than 50]:”; cin>>n; cout<<“Enter the book details\n”; cout<<”–––––––-\n”; for(i=0;i<n;i++) { cout<<“Details of Book No “<<i+1<<”\n”; cout<<“Book Name :”; cin>>a[i].name; cout<<“Book Author :”; cin>>a[i].author; cout<<”–––––––-\n”; } cout<<”================================================\n”; cout<<” S.No\t| Book Name\t|author\n”;cout<<”=====================================================”; for(i=0;i<n;i++) { cout<<”\n ”<<i+1<<”\t|”<<a[i].name<<”\t| “<<a[i].author; } cout<<”\n=================================================”; return 0; … Read more

Simple Addition in C++ Binary Operator Overloading Using C++ Programming

// Header Files #include<iostream> #include<conio.h> //Standard namespace declaration using namespace std; class overloading { int value; public: void setValue(int temp) { value = temp; } overloading operator+(overloading ob) { overloading t; t.value=value+ob.value; return(t); } void display() { cout<<value<<endl; } }; //Main Functionsint main() { overloading obj1,obj2,result; int a,b; cout<<“Enter the value of Complex Numbers a,b:”; … Read more

Simple Example Program for Function Find Smallest Number In C++

#include<iostream> #include<conio.h> using namespace std; // Simple Function int compare( int a, int b ) { return (a+4 < b)? a : b; } int main() { cout<<”\nSmallest Number :”<<compare(1,10); cout<<”\nSmallest Number :”<<compare(31,10); cout<<”\nSmallest Number :”<<compare(11,8); getch(); return 0; }   Output : Smallest Number :1 Smallest Number :10 Smallest Number :8

Factorial Using Loop Example Program In C++

Hello friends, Welcome to your Techgsr.co blog. And today in this article we will learn aboutFactorial Using Loop Example Program In C++ .So let’s go to our topic #include<iostream> #include<conio.h> using namespace std; int main() { // Variable Declaration int counter, n, fact = 1; // Get Input Value cout<<“Enter the Number :”; cin>>n; //for Loop … Read more

Factorial Using Function Example

Hello friends, Welcome to your Techgsr.co blog. And today in this article we will learn about  Factorial Using Function Example.So let’s go to our topic Program In C++ #include<iostream> #include<conio.h> using namespace std; //Function long factorial(int); int main() { // Variable Declaration int counter, n; // Get Input Value cout<<“Enter the Number :”; cin>>n; // Factorial … Read more

Program In C++ Factorial Using Recursion Example

  #include<iostream> #include<conio.h> using namespace std; //Function long factorial(int); int main() { // Variable Declaration int counter, n; // Get Input Value cout<<“Enter the Number :”; cin>>n; // Factorial Function Call cout<<n<<” Factorial Value Is “<<factorial(n); // Wait For Output Screen getch(); return 0; } // Factorial recursion Functionlong factorial(int n) { if (n == … Read more

Fibonacci series Example Program In C++

  #include<iostream> #include<conio.h> using namespace std; int main() { // Variable Declaration int counter, n; long last=1,next=0,sum; // Get Input Value cout<<“Enter the Number :”; cin>>n; //Fibonacci Series Calculation while(next<n/2) { cout<<last <<” ”; sum=next+last; next=last; last=sum; } // Wait For Output Screen getch(); return 0; }   Output : Enter the Number :300 1 … Read more

Find Prime Number by another method

  Example Program In C++ #include<iostream> #include<conio.h> #include<math.h> // Math.h For sqrt function using namespace std; int main() { // Variable Declaration int n; // Get Input Value cout<<“Enter the Number :”; cin>>n; cout<<“List Of Prime Numbers Below “<<n<<endl; //for Loop Block For Find Prime Number for (int i=2; i<n; i++) { bool prime=true; for … Read more

Find Prime Number Example Program In C++

  #include<iostream> #include<conio.h> #include<math.h> // Math.h For sqrt function using namespace std; int main() { // Variable Declaration int n; // Get Input Value cout<<“Enter the Number :”; cin>>n; cout<<“List Of Prime Numbers Below “<<n<<endl; //for Loop Block For Find Prime Number for (int i=2; i<n; i++) for (int j=2; j*j<=i; j++) { if (i … Read more

Simple Example Program For Namespace In C++

#include <iostream> using namespace std; //Namespace namespacefirst namespace namespacefirst { int value = 5; } //Namespace namespacesecond namespace namespacesecond { double value = 3.1416; } int main () { //Namespace namespacefirst Varibale Usage cout << “namespacefirst value : ” <<namespacefirst::value << endl; //Namespace namespacesecond Varibale Usage cout << “namespacesecond value : “<<namespacesecond::value << endl; return … Read more