I have compiled the program and it executes.
But soon after I give a value say 30 (i.e. to find sin 30) cursor keeps blinking with no response.
Along with C, I'm learning C++ from books.
But soon after I give a value say 30 (i.e. to find sin 30) cursor keeps blinking with no response.
Along with C, I'm learning C++ from books.
Code:
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
class value {
float n, x, fct, count;
public:
void getx() {
cout<<"Enter a number"<<endl; cin>>x; fflush(stdin);
}
float fact(float j) {
fct=1;
while(1) {
fct=fct*j; j++;
}
return fct;
}
void sinx(){
float sinxx;
count=-1;
float i;
i=1;
sinxx=0;
while(i<=10){
count*=count;
sinxx=sinxx+count*((pow(x,i))/fact(i));
i+=2;
}
printf("sin of %d is %f", x, sinxx);
}
};
int main()
{
value sed;
sed.getx();
sed.sinx();
return 0;
}