This program needs to be written in C. Please use pointers.
Implement a function that reverses the bits of a decimal number represented with an unsigned char. For example: f (1) ! 128; In binary: f (00000001) ! 10000000 Your function must have the following properties:
(a) Name: ReverseBits
(b) Return type: unsigned char
(c) Input: unsigned char
#include <stdio.h>
unsigned char ReverseBits(unsigned char input);
int main()
{
unsigned char output=ReverseBits(1);
printf("%u",output);
return 0;
}
unsigned char ReverseBits(unsigned char input) {
input = (input & 0xF0) >> 4 | (input & 0x0F) <<
4;
input = (input & 0xCC) >> 2 | (input & 0x33) <<
2;
input = (input & 0xAA) >> 1 | (input & 0x55) <<
1;
return input;
}
This program needs to be written in C. Please use pointers. Implement a function that reverses...
Write a program that allows the user to enter an unsigned integer (the maximum value of an unsigned 4-byte int is 232 = 4,294,967,296) and reverses its format (from little to big endian, or vice versa). Print out the user-entered number in hexadecimal and binary, reverse the endianness, and print the reverse in hexadecimal and binary. Integers in most machine architectures are represented in little endian format: the least significant byte is stored in the smallest address; for instance, the...
No pointers please
Urgent!!!
Q5. Implement a C program that includes a function that copies one string into another string. You cannot use string.h library for this exercise. Use the following function prototype: void copystring(chars1 ().char s2[]); A sample run would be as follows: Please enter a string: cngcourse String 1 is copied to String 2 String 1 is cngcourse and String 2 is cngcourse
The program needs to be written in C. Write a function void camelCase(char* word) where word consists of more than two words separated by underscore such as “random_word” or "hello_world_my_name_is_sam". camelCase() should remove underscores from the sentence and rewrite in lower camel case” (https:// en.wikipedia.org/wiki/Camel_case). Watch out for the end of the string, which is denoted by ‘\0’. You have to ensure that legal strings are given to the camelCase() function. The program should only run when the input is...
***The following is to be written in C:****
****The following is the sizeof.c program that needs to be
modified:****
****Section B11 the question asks to refer to:****
Modify the sizeof.c program (in the sizeof folder on github) and show the data range (min and max) in addition to the size of the data types in a nice table (print one line for each data type). Refer to section B11 in your textbook (page 257) for getting min and max values...
PRG255 3.2 (2 marks) Write a C program that uses the bitwise shift operators to shut the The program will ask the user to enter an unsigned also how many bits for the shift operation. Display the entered operation in both decimal and binary formats, vise shirt operators to shift the bits to the right >> or the left << user to enter an unsigned integer number, choose right shift or left shift, and orauon. Display the entered number and...
C programming lab: Description: In this lab you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use bitwise operators to embed and extract "hidden" bits in a character array. Write a program to test your functions as follows: Obtain a random number seed from the command line of your program using command line arguments. Initialize an array p of 8 unsigned char with random numbers from 0 to 255 Initialize a separate unsigned...
C program that uses
pointers as function arguments to do the
following:
To exemplify pointers, we will be doing quadratics. Remember that a quadratic expression is of the form: ax2 + bx + c where a. b, c are constant and a is not 0. You will scan in the values a. b. and c. With these values, you will write three functions: quadraticFormula quadraticVertex quadratic Info The first function will perform the quadratic equation to find the roots of...
C++ Write a recursive function that reverses the given input string. No loops allowed, only use recursive functions. Do not add more or change the parameters to the original function. Do not change the main program. #include <iostream> #include <string> using namespace std; //Write a recursive function 'void reverse(string &str)' that reverses the given input string. void reverse(string &str) { /*Code needed*/ } int main() { string name = "sherry"; reverse(name); cout << name << endl; //should...
Using C: Implement the function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of the types char, short, int, long, and long long, both signed and unsigned. You should do this by printing appropriate constants defined in the header file /usr/include/limits.h (this is why hw1.c starts with #include <limits.h>). This should print something like: signed char minimum value: -128 maximum value: 127 unsigned char minimum value: 0 maximum value: 255 signed short...
Code needs to be written by KickC - Optimizing C-compiler for 6502 you must write a simple function that displays a text message on the screen. The function signature should be: void print_to_screen(char *message); This function should accept a string, and write each character of the string to the screen, and increase the current_screen_x variable for each character printed. You will need to maintain a pointer to the current line on the screen, as well as the position on that...