Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,398 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,114 people online right now. Registration is fast and FREE... Join Now!




single count statement

 
Reply to this topicStart new topic

single count statement

ser
29 Oct, 2006 - 11:05 AM
Post #1

D.I.C Head
**

Joined: 29 Oct, 2006
Posts: 56


My Contributions
I HAVE STARTED A PROGRAM THAT GENERATES THE FOLLOWING:

1990 135
1991 7290
1992 11300
1993 16700

USE A SINGLE COUNT STATEMENT FOR ALL.

THE PROBLEM THAT I HAVE IS THAT I CAN NOT GET THE NUMBERS ON TO THE OTHER SIDE AS SHOWN ABOVE
CODE

#include<iostream>

  int main()
  {
  int count = 1990;
  cout<< ""<<count<<endl;  
  cout<< ""<<++count<<endl;  
  cout<< ""<<++count<<endl;
{
int count=1993;
cout<< ""<<count<<endl;
{
int count=135;
cout<< ""<<count<<endl;
{
int count=7290;
cout<< ""<<count<<endl;
{
int count=11300;
cout<<""<<count<<endl;
{
int count= 16700;
cout<<""<<count<<endl;
}
}
}
}
}
return 0;
}

User is offlineProfile CardPM
+Quote Post

dance_monkey()
RE: Single Count Statement
29 Oct, 2006 - 12:16 PM
Post #2

New D.I.C Head
Group Icon

Joined: 2 Mar, 2006
Posts: 13


Dream Kudos: 150
My Contributions
First of all, I don't know exactly what you are trying to do, but I do see some funny stuff happening. First of all, why would you put empty quotations after cout, like this:
CODE
cout << "";

It doesn't make any sense.

Also, why are you needlessly using curly brackets? This:
CODE
int main()
{
int count = 1990;
cout<< ""<<count<<endl;
cout<< ""<<++count<<endl;
cout<< ""<<++count<<endl;
{
int count=1993;
cout<< ""<<count<<endl;
{
int count=135;
cout<< ""<<count<<endl;
{
int count=7290;
cout<< ""<<count<<endl;
{
int count=11300;
cout<<""<<count<<endl;
{
int count= 16700;
cout<<""<<count<<endl;
}
}
}
}
}

could be re-written as this:
CODE
int main()
int count = 1990;
cout <<count<<endl;
cout << ++count << endl;
cout << ++count << endl;
int count=1993;
cout << count << endl;
int count=135;
cout << count << endl;
int count=7290;
cout << count << endl;
int count=11300;
cout << count << endl;
int count= 16700;
cout << count << endl;

What exactly was your question, and what exactly is the point of this program?
User is offlineProfile CardPM
+Quote Post

mattman059
RE: Single Count Statement
29 Oct, 2006 - 12:22 PM
Post #3

D.I.C Regular
Group Icon

Joined: 23 Oct, 2006
Posts: 340


Dream Kudos: 175
My Contributions
add the following to your program

#include iomanip

that allows you to do things such as setw for a format similar to what you're looking for. Also think about using the following for your cout

cout << "Something1" << setw(5) << "Something2" << endl;

that should give you :

Something1 Something 2
User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Single Count Statement
30 Oct, 2006 - 09:12 PM
Post #4

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
It is just a simple cout statement.......

CODE

a=135;
b=7290;
c=11300;
d=16700;

for (count=1990; count <= 1993)
{
           cout << "year" <<count<< "result" <<a;
           cout << "year" <<count+1<< "result" <<b;
           cout << "year" <<count+2<< "result" <<c;
           cout << "year" <<count+3<< "result" <<d;
}



This post has been edited by NyeNye: 30 Oct, 2006 - 09:13 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 03:01AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month