Computers and Technology
Computers and Technology, 14.09.2019 08:30, bjbass899

Using for loop . input an integer and identify whether it's even or odd ( without using modulo operator )
using only . c++ programming

answer
Answers: 2

Similar questions

Предмет
Computers and Technology, 20.09.2019 22:20, titalili0204
Program description: in this recitation assignment, will write a complete c program that accepts as input any two integers from the user and swaps both integers using bitwise operators only without a third variable. early on in your programming career, you were told that you need to use a third variable in order to swap two variables, but in this assignment, you will accomplish this task without the extra variable. we will use the bitwise xor operator to swap the integers as the bitwise xor operator evaluates each bit of the result to 1 if the corresponding bits of the operands are different and 0 otherwise. programming with c and unix optional reference textbook by adam hoover to be . your ta or fellow students although not required, you may find chapter 2 on bits, bytes, and data types in the system for this recitation assignment, complete the following tasks. you may receive guidance frorm 1. declare an integer pointer and then request memory using malloc () for an array of 2 integers. this means that you should request memory for a size of 2 times the size of an integer and assign it to int_ptr. use man 3 malloc for details on this system call 2. if the malloc ) system call failed to return memory, print out a meaningful error message and terminate the program 3. prompt the user to enter the first integer using printf and then read in the user's response using scanf, storing the integer in the first element of the integer array allocated in step 1. 4. prompt the user to enter the second integer using printf and then read in the user's response using scanf, storing the integer in the second element of the integer array allocated in step 1. 5. now, print out the original values of both the integers input by the user. 6. this next step is where the swapping is done: a. use the bitwise xor operator on both the array elements and assign the result to the first element. b. use the bitwise xor operator on both the array elements and assign the result to the second element. c. use the bitwise xor operator on both the array elements and assign the result to the first element. 7. now, print out the swapped values of both the integers input by the user. 8. finally, release the allocated memory using free () sample output (user input shown in bold): $ . /a.out enter first integer: 571 enter second integer: 18 original values: 1st 571 2nd18 swapped values: 1st- 18 2nd571 $ . /a.out enter first integer: -4 enter second integer: 288 original values: 1st -4 2nd288 swapped values: 1st 288 2nd - -4
Answers: 1
Do you know the correct answer?
Using for loop . input an integer and identify whether it's even or odd ( without using modulo opera...

Questions in other subjects: