how to fix constant expression required in C++? [closed]












-4















I try to create a table wich contans a number choosen by user but it given me an error :




constant expression required




#include <iostream.h>
#include <conio.h>
main(){
clrscr();
int i,k,nval,pos=0,neg=0;
cout<<"Entrer Le nombre de valeur que vous voulez saisir nval = ";
cin>>nval;
int tab[nval];
for (i=0; i<nval; i++){
k=i+1;
cout<<"Le nombre la valeur numeros = "<<k<<"= ";
cin>>tab[i];
if (tab[i]>0) pos+=1;
else if (tab[i]<0) neg+=1;
}
cout<<"Le nombre des valeurs positives = "<<pos<<endl;
cout<<"Le nombre des valeurs negatives = "<<neg;
getch();
return 0;
}


is there any site to try directly the C++ codes ?.










share|improve this question













closed as off-topic by llllllllll, Galik, πάντα ῥεῖ, Killzone Kid, gnat Nov 24 '18 at 11:14


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Killzone Kid

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1





    If you format your code with consistent indentation other readers may find it easier to help you.

    – Galik
    Nov 24 '18 at 9:02











  • @KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

    – πάντα ῥεῖ
    Nov 24 '18 at 9:03













  • what you mean exactly?

    – KOTL NIAS
    Nov 24 '18 at 9:04






  • 2





    Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

    – Some programmer dude
    Nov 24 '18 at 9:06








  • 2





    Don't use TurboC. Use a C++11 conforming compiler like GCC

    – Basile Starynkevitch
    Nov 24 '18 at 9:16
















-4















I try to create a table wich contans a number choosen by user but it given me an error :




constant expression required




#include <iostream.h>
#include <conio.h>
main(){
clrscr();
int i,k,nval,pos=0,neg=0;
cout<<"Entrer Le nombre de valeur que vous voulez saisir nval = ";
cin>>nval;
int tab[nval];
for (i=0; i<nval; i++){
k=i+1;
cout<<"Le nombre la valeur numeros = "<<k<<"= ";
cin>>tab[i];
if (tab[i]>0) pos+=1;
else if (tab[i]<0) neg+=1;
}
cout<<"Le nombre des valeurs positives = "<<pos<<endl;
cout<<"Le nombre des valeurs negatives = "<<neg;
getch();
return 0;
}


is there any site to try directly the C++ codes ?.










share|improve this question













closed as off-topic by llllllllll, Galik, πάντα ῥεῖ, Killzone Kid, gnat Nov 24 '18 at 11:14


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Killzone Kid

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1





    If you format your code with consistent indentation other readers may find it easier to help you.

    – Galik
    Nov 24 '18 at 9:02











  • @KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

    – πάντα ῥεῖ
    Nov 24 '18 at 9:03













  • what you mean exactly?

    – KOTL NIAS
    Nov 24 '18 at 9:04






  • 2





    Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

    – Some programmer dude
    Nov 24 '18 at 9:06








  • 2





    Don't use TurboC. Use a C++11 conforming compiler like GCC

    – Basile Starynkevitch
    Nov 24 '18 at 9:16














-4












-4








-4








I try to create a table wich contans a number choosen by user but it given me an error :




constant expression required




#include <iostream.h>
#include <conio.h>
main(){
clrscr();
int i,k,nval,pos=0,neg=0;
cout<<"Entrer Le nombre de valeur que vous voulez saisir nval = ";
cin>>nval;
int tab[nval];
for (i=0; i<nval; i++){
k=i+1;
cout<<"Le nombre la valeur numeros = "<<k<<"= ";
cin>>tab[i];
if (tab[i]>0) pos+=1;
else if (tab[i]<0) neg+=1;
}
cout<<"Le nombre des valeurs positives = "<<pos<<endl;
cout<<"Le nombre des valeurs negatives = "<<neg;
getch();
return 0;
}


is there any site to try directly the C++ codes ?.










share|improve this question














I try to create a table wich contans a number choosen by user but it given me an error :




constant expression required




#include <iostream.h>
#include <conio.h>
main(){
clrscr();
int i,k,nval,pos=0,neg=0;
cout<<"Entrer Le nombre de valeur que vous voulez saisir nval = ";
cin>>nval;
int tab[nval];
for (i=0; i<nval; i++){
k=i+1;
cout<<"Le nombre la valeur numeros = "<<k<<"= ";
cin>>tab[i];
if (tab[i]>0) pos+=1;
else if (tab[i]<0) neg+=1;
}
cout<<"Le nombre des valeurs positives = "<<pos<<endl;
cout<<"Le nombre des valeurs negatives = "<<neg;
getch();
return 0;
}


is there any site to try directly the C++ codes ?.







c++ turbo-c++






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 8:59









KOTL NIASKOTL NIAS

75




75




closed as off-topic by llllllllll, Galik, πάντα ῥεῖ, Killzone Kid, gnat Nov 24 '18 at 11:14


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Killzone Kid

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by llllllllll, Galik, πάντα ῥεῖ, Killzone Kid, gnat Nov 24 '18 at 11:14


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Killzone Kid

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1





    If you format your code with consistent indentation other readers may find it easier to help you.

    – Galik
    Nov 24 '18 at 9:02











  • @KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

    – πάντα ῥεῖ
    Nov 24 '18 at 9:03













  • what you mean exactly?

    – KOTL NIAS
    Nov 24 '18 at 9:04






  • 2





    Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

    – Some programmer dude
    Nov 24 '18 at 9:06








  • 2





    Don't use TurboC. Use a C++11 conforming compiler like GCC

    – Basile Starynkevitch
    Nov 24 '18 at 9:16














  • 1





    If you format your code with consistent indentation other readers may find it easier to help you.

    – Galik
    Nov 24 '18 at 9:02











  • @KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

    – πάντα ῥεῖ
    Nov 24 '18 at 9:03













  • what you mean exactly?

    – KOTL NIAS
    Nov 24 '18 at 9:04






  • 2





    Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

    – Some programmer dude
    Nov 24 '18 at 9:06








  • 2





    Don't use TurboC. Use a C++11 conforming compiler like GCC

    – Basile Starynkevitch
    Nov 24 '18 at 9:16








1




1





If you format your code with consistent indentation other readers may find it easier to help you.

– Galik
Nov 24 '18 at 9:02





If you format your code with consistent indentation other readers may find it easier to help you.

– Galik
Nov 24 '18 at 9:02













@KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

– πάντα ῥεῖ
Nov 24 '18 at 9:03







@KOTLNIAS Sorry. My 1st comment didn't apply. To declare the std I'd recommend you'll get a newer compiler. Also see: stackoverflow.com/questions/29329776/…

– πάντα ῥεῖ
Nov 24 '18 at 9:03















what you mean exactly?

– KOTL NIAS
Nov 24 '18 at 9:04





what you mean exactly?

– KOTL NIAS
Nov 24 '18 at 9:04




2




2





Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

– Some programmer dude
Nov 24 '18 at 9:06







Anyway, you really should consider upgrading to a newer development environment. Turbo-C++ is from before C++ was standardized twenty years ago. Nothing but some of the basic syntax you learn with Turbo-C++ will be usable for any real work, you will have a lot of studying to do if you want to become a good programmer after this course. There are plenty of free compilers and environments that you can use, that are up to date with the latest standards and have very good editors and environments.

– Some programmer dude
Nov 24 '18 at 9:06






2




2





Don't use TurboC. Use a C++11 conforming compiler like GCC

– Basile Starynkevitch
Nov 24 '18 at 9:16





Don't use TurboC. Use a C++11 conforming compiler like GCC

– Basile Starynkevitch
Nov 24 '18 at 9:16












1 Answer
1






active

oldest

votes


















2














You can't create an array with a variable size unknown at compile time. You could try creating an array in heap memory instead.



int *tab = new int[nval];


But then you will have to free it after using.



delete tab;





share|improve this answer
























  • it's working thank you!!

    – KOTL NIAS
    Nov 24 '18 at 9:14











  • You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

    – Victor
    Nov 24 '18 at 9:16






  • 1





    @KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

    – Spektre
    Nov 24 '18 at 9:24


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You can't create an array with a variable size unknown at compile time. You could try creating an array in heap memory instead.



int *tab = new int[nval];


But then you will have to free it after using.



delete tab;





share|improve this answer
























  • it's working thank you!!

    – KOTL NIAS
    Nov 24 '18 at 9:14











  • You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

    – Victor
    Nov 24 '18 at 9:16






  • 1





    @KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

    – Spektre
    Nov 24 '18 at 9:24
















2














You can't create an array with a variable size unknown at compile time. You could try creating an array in heap memory instead.



int *tab = new int[nval];


But then you will have to free it after using.



delete tab;





share|improve this answer
























  • it's working thank you!!

    – KOTL NIAS
    Nov 24 '18 at 9:14











  • You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

    – Victor
    Nov 24 '18 at 9:16






  • 1





    @KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

    – Spektre
    Nov 24 '18 at 9:24














2












2








2







You can't create an array with a variable size unknown at compile time. You could try creating an array in heap memory instead.



int *tab = new int[nval];


But then you will have to free it after using.



delete tab;





share|improve this answer













You can't create an array with a variable size unknown at compile time. You could try creating an array in heap memory instead.



int *tab = new int[nval];


But then you will have to free it after using.



delete tab;






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 9:11









VictorVictor

350413




350413













  • it's working thank you!!

    – KOTL NIAS
    Nov 24 '18 at 9:14











  • You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

    – Victor
    Nov 24 '18 at 9:16






  • 1





    @KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

    – Spektre
    Nov 24 '18 at 9:24



















  • it's working thank you!!

    – KOTL NIAS
    Nov 24 '18 at 9:14











  • You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

    – Victor
    Nov 24 '18 at 9:16






  • 1





    @KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

    – Spektre
    Nov 24 '18 at 9:24

















it's working thank you!!

– KOTL NIAS
Nov 24 '18 at 9:14





it's working thank you!!

– KOTL NIAS
Nov 24 '18 at 9:14













You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

– Victor
Nov 24 '18 at 9:16





You're welcome. Just don't forget to call delete after you're done with this array, otherwise you will lose (leak) memory.

– Victor
Nov 24 '18 at 9:16




1




1





@KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

– Spektre
Nov 24 '18 at 9:24





@KOTLNIAS if this answers/solves your question (which it does) you should accept it as such for letting others to see your issue is solved by this ... That is done by clicking on the check icon near the answer score ...

– Spektre
Nov 24 '18 at 9:24





Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin