Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

change the signs in the number field

I have a problem, I need to change the signs in the number field. I don’t know how to do it. Thank you for your help


void swap_sign(const int size, int array[]){
if(array[] != NULL){
for(int i=0; i < size; i++){
   if(array[i] == /* - */){
        //turn the sign to + and save to the field
   }
   else if(array[i] == /* + */ ){
   //turn the sign to - and save to the field
   }
}
}
}


>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not sure why you have commented things out in the for loop, but switching signs is achieved with just multiplying the minus sign.

array[i] = -array[i];

for(int i=0; i < size; i++){
   array[i] = -array[i];
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading