C++ Program to take log^n

Thursday, 22 December 2016

Statement:
C++ program to take log^n
Code : 
#include<iostream>
using namespace std;
void main()
{
       int i, n, s = -1;
       float sum = 0;
       cout << "Enter The Value Of n : ";
       cin >> n;

       for (i = 1; i <= n; i++)
       {
              s = s * -1;
              sum += s*1.0 / i;
       }
       cout << "Log Of 2 : " << sum;

       cout << "\n\n";
       system("pause");

}

Mohammad Tayyab

Author & Editor

Imagination is more important than knowledge.

0 comments:

Post a Comment