Why is it showing this error:
prog.cpp: In function ‘int main()’:
prog.cpp:6: error: ‘cin’ was not declared in this scope
prog.cpp:9: error: ‘cout’ was not declared in this scope
How can I remove it…Please help…
Why is it showing this error:
prog.cpp: In function ‘int main()’:
prog.cpp:6: error: ‘cin’ was not declared in this scope
prog.cpp:9: error: ‘cout’ was not declared in this scope
How can I remove it…Please help…
Try using std::cout and std::cin
Few things:
1)Instead of doing std:: every time, put a using namespace std; statement after header files.
When using cin do cin>>x; and cin>>y;
For cout do cout<<y and…
I checked your code. There is a slight mistake in your logic which is giving you WA. Hint: Consider the case x=10 and y=10.20!!
oh!!!
Thanks a lot kcahdog…
Add " using namespace std;" after the header files , to remove the error .
but i used using namespace std;
still there is the same error in my program
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,i,j,k,x,y;
char a[10][10],b[10][10],l[10];
cout<<"enter the no. of text";
cin>>n;
for (i=0;i<n;i++)
{
gets(a[i]);
l[i]=strlen(a[i]);
}
for (i=0;i<n;i++)
{for (j=0;j<l[i];j++)
{for(k=0;k<j;k++)
{if(a[i][j]==a[i][k])
{
for(x=j;x<l[i]-1;x++)
a[i][x]=a[i][x+1];
a[i][x]=' ';
j--;
l[i]--;
}
}
}
puts(a[i]);
}
}
the error is coming as :
prog.cpp: In function ‘int main()’:
prog.cpp:13: error: ‘strlen’ was not declared in this scope
@aks1997: Because, you’ve not declared the header files required for the same. See, take a look at your own code which successfully compiles: http://ideone.com/4EWXA4 or alternatively you could use only #include <bits/stdc++.h>
to avoid confusion if you don’t know which header file you’re looking for. Look here for its sample implementation: http://ideone.com/5aNH6P
#include
using namespace std;
int main()
{
int t,i,a[100];
int j=1,f=1;
cout<<"enter the no. of values you want to enter"<<endl;
cin>>t;
if(t<=100){
cout<<"enter the values in list"<<endl;
for(i=0;i<t;i++)
cin>>a[i];
for(i=0;i<t;i++)
{
while(j<=a[i])
{
f=f*j;
j++;
}
cout<<"\nthe factorial of given no. is"<<endl<<f;
}
}}
why i am getting wrong answer?