The sequence consists of all numbers from 1 to N (inclusive), n(1<=n<=100). All the odd numbers are listed first, then all the even numbers. For example you input 8 and the code prints this: 1,3,5,7,2,4,6,8. Although when I input an odd number it adds a comma in the end. It's my first time here, no idea how to post it correctly...
Even numbers here
> for(int i=1;i<=n;i++){
if(i%2!=0){
cout<<i<<",";
}
}
Odd numbers here
for(int i=1;i<=n;i++){
if(i%2==0){
if(i==n){
cout<<i;
}
else{
cout<<i<<",";
}
}
}