When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
33 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
#include <iostream>
using namespace std;
int main(){
int n, even, odd;
int arr[n];
cin >> n;
for (int i = 0; i < arr[n]; i++)
{
if ()
{
}
}
cout << even << endl;
cout << odd ;
}
thats all i got
but how to do it
i really dont know
that's VLA ๐
A Variable Length Array (VLA)
is an array where the size is not constant and depends on a variable.
VLAs have poor compiler support and can lead to inefficient code.
The core issue with VLAs is that the compiler doesn't know the size of the stack frame.
Without warning flags like -Wvla (Note: -Wvla is not turned on by -Wall nor any other warning
flag) it can be easy to create a VLA by accident, even in C++ with some compilers.
โ
available since C99
โ not available in C++ at all
โ was never supported by MSVC
โ optional feature since C11
โ supported as non-standard extension by GCC, clang
:stackoverflow: What technical disadvantages do C99-style VLAs have?
:stackoverflow: What's the point of VLA anyway?
but i guess we can just ignore the fact that you shouldn't use it, since this is more about algorithm
i mean rn you're creating n sized array
I don't know how to give you a hint without giving it all away
LMAO
welp

I would use % operator do you know what it does ?
mhm
ik the part
where
n % 2 == 0
but
if i want the whole
number
but it goes like
digit to digit
123
odd = 2
even = 1
yk?
god c++ is confusing
you will get used to syntax quickly

it's good to work on some specific example first
say we get 279
279 % 2 tells us whether the last (rightmost) digit is even or odd
now after doing this we need to get to the next digit so from 279 we need 27
@marble fable
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. You can use !solved to close a post and mark it as solved.
!solved