1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sergiy2304 [10]
3 years ago
4

Write C expressions that evaluate to 1 when the following conditions are true and to 0 when they are false. Assume x is of type

int. Any bit of x equals 1. Any bit of x equals 0. Any bit in the least significant byte of x equals 1. Any bit in the most significant byte of x equals 0. Your code should follow the bit-level integer coding rules (page 128), with the additional restriction that you may not use equality (==) or inequality (!=) tests.

Computers and Technology
1 answer:
Bess [88]3 years ago
3 0

Answer:

Check the explanation

Explanation:

#include <stdio.h>

#include <stdlib.h>

//function to print a message

static void printMessage(char *msg)

{

printf("%s\n", msg);

}

//perform option A

int perform_A(int x)

{

//return true if any bit of x is equal to 1

return !!x;

}

//perform option A

int perform_B(int x)

{

//return true if any bit of x is equal to 0

return !x;

}

//perform option C

int perform_C(int x)

{

//return true if least significant bit is 1

return !!(x & 0xFF);

}

//perform option D

int perform_D(int x)

{

//return true if most significant bit is 0

return !!(~x & 0xFF);

}

//the main function

int main(void)

{

//set the integer

int input = sizeof(int) << 3;

//declare the test values

int onebitis1 = ~0;

int onebitis0 = 0;

int onebitLeast1 = 0xFF;

int onebitMost0 = 0xFF << (input - 8);

(perform_A(onebitis1)) && (printf("A return True\n"));

(perform_B(onebitis0)) && (printf("B returns True\12"));

(perform_C(onebitLeast1)) && (printf("C returns True\n"));

(perform_D(onebitMost0)) && (printf("D returns True\n"));

//to wait for a key press

getchar();

return 0;

}

Kindly check the attached image below to see the output.

You might be interested in
Imma say something random...
Fynjy0 [20]

Answer:

Uh I don't understand what you said.

Explanation:

N/A

5 0
3 years ago
Read 2 more answers
What is operating system​
iren [92.7K]

Answer:

It's simply a software that runs a computer's basic tasks, or functions, such as scheduling, running applications, and controlling peripherals.

3 0
3 years ago
Read 2 more answers
Which Internet of Things (IoT) challenge involves the difficulty of developing and implementing protocols that allow devices to
dolphi86 [110]

Answer:

Option C i.e., Interoperability is the correct option

Explanation:

Interoperability performs for computers or its components for the purpose to communicate and it is important to improve the development of the Internet of Things. It performs the communication as well as share their services between computer or its components.

It also contains challenges occurred at the time of developing and implementing the protocols by which they communicate.

7 0
4 years ago
Which page layout is most commonly used for a website with a large navigation menu?
mestny [16]

Explanation:

The Name is called, (navigation menu..)

to direct users 2 info., they look up...

7 0
3 years ago
Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and sec
fiasKO [112]

Answer:

Step by step explanation along with code and output is provided below

Explanation:

#include<iostream>

using namespace std;

// print_seconds function that takes three input arguments hours, mints, and seconds. There are 60*60=3600 seconds in one hour and 60 seconds in a minute. Total seconds will be addition of these three  

void print_seconds(int hours, int mints, int seconds)

{

   int total_seconds= hours*3600 + mints*60 + seconds;

   cout<<"Total seconds are: "<<total_seconds<<endl;

}

// test code

// user inputs hours, minutes and seconds and can also leave any of them by  entering 0 that will not effect the program. Then function print_seconds is called to calculate and print the total seconds.

int main()

{

   int h,m,s;

   cout<<"enter hours if any or enter 0"<<endl;

   cin>>h;

   cout<<"enter mints if any or enter 0"<<endl;

   cin>>m;

   cout<<"enter seconds if any or enter 0"<<endl;

   cin>>s;

   print_seconds(h,m,s);

  return 0;

}

Output:

enter hours if any or enter 0

2

enter mints if any or enter 0

25

enter seconds if any or enter 0

10

Total seconds are: 8710

8 0
4 years ago
Other questions:
  • Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in t
    6·1 answer
  • 1. In your own words, describe the purpose of a for a loop.
    11·1 answer
  • Which wireless communication is typically limited to six feet of distance?
    6·1 answer
  • If you copy and paste from someone else's document (such as a website, a friend's paper, an instructor's solutions manual, etc.)
    15·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • Which of these parts serves as the rear cross structure of a vehicle?
    12·1 answer
  • What is the difference between autofocus and autocomplete
    8·1 answer
  • Which storage is faster than secondary storage​
    14·2 answers
  • Write a statement that slices a substring out of the string quote and puts it into a variable named selection. If given the stri
    8·1 answer
  • What is the difference between a status bar, title bar, and tabs?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!