Pradevel (Pratyush)
Anonymous
Visual studio code
klimi
yeah... i don't know, maybe you need a plugin in VSC ? not sure... i use neovim...
Anonymous
hey, i have c++ 14
how do i get version 17?
do i need to uninstall and then install it?
klimi
klimi
no idea, you should know how your editor works.... i guess there is some make instructions, so you would have to modify that file, maybe google can help, no idea
Anonymous
klimi
Anonymous
Anonymous
i tested with a c++17 exclusive code
klimi
what's your compiler?
Anonymous
klimi
version?
Anonymous
version?
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
klimi
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
you can look in this https://gcc.gnu.org/projects/cxx-status.html to find what version of g++ you need, but if i am not looking wrong, mainly C++17 features got implemented in version 7
Anonymous
klimi
Anonymous
Anonymous
You just update it.
https://stackoverflow.com/questions/9865319/how-to-update-gcc-in-mingw-on-windows#:~:text=Run%20the%20command,will%20be%20upgraded.
This?
Anonymous
Anonymous
Anonymous
#include <stdio.h>
int main()
{
int num,i;
long int fact;
printf("Enter an integer number: ");
scanf("%d",&num);
/*product of numbers from num to 1*/
fact=1;
for(i=num; i>=1; i--)
fact=fact*i;
printf("\nFactorial of %d is = %ld",num,fact);
return 0;
}
How can I make it to be able to give huge numbers output
It sounds it is limited for 10 digits only
Anonymous
klimi
and if you need ever bigger, you will have to use some libraries for big integers
Anonymous
Anonymous
Anonymous
Anonymous
Ravi
I want it to find 200!
Use array of size 1000, do 1 2 3 .....upto 200 numbers multiplication using traditional digit wise multiplication.
king king
guys i beg you
Anonymous
https://www.msys2.org/ have up to date versions most of the time
Anonymous
...
Anonymous
How can I add libraries for c in android?
Dumb
Dumb
I don't know, you should ask in an android group
They could help you if you can't get anything here
Anonymous
Anonymous
I dont follow you.
I mean I should use the gmp library
So the prgram can return more than 10 digits
Anonymous
??
Ehsan
does anyone have mac and know how to install boost with CMake
kc
https://github.com/microsoft/vcpkg
Anonymous
how do i get std::initializer_list to preserve it's data?
https://rextester.com/WUM88022
Manu
Guys, i am new in c++ anyone help me how to start
Manu
And with whom
Spirit
Spirit
Use a vm and install gentoo
klimi
Anonymous
I want to make a simple calculator, What's wrong in this code?
#include <stdio.h>
int main()
{
int num1,num2,value;
char op;
printf("Enter a number: ");
scanf("%d", &num1);
printf("Enter an operator [d = /, m = *, a = *, s = - ]: ");
scanf("%c",&op);
printf("Enter another number: ");
scanf("%d", &num2);
if (op = d), value = num1/num2;
if (op = m), value = num1*num2;
if (op = a), value = num1+num2;
if (op = s), value = num1-num2;
printf("Answer = %d", value);
return 0;
}
Official hooligan of Pius XII
I want to make a simple calculator, What's wrong in this code?
#include <stdio.h>
int main()
{
int num1,num2,value;
char op;
printf("Enter a number: ");
scanf("%d", &num1);
printf("Enter an operator [d = /, m = *, a = *, s = - ]: ");
scanf("%c",&op);
printf("Enter another number: ");
scanf("%d", &num2);
if (op = d), value = num1/num2;
if (op = m), value = num1*num2;
if (op = a), value = num1+num2;
if (op = s), value = num1-num2;
printf("Answer = %d", value);
return 0;
}
you use = instead of == during comparison
Official hooligan of Pius XII
also keep in mind that dividing two integeres won't give you correct fractions
Anonymous
can you edit this code plz
Official hooligan of Pius XII
just do if(op=='s') and so on
Anonymous
main.c:25:15: error: ‘d’ undeclared (first use in this function)
if (op == d), value = num1/num2;
it shows this error
Official hooligan of Pius XII
Official hooligan of Pius XII
Anonymous
Official hooligan of Pius XII
"d" -> string literal
'd' -> char
d -> variable named d
Anonymous
Here's modified code, still it shows errors
#include <stdio.h>
int main()
{
int num1,num2;
float value;
char op;
printf("Enter a number: ");
scanf("%d", &num1);
printf("Enter an operator [d = /, m = *, a = +, s = - ]: ");
scanf("%c",&op);
printf("Enter another number: ");
scanf("%d", &num2);
if (op == "d"), value = num1/num2;
if (op == "m"), value = num1*num2;
if (op == "d"), value = num1+num2;
if (op == "s"), value = num1-num2;
printf("Answer = %f", value);
return 0;
}
Official hooligan of Pius XII
Here's modified code, still it shows errors
#include <stdio.h>
int main()
{
int num1,num2;
float value;
char op;
printf("Enter a number: ");
scanf("%d", &num1);
printf("Enter an operator [d = /, m = *, a = +, s = - ]: ");
scanf("%c",&op);
printf("Enter another number: ");
scanf("%d", &num2);
if (op == "d"), value = num1/num2;
if (op == "m"), value = num1*num2;
if (op == "d"), value = num1+num2;
if (op == "s"), value = num1-num2;
printf("Answer = %f", value);
return 0;
}
1) When using char type, you have to use single ', not double ".
2) Don't make commas , after if statement. You can make no brackets {} when executing just one line but still, no place for commas like that
Here's the correct part of the code:
if (op == 'd')
value = num1/num2;
if (op == 'm')
value = num1*num2;
if (op == 'd')
value = num1+num2;
if (op == 's')
value = num1-num2;
Anonymous
Anonymous
int main()
{
int num1,num2;
float value;
char op;
printf("Enter a number: ");
scanf("%d", &num1);
printf("Enter an operator [d = /, m = *, a = +, s = - ]: ");
scanf("%c",&op);
printf("Enter another number: ");
scanf("%d", &num2);
if (op = 'd') value = num1/num2;
if (op = 'm') value = num1*num2;
if (op = 'd') value = num1+num2;
if (op = 's') value = num1-num2;
printf("Answer = %f", value);
The underlined lines are not running, what's the reason?
Pavel
Anonymous
Anonymous
Enter a number: 3
Enter an operator [d = /, m = *, a = +, s = - ]: Enter another number: m
...Program finished with exit code 0
Press ENTER to exit console.
Official hooligan of Pius XII