I am attempting to write a program " that has a function that is passed an array of int and its size, and with that it prints out only the numbers that are above average. "
I have included my code so far, but I am only getting one value as output, and that value seems to be completely off. I keep trying, but I am really stuck.
#include <iostream> using namespace std; int average(int values[],int size); int main(){ int size; int values[] = {1,2,3,4,5,6};
[Code] ....
Added the floats in the average() function. But there is still a value problem.
I have a program in c++ to print all the binary numbers that have 64 bits. But the problem is it works only for 30 bits. Beyond that the program does not work possibly because of insufficient space availability.
my code is as below:
// C++ program to generate n-bit binary numbers #include <iostream> #include <string> #include <vector> #include <fstream> using namespace std;
// This function generates all n bit Gray codes and prints the generated codes void generateSequence(int n)
I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:
3 10110101 11111111 10101010
The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.
I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....
comparing with screen size the height is bigger but lenght is smaller. I don't understand.
I can understand that different printers process the fonts in different way and then to have different lenghts. That's not the problem. The problem is I need to simulate in screen the same behaviour i will have on printer because these texts are being aligned in the document, and I don't want to see that the text si aligned different in text than in paper.
What can I do to render the text on screen with the same size I will have on the printer? Print preview is doing it. Should I change the font parameters? is something related with pixels per inch?
I was trying to program an decimal to binary converter (8-bits) in C. I am a complete beginner so I tried to put the 1's and 0's of the binary number as they come without reversing the order for beginning. I have seen example on the internet but didn't understand them so I decided to write it as I understood it. So, I typed the code as shown below:
Code: #include <stdio.h> #include <stdlib.h> int main() { int number; int BitNum[8], x;
[Code] ....
The problem with the code is that if binary form has 0s in it then program displays a random number instead of a 0. For example if decimal is 7, it should print out 11100000 but it displays only 111(and some stupid numbers instead of 0). I have tried to solve it but failed.
I need to create a program which could create text files of the bits stored in avi file/binary file. My first requirement is to show 0s and 1s in the text representation . My second requirement is to create an avi file from this text file. I have tried few codings but either they give me error or they not playing the reconverted binary files.
I am making a program where the user enters numbers into an array and then a number,x. The array is sorted, then x is inserted into the appropriate place. I wrote my selection sort
Code:
void Sort(int ary[], int size) { int temp; int smallest; int current; int move; }
[code]....
put it wont print the numbers sorted when I use my print function, just the unsorted numbers.
My binary file size is 88200000 bytes, but each element should have 2 bytes. So when I use "infile.read( block , size)" , should I be using the size of the file or number of elements (44100000)?
And should block be resized to the number of bytes or the number of elements?
I am working on a project where I need to retrive a double number and store 8 bits of the number in one field and the other 16 bits in another field. the code below gives me an error.
lata= lat>>8; latb = (lat & 0xff);
The error states that & and >> are illegal for double. With this in mind, can I use these on a double. If not what can I do to achieve what I am trying to do?
I am having trouble getting the stars to output correctly in the printStars function. the final output should look something like this:
#include <iostream> using namespace std; int readArray(int input[], int size); void printArray(int input[], int count); void printStars(int input[], int size);
I want to make a program to print the product of even numbers between 1 and 30 and sum of odd numbers between 1 and 30. But the answer of product is negative. The photo shows the output of the code.
#include <stdio.h> #include <conio.h> void main () { int i, even_product=1, odd_sum=0; for(i=1;i<=30;i++) // For loop starts here!
Write a program that prompts the user to enter three integer values, and then outputs the values in numerical sequence separated by commas.
So, if the user enters the values 10 4 6, the output should be 4, 6, 10.
If two values are the same, they should just be ordered together.
So, the input 4 5 4 should give 4, 4, 5.
Code: #include "std_lib_facilities.h" int main() { cout << "Enter three integers, separated by space: "; int a, b, c, temp1 = 0, temp2 = 0; cin >> a >> b >> c;
[Code] ....
My first solution has a bug, so here's the corrected solution, written using only features I have learned in the first three chapters:
Code: #include "std_lib_facilities.h" int main() { cout << "Enter three words, separated by space: "; string a, b, c, temp; cin >> a >> b >> c;
I did write a print function which the user put a number and then it will print out till that number
the output is correct ,, but is code correct ? or it could be better somehow ?
write a function named print_out that print all the whole numbers from 1 to n. test the function by placing it in a program that passes a number n to print_out , where this number is entered from the keyboard . the print_out function should have type void; it does not return a value. the function can be called with a simple statement:
print_out(n);
PHP Code:
# include <iostream> using namespace std; void print_out (int x); int main () { int n; cout << " enter a number : ";
How to approach this? Not very clear on how hashing works..
Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Linear Probing.
75, 98, 43,1,-56,93,101,34,23
Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Chaining.
i am trying to write a program to get a number from user and then print even numbers as well as 0,2,4 and so on.what changes i should do ?
PHP Code:
# include <iostream> using namespace std; int main () { int n,i; cout << " Enter number "; cin >>n; i = 0; while ( i%2 == n) { cout <<i<<" "; i = i+1; } system ("PAUSE"); return 0; }
The program must print out 5 random numbers, from 1 to 45 and 100 different sequence.. Now I want each number of sequence to be different and not the same....
for example
1,2,3,4,5 6,7,8,9,10 .... ... ..
here is my code:
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main () { int xRan1;