| | |
Please help newbie:
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 10
Reputation:
Solved Threads: 0
I need to display 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 … I “must” use the “for” …This is what I have but it only counts by two. I don’t want the answer…however can you please give me some clues on the proper way to add the prior two numbers to get the needed sum?
C++ Syntax (Toggle Plain Text)
#include <iostream> using std::cout; using std::endl; // int main() { int count = 0; for ( int count = 1; count <= 55; count = count + 2) cout << count << endl; return 0; } //end of main function
Last edited by Ancient Dragon; Aug 27th, 2007 at 8:35 am. Reason: add code tags
•
•
Join Date: Aug 2006
Posts: 2
Reputation:
Solved Threads: 0
Have 2 variables outside the for loop. These two variables will contain the first 2 values. Display them. Inside the loop add these two variables which will result in third variable. Display the third variable's value. Once added and displayed, move second variable value to first variable, and move third variable value to second variable. The for loop condition should check for the last value of the third variable.
Hope this clarifies your query!!!!!
Hope this clarifies your query!!!!!
•
•
•
•
I need to display 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 … I “must” use the “for” …This is what I have but it only counts by two. I don’t want the answer…however can you please give me some clues on the proper way to add the prior two numbers to get the needed sum?
#include <iostream>
using std::cout;
using std::endl;
//
int main()
{
int count = 0;
for ( int count = 1; count <= 55; count = count + 2)
cout << count << endl;
return 0;
} //end of main function
•
•
Join Date: Aug 2007
Posts: 10
Reputation:
Solved Threads: 0
I still have errors please help?
C++ Syntax (Toggle Plain Text)
#include <iostream> using std::cout; using std::endl; int main() { int num1 = 0; int num2 = 1; cout << num1 << endl; cout << num2 << endl; for(int num = num1 + num2;) cout << num << endl; num1 = num2; num2 = num; return 0; } //end of main function
Last edited by Ancient Dragon; Aug 27th, 2007 at 8:36 am. Reason: code tags
•
•
Join Date: Aug 2007
Posts: 10
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include <iostream> using std::cout;using std::endl; int main() { int num1 = 0; int num2 = 1; cout << num1 << endl; cout << num2 << endl; for(int num = num1 + num2;) cout << num << endl; num1 = num2; num2 = num; return 0;} //end of main function#include <iostream> using std::cout; using std::endl; int main() { int num1 = 0; int num2 = 1; cout << num1 << endl; cout << num2 << endl; for(int num = num1 + num2;) cout << num << endl; num1 = num2; num2 = num; return 0; } //end of main function
Last edited by stymiee; Aug 27th, 2007 at 12:39 pm. Reason: fixed code tags
![]() |
Similar Threads
- As a newbie, where i should start from in linux? (Getting Started and Choosing a Distro)
- Questions about building a system (was: newbie) (Troubleshooting Dead Machines)
- Best free C/C++ compiler for a newbie? (C++)
- help newbie alert needs help with login page (ASP.NET)
- newbie needs help, basic mfc stuff (C++)
- Hello, newbie here... (Geeks' Lounge)
- Book For Newbie (C++)
- Newbie - how do I start C++ programming? (C++)
- PHP newbie, project feasibility (PHP)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: Visual C++ 2005 Express Edition IDE Help
- Next Thread: calculator with password
Views: 1425 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets







