Assignments » Flow Of Control » Set 2 » Solution 13
Source Code:
#include<iostream> using namespace std; int main() { int i,n; float sum=0; cout<<"Enter the value of n "; cin>>n; for(i=1;i<=n;i++) sum += 1.0/i; cout<<"Sum : "<<sum; return 0; }
#include<iostream> using namespace std; int main() { int i,n; float sum=0; cout<<"Enter the value of n "; cin>>n; for(i=1;i<=n;i++) sum += 1.0/i; cout<<"Sum : "<<sum; return 0; }
The Output Is:
Enter the value of n 5
Sum : 2.28333
Course Outline BSIT 2 year Program First Semester Outline Second Semester Outline Third Semester Outline ...
Post a Comment