20120831

C++ Program to Add Two Numbers using Class

//Cpp Program to Add Two Numbers using Class

     #include <iostream>
     using namespace std;
        class SumWithClassDemo
        {
            public :
             void Add(int a,int b)
            {
            int total;
            total=a+b;
            cout<<"Total= "<<total;
            }
        };

        int main()
        {
        int x=3,y=4;
        SumWithClassDemo s;
        s.Add(x,y);
        return 0;
        }


//=====Program 2=====
//Cpp Program to Add Two Numbers using Class
//==================

#include <iostream>
using namespace std;

int main()
{
int x;
int y;
int sum;
         
   cout << "Insert two numbers to be added: "<<endl;
    cin >> x;
    cout<<"Enter second No: "<<endl;
    cin>> y;

   sum = x + y;
   cout <<"Sum is: "<<sum<<endl;
   return 0;
}

Simplest Way to learn Data Structure in C++ CPP or C

C++ Program for Fibonacci series

//C++ Program for Fibonacci series
//cpp program to find fibonacci series
#include<iostream>
using namespace std;
int main()
{
   int n, first = 0, second = 1, next;
   cout << "Enter the number of terms of Fibonacci series you want " << endl;
   cin >> n;
    cout << "Fibbonacci Series of first "<<n<<"numbers is = " <<endl;
    for ( int i = 0 ; i < n ; i++ )
       {
     if ( i <= 1 )
         next = i;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
      cout<<next<<endl;
   }
   return 0;
}

//How to find fibonacci Series in C++/Cpp
//How to find fibonacci Series in C++/Cpp
//C++ program for fibonacci Number
 //How to find fibonacci Series in C++/Cpp
//How to find fibonacci Series in C++/Cpp
//C++ program for fibonacci Number

Previous                             Home                               Next