i have read a few threads and am amazed at how much help you get here. I just started learning C++... anyway here is my delema

i am working on a program that you have to enter a number but the seccond number has to be less that the first number, the third number has to be less than the seccond number and the fourth number has to be two less than the third number.

i want to use the keystroke logger so when you type in a number it each keystroke as a vairable and then i can just use this code

if (b < a && c < b && d == c-2){
cout<<"Congrats!! you found a number!";
}

or

if (b<a){
   if (c<b){
      if (d==c-2){
          cout<<"Congratulations you found a number!";
                     }
             }
          }

if any one knows of an easier and/or different way please let me know

>if any one knows of an easier and/or different way please let me know
An easier and different way is to just read all of the numbers and compare. At any given point it looks like you only need the current number and the previous number, and how much less the current number has to be than the previous number grows incrementally. I'm thinking of a simple loop:

#include <iostream>

using namespace std;

int main()
{
  const int n = 3;
  const int increment[n] = {1, 1, 2};
  int prev, curr;

  cin>> prev;
  for (int i = 0; i < n; i++) {
    cin>> curr;
    if (prev - increment[i] < curr)
      cerr<<"Invalid"<<endl;
    prev = curr;
  }
}

This can be adapted to reading single digits as well, if your intention is to enter a number such as 5431 and make sure that each digit is less than the previous by a certain amount.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.