C++ :: How To Display File With Numbers On The Screen
Apr 1, 2013I have a file with numbers and want to display it on the screen.
View 15 RepliesI have a file with numbers and want to display it on the screen.
View 15 RepliesI 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....
there is a file contains only a numbers ,we dont know how many numbers present in that file.so i want a program to display top n largest number present in that fie.(n may be 5,10,12 like that.)
View 3 Replies View Relatedhow to display an image on the output screen of c++ program.
I am using : Turbo c++(dos box) on win8
NOTES AT BOTTOM---EXPLANTION, PROBLEMS ETC. SCROLL DOWN
#include <iostream>
#include <iomanip>
#include <string>
[Code]....
I have to write a program that stores information about students and displays results (Formated). Example-
Inputs ( # of students, First and Last name of student, the gender, age, and hieght. (height inputed as inches and outputed as feet and inches))
Student 2
---------
Jett, Joan Female
100 years old 5' 7"
Ive been falling behind a little due to working late and barely having time for my school work. Coming across several issues, one being an error with GENDER (Error C4700: uninitialized local variable 'gender' used:). As well as how to format the end result, i understand that u have to use #include <iomanip>, but am confused on how to format correctly.
I need to edit ,update and display a group of 40 parameters on screen. (10 parameters per page and use of Arrow Key pad or touch screen clicks to modify value)....
For that I will need .. Parameter No . , String Name , Point Screen Cord , double value , next element no. etc I have my old code with structure and array of structure written in C. I have translated it on C++/MFC .
How can I implement Class property of c++ ?
Write a program to enter data into a table and display on the screen in tabular form. I want to know where are the errors.
#include<iostream>
using namespace std;
int main() {
int table[3][4];
int r,c,i;
r=c=0;
while(r<=2)
[Code] .....
I'm trying to write a program that prints all of the prime numbers to the screen. I'm getting angry because it only prints EVERY number. I think it has something to do with the bool change not being able to leave the for-loop but how to fix it.
Code:
#import <stdio.h>
#include <stdbool.h>
int main(void){
printf("
The Primes Are: 1");
[Code] ....
i want to to apply a validation for an field which is Vehicle number in that the last four should be digits for ex:
AP1234 something like this it and it shldnt have 0000 at the last ...
float put;
put = 6/120;
cout << put;
This outputs 0. Why is it so and how can I make it output 6/120 in a more precise way?
Using for loop .....
View 15 Replies View RelatedDisplay the remainder of the square of numbers from 100 to 10. This square of numbers must be divisible by the numbers from 100 to 10 respectively. what i need to in this
View 3 Replies View RelatedThis is a program that display prime numbers from 1 to 100. it has problem linking when i run the program.
#include <iostream>
class Prime {
public:
int PrimeNo();
int Display();
};
// class Prime number
int Prime::PrimeNo()
[Code] ....
Write a program that displays the first 40 Fibonacci numbers. A Fibonacci number is created by add the previous two, with the first two always being 0 and 1. A partial sequence is as follows:
0, 1, 1, 2, 3, 5, 8, 13, 21,….
Your table must display 6 numbers per row and use a spacing of 10 for each number. Don’t forget to include the header file “iomanip” at the top and use “setw()”. You will need to turn in an algorithm, source code and output.
Here is what i have but i get errors!
#include <iostream>
using namespace std; {
int FirstNumber = 0;
int SecondNumber = 1;
int NumberOfNumbers = 2;
int NewNumber;
[Code] .....
My display is producing:
Enter the first number:234
Enter the second number:2
Enter the Third number:3
The largest number is 3
#include <iostream>
using namespace std;
double larger(double n1, double n2, double n3);
int main() {
[Code] ....
We were asked to make a program which displays the prime numbers within the range you inputted... like for example i entered 20 as the upper limit and 1 as the lower, then the program must display all prime numbers within 20 and 1..
and so my problem is, i get to display the prime numbers, but 2, 3, 5, and 7 can't because it think it's with the if statement i made within the loop? (Code below)
#include<iostream.h>
#include<conio.h>
void prime (int up, int low);
main() {
clrscr();
int Upper, Lower, i;
[Code] .....
Create a program that will display all the composite numbers from 0 to 1000 and has a maximum column of 5 . A composite number is a positive integer that has at least one positive divisor other than one or itself. In other words a composite number is any positive integer greater than one that is not a prime number.
SAMPLE OUTPUT:
4 6 8 9 10
12 14 15 16 18
20 21 22 24 25
26 27 28 30 32
....and so on.
I want to display the numbers in a bst but all I get are 0s, what is wrong with my code that is causing this?
#include <iostream>
using namespace std;
class binarySearchTree {
private:
class TreeNode {
friend class binarySearchTree;
int value;
[Code] ....
This code is suppose to display arithmetic sequence after it has to add all the numbers together without a formula.
for example: the starting number is 5, common difference is 3, the term is 9
the sequence would display as: 5, 8, 11, 14, 17, 20, 23, 26, 29
the sum is: 153
with my code I've managed to get 8,11
To get the sum, I am restricted to using a "for" loop. For sequence, I am using a while. I am trouble developing the while loop to display the sequence and getting the sum for the for loop.
#include <iostream>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main() {
double a, d, n,i,sum,j;
[Code] ....
I have everything down except for the highest # and lowest number being displayed.
The arrays are 23, 4, 76, 89, 12, 43, 37, 67, 21, 14.
I have the average which is 38.6 but i stuck getting highest number and lowest.
What shall I learn in order to send values from 0.00 to 5.00? I'm working with they Hitachi 16x2 LCD display.I've been sending/displaying literal values on it all day.
Code:
SendCharater(unsigned char val)
where the variable val corresponds to the LCD character table.I can also send Hello World to the display, like so:
Code:
void putsXLCD(unsigned char *buffer){
while(*buffer) // Write data to LCD up to null
{
while( BusyXLCD() ); // Wait while LCD is busy
SendCharacter(*buffer); // Write character to LCD
buffer++; // Increment buffer
}
return;
}
I could type in putsXLCD("5.00") in order to display it on the LCD, but how do I implement this automatically for values, e.g. 0.00 to 5.00?It appears I can only pass literal values through the function SendCharacter, meaning that in order to display "0" I have to pass the value 0x30 (the hex value of "0" on the LCD Table).
My current thought process:Much like passing "Hello World" in the function putsXLCD(), I need to assign a pointer that points at each value in the "array" that I need to send. E.g., I need to send 3.24, so I need to point to "3", fetch the corresponding hex value in the LCD table, in this case 0x34, and the pass this 0x34 into the SendCharacter function, and so on. So, if this is the case, how can I fetch the corresponding hex value?
I'm writing a program to display a histogram of 1000 Gaussian distributed numbers. I've generated the numbers using rand and now need to transform them. I have found the following formula to use
f(x) = exp(-x^2 / (2*sigma^2)) / sqrt(2*pi*sigma)
And I am unsure how to implement this into a function.
Program to read in 15 numbers and display them as follows //each number on a separate line
Code:
# include <stdio.h>
# define MY_ARRAY 15
int main(){
int i ;
printf("please enter 15 numbers
[Code] ....
Error that i get from compiler:
Error E2062 array1.c 14: Invalid indirection in function main()
Error E2062 array1.c 19: Invalid indirection in function main()
both pointing to the separate "scanf"
Create a program that will ask the user to enter a decimal value (1-999999) then display its corresponding binary numbers. Repeat this process until the value entered is equal to 0. Use the following Function Prototype:
void BinCodes(int value);
Sample Input/Output:
Enter a Decimal: 35
Binary: 100011
Enter a Decimal: 184
Binary: 10111000
Enter a Decimal: 0
Write a program which reads a stream of numbers from a file, and writes only the positive numbers to a second file. The user should be prompted to enter the names of both the input file and output file in main(), and then main() will open both files. Another function named process() must then be called to read all the numbers from the input file and write the positive numbers to the output file. Note that you must pass the open stream variables for each file as arguments to the process() function, and that you need to (always) double check that the files opened successfully before using them.
This is what I have so far but its not working out!
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int process(ifstream &inf, ofstream &outf);
[Code] ....
How to open a file and just print what is in that file on the screen. I though maybe I had the directory wrong but putting G: or G: give me the same result. When I select 1 it just goes to the next line and doesn't print anything.
Code:
int getchoice(void)
{
int num;
int choice;
FILE* outputfile;
[Code] ....