+ 2
iNCLUDE OTHER THAN IOSTREAM
WHY CANT WE INCLUDE CONIO AND MATH HEADER FILE , IS THERE ANY WAY TO INCLUDE IT IN SOLO LEARN CODE PLAYGROUND
14 odpowiedzi
+ 18
.
You forgotten 'using namespace std', and started to use cout and cin. Of course it would throw an error. To add to that, clrscr() has loooong been deprecated, wouldn't even work on my desktop compiler. In C.Playground, the use of getch() to hold console output is unnecessary.
+ 12
I try it!
None error exist
I bet that you use Turbo C++
+ 11
!!!!
#include <math.h>
#include <conio.h>
What is a problem?!
+ 11
Bro....Where did you have hot head come from?
+ 11
void main()
to
int main()
in c++
that's the problem too,
sir
+ 7
Dear Garvit, please find code with few tweaks, now it is working
#include <iostream>
#include <math.h>
using namespace std;
float sum (int x, int n){
float sign=1.0;
float total = 0.0;
long fact;
for (int i = 1; i<=n; i++){
fact = 1;
for (int j = i; j >1; j--){
fact *=j;
}
total += sign * pow(x,i)/float(fact);
sign *= -1.0;
}
return total;
}
int main(){
int x, n;
cout << "Enter value of x: "; cin>>x;
cout << "Enter value of n: "; cin>>n;
float res = sum(x,n);
cout<<"Sum = "<<res;
return 0;
}
+ 4
/*#THIS IS A PROGRAME THAT FINDS THE SUM OF:
x-(x^2)/(3!)+(x^3)/(5!)-(x^4)/(7!)+(x^5)/9!.......Upto N terms
using float sum(int,int)*/
#include<iostream>
#include<conio.h>
#include<math.h>
float sum(int x,int N)
{
int sign=1;
float total=0;
float fact=1;
for(int i=1;i<=N;i++) //i is for power
{
for(int j=1;j<=i*2-1;j++) //j and fact are for factorial
{
fact*=j;
}
total+=pow(x,i)/(fact)*sign;
sign=sign*-1;
fact=1;
}
return total;
}
void main()
{
clrscr();
int x,N;
cout<<"\n\n\tx-(x^2)/(3!)+(x^3)/(5!)-(x^4)/(7!)+(x^5)/9!.......Upto N terms";
cout<<"\n\n\tEnter Value of x: ";
cin>>x;
cout<<"\n\n\tEnter Values of N: ";
cin>>N;
float result=sum(x,N);
cout<<"\n\n\tSum of given expression is: "<<result;
getch();
}
JUST TRY THIS CODE IN SOLO LEARN AND SEE THE ERRORS HEADER FILES ARE INCLUDED I DID IT IN MY C++ AND ITS WORKING CORRECTLY
+ 4
..\Playground\:24:11: error: '::main' must return 'int'
void main()
^
..\Playground\: In function 'int main()':
..\Playground\:26:8: error: 'clrscr' was not declared in this scope
clrscr();
^
..\Playground\:28:1: error: 'cout' was not declared in this scope
cout<<"
\tx-(x^2)/(3!)+(x^3)/(5!)-(x^4)/(7!)+(x^5)/9!.......Upto N terms";
^
..\Playground\:28:1: note: suggested alternative:
In file included from ..\Playground\:4:0:
..\Playground\\include\c++\iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^
..\Playground\:30:1: error: 'cin' was not declared in this scope
cin>>x;
^
..\Playground\:30:1: note: suggested alternative:
In file included from ..\Playground\:4:0:
..\Playground\\include\c++\iostream:60:18: note: 'std::cin'
extern istream cin; /// Linked to standard input
^
got these errors
+ 4
@Digitalboy Seeing that clrscr() is included in conio, which in itself is OS dependent, I can safely assume that system("CLS") is an alternative (which isn't any better in terms of good practices).
+ 3
just try it buddy u will know !!
0
Pomogite sozdat' slovari sozdaniye wordlist to yest' zapisat' v nego tsifry i bukvy,kak eto sdelat'?
0
#include <stdio.h>
int main(int argc, char **argv)
{
unsigned int n = 0;
FILE *f = fopen("/sdcard/n.txt", "w");
while (n < 100000000)
{
fprintf(f, "%08d\n", n++);
if (n % 1000000 == 0)
{
fprintf(stderr, "*");
}
}
fclose(f);
fprintf(stderr, "\ndone!\n");
return 0;
}
0
Eto byl primer na si.a mne nuzhno na С++
0
словари нужны на С++