File IO and Bit Manipulation Homework:
Write one program that calls 2 methods:
Method to read and write a file: Write a program to find the Average of Numbers stored in a text file, write the numbers and the average to the screen, and then write the numbers and their average to another file. Look at the contents of that new file. .
Details: Write a program that will ask the user for a file name. Contained in this file is a series of integers separated by white space. Read in the numbers, displaying them on the screen, adding them up and then calculating their average.
Then write the three numbers and average to one row in a new text file.
Note: If you get odd results for reading values, please be sure you do not have a \r carriage return in your file. You can remove \r using notepad++'s edit / EOL Conversion / Unix.
Method to change and display the bits of an integer: Ask the user to enter a number, displaying the number, shift the bits one way to the left and then display the new number in both hex and decimal format..
Use scanf to ask the user for an integer.
Then display the integer on the screen in both decimal and hex format (%d and %x).
Then move the bits of your integer over one place ot the left (<<=1) and display that new shifted number in both decimal and hex format (%d and %x).
Ask for one more integer.
Then use bitwise AND & againste the two integers to create a new integer. Print the new integer.