Help please!
Program in C
Problem-4
Write a function that receives an unsigned number and generates and returns a new number
that may or may not have an error in it. An error on a random bit must be introduced
randomly. Use the rand function to generate 0 or 1 to see if the error needs to be generated
and use a rand function in the range of 1 to 32 to see on which bit positon the error needs to
be introduced. The number with the given error must be the return value.
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// Function used to generate error integer if a=1 else return
number as it is
// srand function to generate random number along with
rand()%n
//srand() is random seed in order to generate random numbers each
time we run the program.
unsigned int findError(unsigned int num)
{
srand(time(NULL));
//a is generated randomly either 0 or 1
unsigned int y, a=rand()%2;
//a =1 means error need to be introduced
if(a==1)
{
// pos is generated randomly between 1 to 32
int pos = rand()%32+1;
//make a left shift in 1 to pos-1 time to reach to bit where error
need to be introduced
y= 1<<(pos-1);
//Introduce an error at desired bit by taking XOR of num with
y
num = num^y;
}
return num;
}
int main ()
{
unsigned int n;
printf("Enter an integer value: ");
scanf("%u", &n);
unsigned int ans = findError(n);
printf("%u\n",ans);
return 0;
}

Kindly revert for any queries
Thanks.
Help please! Program in C Problem-4 Write a function that receives an unsigned number and generates...
Write a C++ program that generates a random number from 0 to 9. It will then prompt the user to guess the random number it generated. Your program stops if the user guesses the right number. (Use the cout function to display the random number the computer generates so that you can determine if your code actually works). SAMPLE OUTPUT Random number = 8 Guess a number in the range [0,9]: 1 Too low Guess a number in the range...
Write a program in C to generate random numbers. The program recieves 4 items on activation through argv: 1. Name of the data file 2. Number of items for program to generate 3. Range of numbers 4. Seed of the random number generator Example run: ./rand datafile.txt 20 1000 3127 Program must convert all numbers to ints using atoi(), must save all parameters into variables, opens the data file to write the random numbers into it, program loops to generate...
Problem 1: Write a function add64 that adds two input unsigned 64 bit integers x and y and returns the unsigned 64 bit integer sum z, i.e. zx+y. In your main function, you should assume that x, y, and z will be stored in the following 6 registers as follows: x: upper 32 bits in $t1 y: upper 32 bits in St3 z: upper 32 bits in St5 lower 32 bits in $to lower 32 bits in $t2 lower 32...
The rand() function generates a random real number between 0 and 1, but what if we want real numbers in a different range? Use the rand function to generate a 4x5 matrix with random real numbers between 5 and 10. Store your result in the variable "mat".
C++ Write a program that generates and prints 24 random values using an array and the rand () function. Implement an algorithm to find the maximum and a minimum number of random numbers generated. Use the header "#include <ctime>", "#include <cstdlib>" in addition to the usual header: "#include <iostream>"
Programming C++ Language, PLEASE HELP, Will upvote Write a program that first generates two random decimal numbers within the range -100 to 100 inclusive. Next, generate a random number between 1 and 4 inclusive to correspond to each of our math operators (+, -, *, /). Finally, write out to a file called mathWorksheet.txt the following format: A o B = ? With A and B replaced by the two random numbers that were generated and o replaced by the...
(C++)Write a program that generates twenty five random integers between 0 and 24 and display the sum of even integers. (Hint: Use rand()%25 to generate a random integer between 0 and 24. Use an array of 25 integers, say num , to store the random integers generated between 0 and 24.)
C++ exercise: Lottery Number Generator Design a program that generates a 7-digit lottery number. The program should have an Integer array with 7 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 9 for each element. (Use the random function that was discussed in Chapter 6.) Then write another loop that displays the contents of the array.
Write a C++ program that simulates playing the Powerball game. The program will generate random numbers to simulate the lottery terminal generated numbers for white balls and red Powerball. The user will have the option to self-pick the numbers for the balls or let the computer randomly generate them. Set the Grand Prize to $1,000,000,000.00 in the program. Project Specifications Input for this project: Game mode choice – self pick or auto pick Five numbers between 1 and 69 for...
Write a C program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.)