C programming: Alice, Betty and Carol all vote on 16 separate referenda. Assume that each individual’s vote is represented bitwise in a 16-bit integer, represented in Hexadecimal. Write a function with its signature being short majority(short a, short b, short c) that returns the bitwise majority of the votes. For example, If inputs are 0x8E, 0x21, and 0xD4, the output should be 0x84.
Code
#include<stdio.h>
short majority(short a,short b,short c){
return (a & b) | (b & c) | (c & a);
}
int main(){
int a,b,c; //a,b,c is vote variable,defined as int because %x in scanf is compatible with int
printf("Enter Alice's vote\n");
scanf("%X",&a); //%x takes input in hex format ex-0x8E/0xd4
printf("Enter Betty's vote\n");
scanf("%X",&b);
printf("Enter Carol's vote\n");
scanf("%X",&c);
//pass to majority function by type casting to short
printf("Result of the vote is 0x%X\n",majority((short)a,(short)b,(short)c));
return 0;
}
================
Output

C programming: Alice, Betty and Carol all vote on 16 separate referenda. Assume that each individual’s...
Edit, compile, and run the following programs on the UNIX shell: Write a program that takes in six commandline arguments and has four functions (described below) that use bitwise operators. The user should enter six space-separated commandline arguments: four characters (any ASCII character) followed by two integers. Anything else should print an error message telling the user what the correct input is and end the program. Convert the commandline input into "unsigned char" and "unsigned int" datatypes. Be careful with...
Using C programming language
Question 1 a) through m)
Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....
Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. Commenting out the existing coding, write the code to divide a...
Please develop the following code using C programming and using the specific functions, instructions and format given below. Again please use the functions given especially. Also don't copy any existing solution please write your own code. This is the first part of a series of two labs (Lab 7 and Lab 8) that will complete an implementation for a board-type game called Reversi (also called Othello). The goal of this lab is to write code that sets up the input...
Programming Traversal Methods in C++ (depth first & breadth first) Need solution ASAP any help is much appreciated. read a set of data representing a directed, unweighted graph build an in-memory graph structure using the data display the graph using depth-first traversal display the graph using breadth-first traversal Input data - The data consists of records like this: 16 3 15 4 -1 This represents a vertex 16 with neighbors 3, 15, and 4. The -1 is the indicator that...
C++ For this assignment you will be building on the Original Fraction class you began last week. You'll be making four major changes to the class. [15 points] Delete your set() function. Add two constructors, a default constructor that assigns the value 0 to the Fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the Fraction, and the second parameter will represent the initial denominator of the Fraction. Since Fractions cannot have...