create a bool flag before the loop starts and set it to false. when a swap is made change the flag to true. on next loop iteration if the flag is still false then no swaps were performed during the previous loop iteration.

and please next time use code tags.

cutieyan: ammp i have a problem in making c++ programs,,,i am not familiar of it and it is very difficult for me ,our teacher told us to do a c++ program....what am i gonna do????plzzz hlp me

cutieyan...can u give an example of c++ programs for beginners like me....thank you

Don't you have a text book to study?

Simplest program, the famous Hello World program:

#include <iostream>

int main() {
  std::cout << "Hello World!" << std::endl;
  return 0;
};
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.