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

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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.