C++ :: Program To Display All Fibonacci Numbers And 21st Digit Using Array

Mar 7, 2013

Create a program that display all the fibonacci numbers and display the 21st digit using array.

Here's my code:

#include <iostream>
using namespace std;
int main () {
cout<<" This program shows a series of fibonacci numbers
"<<endl;

[Code] ....

View 2 Replies


ADVERTISEMENT

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;

[Code] .....

View 3 Replies View Related

C :: Program That Will Generate But Not Display Three-digit Target Number

Oct 6, 2014

Write a program that will generate, but not display, a three-digit "target" number that has three distinct digits. (Hint: use random number generator.) Then, input a maximum of ten user guesses and for each guess, output the number of hits and matches in the guess. Stop when the user guesses the number or runs out of guesses. For example, if the target is 427, the guess 207 has one hit (7) and one match (2).

View 8 Replies View Related

C :: Program That Displays Each Digit Of Integer In English - Zeros Won't Display

Apr 24, 2014

I'm new to C programming and in my first computer science class. Our assignment was to write a program that displays each digit of an integer in English. I wrote the following but cannot figure out why it won't display zeros. When I execute and type in the number 1,000, I get "zero."

Code:
#include <stdio.h>
int main (void)
{
int x, y = 0;
printf ("This program displays each digit of an integer in English.

[Code] ....

View 5 Replies View Related

C++ :: Game Of Pick 4 - How To Find Similar 4 Digit Numbers In Array Of 120

Jun 6, 2014

I have a question regarding finding similar 4 digit numbers in a pool of 120 numbers

Below is an linear single dimension array of 4 digits

There are 120, 4 digit numbers in total

My question is this - How can I code in C - a function that looks through all the 120, 4 digits to find similar numbers

Example - 2095 is similar or matches to - 0950, 5095, 5250, 5269 - i.e having 3 of the digits that are the same in the 4

The code must print out 2095 + all the matched numbers

If the Matched or Similar numbers are less then a certain number n - that number is discarded and the code should go onto the next number

2095095053741884864037233464846523768035
4340520865405306753553226100610753235081
1160346508409698809176715645765520676974
2398509523307591808464215318649140982136
2388015030217584311064844010520796345135
5376565155806436092330366745536969232311
4351519149310340620918615194324744655250
5330634052450976531053882380318069765623
2186677440212394367468519636617536556706
5274239549814534091052060118499521655275
6351091153944834003545212360098053955218
4835406061305276769161885611376776845269

I have written some code below but it is not working ...

Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <memory.h>
#include <dos.h>
FILE *fileptr;
FILE *fileptr1;

[Code] ....

View 10 Replies View Related

C++ :: Program That Display Prime Numbers From 1 To 100

Oct 4, 2014

This 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] ....

View 3 Replies View Related

C/C++ :: Program To Display First 10 Largest Numbers Present In A File?

Oct 15, 2012

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 Related

C++ :: Using Array - Display Highest And Lowest Numbers

Oct 1, 2013

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.

View 7 Replies View Related

C/C++ :: How To Do Fibonacci Sequence Program

May 5, 2014

Q) How to do nested loops?
Q) How to do Array?
Q) How to do Fibonacci sequence?

View 1 Replies View Related

C++ :: Find Remainder Of Two Many-digit Numbers

Aug 25, 2013

if i have two integers, say number1 and number2, stored in arrays where each index is a digit of the number (i.e. if my numbers are 321 and 158, then number1 = {3,2,1} and number2 = {1,5,8}), can i find the remainder of number1/number2? assume number1 > number2.

View 1 Replies View Related

C :: Which Data Type Have To Enter To Get 12 Digit Numbers

Jul 8, 2013

I've seen some threads that include the information about what data types one has to use usually to put a number of 12digit. But honestly speaking none of them works for me & it takes me a lot suffering about the data type. Even I've googled but I didn't get any specific result.

So, which data type I'd have to use to enter 12digit number.

I'm writing a code to find the largest prime factor of the number 600851475143

View 4 Replies View Related

C# :: Fibonacci Series - Adding Value In Array Inside While Loop

May 27, 2014

I am making a program to run Fibonacci series. I have created 2 array.

1)- 1st array holds only 0, 1
2)- 2nd array holds other values eg: 1, 2, 3, 5..........etc

I am using while loop to get the febonacci series and storing it in a 2nd array called int[] numbers.

After getting value using while loop, I am joing both the arrays using int[] final = arr.Concat(number).ToArray();

At last, I have used foreach loop to add the febonacci series into the listbox.

The problem I have is that, I cannot able to concat both the arrays. I tried to assign number array at the top of the while loop. so that number variable will be accessible outside the while loop. But I am getting a error.

See the code below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

[Code] .....

View 4 Replies View Related

C/C++ :: Swap A Digit From A Number With Another Digit Using Function

Oct 26, 2014

