Sunday 13 July 2014

program to find the reciprocal of five numbers.it ignores zero ,if entered.

#include<iostream>
#include<cmath>
#include<stdlib.h>
#define esp 0.000001
using namespace std;
int main()
{
int n,i;
float sum=0;

for(i=1;i<+5;i++)
{
cout<<"enter the number  "<< i<<endl;
cin>>n;

if(n==0)
{
cout<<"zero is not define";
continue;

}
sum=sum+1/n;
}
cout<<"the sum is"<<sum<<endl;
}

No comments:

Post a Comment

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...