| | |
Help with for loop
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
C++ Syntax (Toggle Plain Text)
#include<iostream.h> main(){ int answer; for(int index = 12; index >= 1; i--){ answer=3*i; cout<<index<<" times 3 = "<<answer<<endl; } }
Last edited by Narue; Jun 1st, 2009 at 3:29 pm. Reason: added code tags
With my best wishes=>mostafa_adel01@yahoo.com
•
•
•
•
#include<iostream.h>
main(){
int answer;
for(int index = 12; index >= 1; i--){
answer=3*i;
cout<<index<<" times 3 = "<<answer<<endl;
}
}
Iwish that hels you GOOD LUCKk
-it's int main
-you're mixing index with the variable i
etc etc and use [code][/code] tags next time.
Last edited by iamthwee; Jun 1st, 2009 at 6:53 am.
*Voted best profile in the world*
•
•
Join Date: May 2009
Posts: 27
Reputation:
Solved Threads: 2
•
•
•
•
Hi, im new to c++ and wondered if anyone could help me with this
Use a for loop to display 3 times table backwards
12 times 3 = 36
11 times 3 = 33
10 times 3 = 30
9 times 3 = 27
8 times 3 = 24
7 times 3 = 21
6 times 3 = 18
5 times 3 = 15
4 times 3 = 12
3 times 3 = 9
2 times 3 = 6
1 times 3 = 3
C++ Syntax (Toggle Plain Text)
#include<iostream.h> main(){ int multiply; // for loop for 12 times for(int count = 12;count >= ;count--){ multiply = 3*count; cout << count << " times 3 = " <<multiply << endl; }//for return 0; }
Last edited by Tekmaven; Jun 1st, 2009 at 4:15 pm. Reason: Code Tags
Keep it simple:
C++ Syntax (Toggle Plain Text)
for (int i = 12; i; i--) cout << i << " times 3 = " << 3*i << '\n';
![]() |
Similar Threads
- Help with gui loop. (C)
- Loop...without the loop (Java)
Other Threads in the C++ Forum
- Previous Thread: C++ keep image floating within window
- Next Thread: error LNK 1120 and LNK 2001
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