Write a function which will take 3 arguments. The function needs to return a new number which is formed by replacing the digit on a given position in the number with a digit which is carried as an argument (the position in the number is counted from right to left, starting with one). Write a main program which will print the newly formed number.

Examples:
A function call of 2376, 3 and 5 should return the number 2576
A function call of 123456, 4 and 9 should return the number 129456

What I succeeded to do so far:
Figure out the logic for swapping the digit and write working code for it (in the main function).

What I failed to do so far:
Write a function which will return the desired result.

What is my problem:
I tried writing a function to do this, but as you see from my calculations, my result is divided in 3 parts. I don't know how to return more variables from a function.

Code:

#include <stdio.h>
int main() {
int inputNumber, swapPosition, swapDigit;
scanf("%d%d%d", &inputNumber, &swapPosition, &swapDigit);
int i, numberPart1 = inputNumber;
for (i = 1; i <= swapPosition; i++)

[Code] ...

View 8 Replies View Related

C :: How Program Works If Integer Is More Than One Digit

Mar 15, 2013

Assignment: Take an integer keyed in from the terminal and extract and display each digit of the integer in English. Ex. 932 --> nine three two

Code:

/*This program takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English.*/
#include<stdio.h>
int main(void)
{
//DECLARE VARIABLES
int num;
}

[code]....

I don't know how the program works if the integer is more than one digit.

View 1 Replies View Related

C++ :: Create Program That Lists Off Each Digit Of Integer?

Mar 20, 2014

I need to create a program that lists off each digit of an integer and then display the sum off all the digits in that integer. I know that sepereatly the sum function i wrote works. But the first part which i try to list off the digits work but in reverse order which i dont know how to correct. and for some reason that i cant figure out this is affecting the sum output.

#include <iostream>
using namespace std;
int digcount (int x) {;

[Code]....

View 5 Replies View Related

C :: How To Get Each Digit Of A Number From Array

Apr 14, 2013

I have an array join[], some of its elements are single digit and some are numbers. I want to print the output in single digit form.Like in below code

Code:
int join[3]= {12,0,3};
int split;
int j;
for (j=0;j<3; j++) {

[Code] ....

My code won't consider array element "0". How can i fix it for that too.

Code: I want output should be like
1
2
0
3

View 4 Replies View Related

C++ :: Create Program That Has User Input 5 Digit Number?

Mar 9, 2013

Im trying to create a program that has the user input a 5 digit number. If it's between 10000 & 99999, it will do one thing..(just saying 'yes' for now. Outside those numbers will prompt the user to input again. However, if the user inputs the exact digits 76087, it should display 'term'.

This current code is displaying 'term' whenever the user inputs the 5 digits.

Code:

#include <iostream>
using namespace std;
int main() {
int pin;
cout << "Welcome to Movie Food
Enter your 5-digit pin code: " ;

[code]....

View 14 Replies View Related

C++ :: How To Save Two Digit Variables In Array

Feb 11, 2014

I am trying to redefine an array, but the result can only display one digit variable. I want the program to display 97 98 99 *+, but the program is only displaying 789*+.

int main() {
string test="abc*+";
for(int i=0; i<test.size;i++)

[Code].....

View 1 Replies View Related

C/C++ :: Finding First Non-repeated Digit In Array

Aug 26, 2014

With out sorting and if the array size is changed and filled with different elements, mayb some that are all duplicates(in that case display message that says "No nonrepeated digits".

This seemed like a simple task but im failing to grasp some concept. if the array is 2,0,38,2,3,1,3 the first non repeated is 0.
nested loop is how i went. i feel like im going to far with the counters than need be. just need first non repeated. if n equals 2 an o equals 0. and it iterates comparing 0,38,2,3,1,3 to n which is 2. repCount will b 1. if repcount was 0 then n would be the first non repeated number. im trying to consolidate my if else statements so there are not so many. This program fails if the array gets bigger say 2,45,2,7,1,8,9,45,1,10 .....

for (n=0; n<sizeof(digits)/sizeof(int); n++) {
if(repCount<2) {
// nonRepCount=0;
for (o=n+1; o<sizeof(digits)/sizeof(int); o++)

[Code] .....

View 1 Replies View Related

C/C++ :: Program Takes Integer Input And Displays Each Digit On New Line From Right To Left

Jan 23, 2015

I'm trying to create a program that takes an integer input and displays each digit on a new line from right to left.

An example of this would be:

Enter an integer: 657
Digit (1): 7
Digit (2): 5
Digit (3): 6

So far I have this:

#include <stdio.h>
#include <math.h>
int main() {
int i, input, output;
printf("Enter an integer: ");
scanf("%d", &input);
if(input == 0)
printf("Digit (1): 0");

[Code] ....

It works perfectly fine, but I just learned that I am not allowed to use the #include <math.h> so I have to take out floor, log, and pow.

I'm pretty sure I have to do some sort of while or for loop to get the results, but how to do it.

View 6 Replies View Related

C/C++ :: Program Which Ask For X Numbers And Store Them In Array

Nov 22, 2014

This is in c. Write a program which asks for X numbers, and stores them in an array.

The program then asks the user to enter a number to look for, and tells the user how many times that number appears in the array of numbers (if any), and the array index which contain the number

Make an array of the indexes where the number was found, and then format your output to match my output.

Sample Run:

How many numbers would you like to enter: 5

Please enter a number:1
Please enter a number:2
Please enter a number:3
Please enter a number:4
Please enter a number:2

The numbers you enter were: 1, 2, 3, 4, 2
Please enter a number to find: 2
The number appears 2 times, at array ellements with indexes 1, 4

Press any key to continue . . .

View 10 Replies View Related

C++ :: Heap And Priority Queue (Array Not Storing Digit)

Feb 27, 2015

This assignment is about Heap and PQ's to sort out jobs inside a printer. I'm far from finishing the assignment but the most important part isn't working. My issue is that nothing is getting stored inside the array. I keep getting crashes and at this point I'm not sure what to do. I notice that my destructor runs right after my "addJob" Function finishes, which is destroying the memory. Which might be why nothing gets stored inside OR I think my implementation of Heap/PQ is wrong.

Functions inside my test.cpp aren't properly done, they are made just to see if something is stored inside.

1. Check if I created the array correctly [PQtype.cpp / Heap.h/ PQType.h]
2. Am I even using/storing into the array. [Test.cpp "addJob" Function]
3. I'm also new to working with Class Templates.

PQType.h
template<class ItemType>
class PQType {
public:
PQType(int);
PQType(const PQType&); /

[Code] .....

View 4 Replies View Related

C :: Program That Sorts Array Of 5 Integer Numbers

Oct 6, 2013

Write a C program that sorts an unsorted array of 5 integer numbers in ascending order by swapping numbers repeatedly. Specifically, first prompt the user to input 5 numbers and store the numbers in an array. Then, if the numbers in the array are not in ascending order, ask the user to provide the indices of two numbers in the array that the user wants to swap. If the user does not enter valid indices (i.e., outside 0 to4), then re-prompt the user to enter new indices. Continue prompting the user to provide indices of numbers to swap until the array becomes sorted in ascending order. Finally, when the array becomes sorted, the program should print "The array is now sorted in ascending order".

Implementation Requirements

Use the #define directive to define the size of the array.

Implement a function called "checkArrayOrder" to check whether an array is in ascending order or not. The prototype of the function is

"intcheckArrayOrder(int arr[], int size);". The function should return

1 if the array passed to the function is in ascending order0 if the array passed to the function is not in ascending order

Define the function prototype in your program.

Implement a function called "swap", whose prototype is "int swap(int arr[], int size, int i, int j);" which swaps the numbers in positions "i" and "j" of the array passed to the function and returns

1 if the indices"i" and "j" are within bounds (i.e., between 0 and 4) and the swap operation is performed correctly.
0 if the indices"i" and "j" are outside bounds so that the swap operation cannot be performed.

Define the function prototype in your program.

Use the function "checkArrayOrder" whenever your program needs to check whether an array is in ascending order or not; and the function "swap" to swap the numbers the user specifies (Note that, you should check whether the user provided indices are valid inside the function "swap" and not inside "main").

here is my code so far

Code:
#define ARRAY_SIZE 5
void main()
{
int i, array[ARRAY_SIZE];

printf("Enter %d numbers
", ARRAY_SIZE);
for(i=0; i<ARRAY_SIZE; ++i)
scanf("%d", &array[i]);

[Code] .....

I'm just not sure how to proceed. I'm not really sure how to progress the checkArrayOrder function to the swap function (in the if statement).

View 7 Replies View Related

C :: Program That Fills Array With 10 Random Numbers Between 1 And 20

Apr 16, 2013

i have a programming problem and i am unsure of what the final part is.the question is:

Write a program that fills an array with 10 random numbers between 1 and 20, displays the 10 numbers, and finds the sum of the 10 numbers. Call the getData, displayData, and getSum functions from the main function. Output the sum from the main program by calling the getSum function within a printf statement.

i am just really unsure of what this is--getData, displayData, and getSum functions from the main function. Output the sum from the main program by calling the getSum function within a printf statement.what i have got so far is;

Code:

#include <stdio.h>
#include <stdlib.h>
#define ARY_SIZE 10
int main() {
int randomNumbers[ARY_SIZE], sum = 0, i;

[Code]....

View 1 Replies View Related

C++ :: Program To Store 10 Decimal Numbers In Array

Sep 24, 2014

Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the following:

Display each elements of the array
Display the sum of all the elements of array

View 1 Replies View Related

C++ :: Program That Takes Several Numbers Into Array Into A Function

Nov 25, 2014

I have to make a program that takes several numbers into an array into a function, and send them back into the main function multiplied by 1.13. This is what I have so far:

#include <iostream>
using namespace std;
void connell(int&n[20])
main() {
int num[20];

[Code] ...

I do not know how to get numbers from an array from a main program to a function.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved