C++ :: Program To Display First 40 Fibonacci Numbers
Feb 25, 2014
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;
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.)
Display 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
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;
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.
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;
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
I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.
This is what I have ....
#include <iostream> using namespace std; int main() { int amount; int count; int number = 0; int smallest = 0; int largest = 0; cout << "Enter total numbers to process: ";
I made a fibonacci series with label above it now how to put the label after the first layer because as you can see in the screenshot the label is continuous.
I can't seem to get the math portion right. It is supposed to approximate pi using (sigma,i=-1 to infinity)(-1)^(i+1)(4/(2i-1))=4(terms of pi). And what I have does some math but it is incorrect because I get a negative value for pi and one that is entirely too large at that. The precision is also to be at 20 decimal places. I also need it to end immediately after if I get an invalid input, but I can't seem to get it to end after trying a few different things it will say that it is an invalid number, but will continue to run the math loop. I also need the final cout to print all the terms that is multiplied by 4.
[code]#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int nterm, numerator; double sum = 0.0; const int upperBound = nterm * 2; cout<<"This program approximates pi using an n-term series expansion. "<<endl;