VENUJAN
#include <stdio.h>
int main(){
int n,i,total=0,x;
printf("Enter the numbers of elements :");
scanf("%d",&n);
int odd_num[n];
int even_num[n];
int numbers[n];
for (i=0;i<n;i++){
printf("Enter your sum_of_elements : ");
scanf("%d",&numbers[i]);
if (numbers[i]%2 == 0)
{
even_num[n] = numbers[i];
}
else
{
odd_num[n] = numbers[i];
}
}
printf("even numbers are = %d \n",even_num[n]);
printf("odd numbers are = %d \n",odd_num[n]);
return 0;
printf("%d",numbers[n]);
}
VENUJAN
Enter the numbers of elements :5
Enter your sum_of_elements : 9
Enter your sum_of_elements : 8
Enter your sum_of_elements : 6
Enter your sum_of_elements : 7
Enter your sum_of_elements : 3
even numbers are = 6
odd numbers are = 3
--------------------------------
Process exited after 13.84 seconds with return value 0
Press any key to continue . . .
what's wrong ? why i couldn't store all numbers?
olli
Hentai-kun
/get cppbookguide
Dima
Bruh
klimi
int main();
shriman_deepak
klimi
shriman_deepak
Here i am getting the output
shriman_deepak
But looking for an alternative.
klimi
But looking for an alternative.
what do you mean by "an alternative"? if you have written the code, you will be able to rewrite it differently
shriman_deepak
Can i use string instead of char
klimi
also, that formatting will probably make others not even look at the code btw
klimi
well you are certainly using C++ so you can use std::string... why not
shriman_deepak
klimi
shriman_deepak
?
This code is copied from somewhere.
shriman_deepak
klimi
and your goal is to mask it as you have you written it or why do you need to change it?
shriman_deepak
There's something I don't understand so i thought there might be another option to do this.
shriman_deepak
Val=strcmp("yes",robotChk);
shriman_deepak
And cin>>robotChk
klimi
And cin>>robotChk
cin: https://en.cppreference.com/w/cpp/io/cin
strcmp: https://en.cppreference.com/w/c/string/byte/strcmp
king king
Hello.
I read an article about memcpy optimization and i think I aim dying for help
Vlad
king king
*desperate
king king
https://www.embedded.com/optimizing-memcpy-improves-speed/
Vlad
What didn't you get?
king king
they give an example for making the coping word size.
and than they do checking to see 4 bits alignment
i think they do wrong comparison
king king
An algorithm that offers better performance on wider memory buses, such as the one on the evaluation board I used, can be found in GNU's newlib source code. I've posted the code here. If the source and destination pointers are both aligned on 4-byte boundaries, my modified-GNU algorithm copies 32 bits at a time rather than 8 bits. Listing 2 shows an implementation of this algorithm.
Listing 2: The modified-GNU algorithm
void * memcpy(void * dst, void const * src, size_t len)
{
long * plDst = (long *) dst;
long const * plSrc = (long const *) src;
if (!(src & 0xFFFFFFFC) && !(dst & 0xFFFFFFFC))
{
while (len >= 4)
{
*plDst++ = *plSrc++;
len -= 4;
}
}
char * pcDst = (char *) plDst;
char const * pcDst = (char const *) plSrc;
while (len–)
{
*pcDst++ = *pcSrc++;
}
return (dst);
}
Vlad
Vlad
I believe they wanted to avoid modulo operation
king king
(!(src & 0xFFFFFFFC) && !(dst & 0xFFFFFFFC))
so this is a mistake ?
Vlad
Vlad
If any of the last two bits are on it would give true
Vlad
Then result is negated
Vlad
Vlad
Or not
king king
but lets take src to be (64 = 1000000 & 01111111100) it will give troe
Vlad
I think it should be src & 3
king king
how come so advanced articles do such mistakes?
king king
not that i complain, but a beginner like me will waste 4 days rechecking before I will have the courage to doubt professional article
king king
king king
Бабак
Hi bro
Im Iranian too
Ismael
/get
Abdul
Hi
Abdul
I am new joining
Vitrag
Abdul
Anonymous
Hii plz suggest me a book for cpp
Abdul
Anonymous
Anyone to help with a School assignment c++ program
Kelthy
What's so wrong with saying hi? Yikes. Don't be like those guys in QebecOS IRC.
Anonymous
Do while loop is not working ? Y?
Talula
Anonymous
Anonymous
Hi! I'm new joining
Anonymous
I'm Mohammed Sahfan
Sri Lanka
I have some doubts in c programming. Can anyone solve my doubt?
Juan
/get cbook
Anonymous
Ok
.
JoyfulTyrant
How can we remove whitespaces from a string, none of the algorithms on the internet are working
Anonymous
how do i split a vector into sub vectors based on content comparison? as i need to split a list of views into a seperate list of views based on if the location X is inside the view's location
Anonymous
Anonymous
string tmp;
for (char x : str) {
bool skip = false;
for (char w : whitespace_chars) {
if (x == w) {
skip = true;
break;
}
}
if (skip) {
continue;
}
tmp += x;
}
return tmp;
Anonymous
Hey
Anonymous
バレンタインがいない柴(食用不可)
https://github.com/jakowskidev/uMario_Jakowski
Some crazy guy rewrote super Mario in c++...
touhou
Anonymous
Hii
Talula
Typing...
Does codeblocks is better than vs code ?
Golden Age Of
M.
Anonymous
Does codeblocks is better than vs code ?
In my opinion I don't think this comparison is up for debate at this point. Code::Blocks is too old and slow for today's standards, but it was acceptable back in the day.
Niranjala Priyangani
/get
Shahar
I've built a user thread library in C++ .
Now, using Googletest framework to test the functionality of my library, when I call ASSERT_EXIT to verify the number of exit code, the exit code that is returned is always 1, and 0 is expected.
I've debugged it. and I exit the program with std::exit(0), and not with 1.
But, for some strange reason, I've checked the assembly of this std::exit(0) and I got:
__GI_exit:
endbr64
push rax
pop rax
mov ecx,0x1
mov edx,0x1
lea rsi,[rip+0x1a1b41] ; 0x7f79946c3718 <__exit_funcs>
sub rsp,0x8
call 0x7f7994521930 ; <__run_exit_handlers>
That is, the assembly of std::exit always returns exit code = 1 !!
Why is that?
Even if I change it to std::exit(5) it still exits with 1.