# iso646

***

**1. Basic Input and Output**

```cpp
#include <iostream>

int main() {
  char c;
  std::cin >> c;
  std::cout << c;
}
```

**2. Character Constants**

```cpp
#include <iostream>

int main() {
  char c = '\n';
  std::cout << c;
}
```

**3. Escape Sequences**

```cpp
#include <iostream>

int main() {
  char c = '\t';
  std::cout << c;
}
```

**4. String Literals**

```cpp
#include <iostream>

int main() {
  std::string s = "Hello, world!";
  std::cout << s;
}
```

**5. String Concatenation**

```cpp
#include <iostream>

int main() {
  std::string s1 = "Hello, ";
  std::string s2 = "world!";
  std::cout << s1 + s2;
}
```

**6. String Comparison**

```cpp
#include <iostream>

int main() {
  std::string s1 = "Hello";
  std::string s2 = "World";
  std::cout << (s1 == s2);
}
```

**7. String Finding**

```cpp
#include <iostream>

int main() {
  std::string s = "Hello, world!";
  std::cout << s.find("world");
}
```

**8. String Manipulation**

```cpp
#include <iostream>

int main() {
  std::string s = "Hello, world!";
  std::cout << s.replace(7, 5, "universe");
}
```

**9. String Formatting**

```cpp
#include <iostream>

int main() {
  int n = 10;
  std::cout << std::format("The number is {}", n);
}
```

**10. Regular Expressions**

```cpp
#include <iostream>
#include <regex>

int main() {
  std::string s = "Hello, world!";
  std::regex re("world");
  std::cout << std::regex_match(s, re);
}
```

**11. File Input and Output**

```cpp
#include <iostream>
#include <fstream>

int main() {
  std::ifstream in("input.txt");
  std::ofstream out("output.txt");
  std::string line;
  while (std::getline(in, line)) {
    out << line << std::endl;
  }
}
```

**12. Data Structures**

```cpp
#include <iostream>
#include <vector>

int main() {
  std::vector<int> v = {1, 2, 3};
  for (int n : v) {
    std::cout << n << " ";
  }
}
```

**13. Algorithms**

```cpp
#include <iostream>
#include <algorithm>

int main() {
  std::vector<int> v = {1, 2, 3};
  std::sort(v.begin(), v.end());
  for (int n : v) {
    std::cout << n << " ";
  }
}
```

**14. Object-Oriented Programming**

```cpp
#include <iostream>

class Person {
public:
  std::string name;
  int age;

  Person(std::string name, int age) {
    this->name = name;
    this->age = age;
  }

  void print() {
    std::cout << name << ", " << age;
  }
};

int main() {
  Person person("John", 30);
  person.print();
}
```

**15. Exception Handling**

```cpp
#include <iostream>

int main() {
  try {
    // Code that may throw an exception
  } catch (std::exception& e) {
    // Code to handle the exception
  }
}
```

**16. Templates**

```cpp
#include <iostream>

template<typename T>
T max(T a, T b) {
  return a > b ? a : b;
}

int main() {
  std::cout << max(1, 2);
}
```

**17. Lambda Expressions**

```cpp
#include <iostream>

int main() {
  int n = 10;
  auto lambda = [n](int x) { return x + n; };
  std::cout << lambda(5);
}
```

**18. Concurrency**

```cpp
#include <iostream>
#include <thread>

int main() {
  std::thread thread([] {
    // Code to be executed in a separate thread
  });
  thread.join();
}
```

**19. Input Validation**

```cpp
#include <iostream>

int main() {
  int n;
  while (!(std::cin >> n)) {
    std::cout << "Invalid input";
  }
}
```

**20. Error Handling**

```cpp
#include <iostream>
#include <stdexcept>

int main() {
  try {
    // Code that may throw an exception
  } catch (std::invalid_argument& e) {
    std::cout << e.what();
  }
}
```

**21. Debugging**

```cpp
#include <iostream>
#include <cassert>

int main() {
  int n;
  std::cin >> n;
  assert(n > 0);
  // ...
}
```

**22. Unit Testing**

```cpp
#include <iostream>
#include <gtest/gtest.h>

TEST(UnitTest, Test1) {
  // Assertions and tests
}

int main(int argc, char** argv) {
  return RUN_ALL_TESTS();
}
```

**23. Logging**

```cpp
#include <iostream>
#include <spdlog/spdlog.h>

int main() {
  auto logger = spdlog::stdout_logger_mt("console");
  logger->info("Hello, world!");
}
```

**24. Configuration**

```cpp
#include <iostream>
#include <boost/program_options.hpp>

int main(int argc, char** argv) {
  boost::program_options::options_description desc("Options");
  desc.add_options()
    ("help,h", "Show help message")
    ("config,c", boost::program_options::value<std::string>(), "Configuration file");

  boost::program_options::variables_map vm;
  boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);

  if (vm.count("help")) {
    std::cout << desc << std::endl;
    return 0;
  }

  std::string configFile;
  if (vm.count("config")) {
    configFile = vm["config"].as<std::string>();
  }

  // ...
}
```

**25. Networking**

```cpp
#include <iostream>
#include <boost/asio.hpp>

int main() {
  boost::asio::io_service io_service;
  boost::asio::ip::tcp::acceptor acceptor(io_service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 12345));
  for (;;) {
    boost::asio::ip::tcp::socket socket(io_service);
    acceptor.accept(socket);
    // ...
  }
}
```

**26. Database Access**

```cpp
#include <iostream>
#include <sqlite3.h>

int main() {
  sqlite3* db;
  sqlite3_open("database.db", &db);
  sqlite3_stmt* stmt;
  sqlite3_prepare_v2(db, "SELECT * FROM table", -1, &stmt, NULL);
  while (sqlite3_step(stmt) == SQLITE_ROW) {
    // ...
  }
  sqlite3_finalize(stmt);
  sqlite3_close(db);
}
```

**27. Image Processing**

```cpp
#include <iostream>
#include <opencv2/opencv.hpp>

int main() {
  cv::Mat image = cv::imread("image.jpg");
  cv::cvtColor(image, image, cv::COLOR_BGR2GRAY);
  cv::imshow("Image", image);
  cv::waitKey(0);
}
```

**28. GUI Programming**

```cpp
#include <iostream>
#include <wx/wx.h>

class MyApp : public wxApp {
public:
  bool OnInit() override {
    wxFrame* frame = new wxFrame(NULL, -1, "wxWidgets Example", wxPoint(50, 50), wxSize(450, 340));
    frame->Show();
    return true;
  }
};

wxIMPLEMENT_APP(MyApp);
```

**29. Web Development**

```cpp
#include <iostream>
#include <boost/beast.hpp>

int main() {
  boost::beast::http::server server;
  server.listen(boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 8080));
  server.run();
}
```

**30. Cloud Computing**

```cpp
#include <iostream>
#include <aws/s3/S3Client.h>

int main() {
  Aws::S3::S3Client s3Client;
  Aws::S3::Model::HeadBucketRequest request;
  request.SetBucket("my-bucket");

  auto outcome = s3Client.HeadBucket(request);
  if (outcome.IsSuccess()) {
    std::cout << "Bucket found" << std::endl;
  } else {
    std::cout << "Bucket not found" << std::endl;
  }
}
```

**31. Machine Learning**

```cpp
#include <iostream>
#include <mlpack/core.hpp>

int main() {
  arma::mat data = arma::randn(100, 10);
  arma::rowvec labels = arma::randi<arma::rowvec>(100, arma::distr_param(0, 2));
  mlpack::svm::LinearSVMClassifier classifier(data, labels);
  classifier.Train();
  // ...
}
```

**32. Natural Language Processing**

```cpp
#include <iostream>
#include <boost/spirit/home/qi.hpp>
#include <boost/spirit/home/karma.hpp>

int main() {
  std::string input = "John Doe, 30, Software Engineer";
  boost::spirit::qi::grammar<std::string::iterator, std::tuple<std::string, int, std::string>()> grammar;
  grammar = boost::spirit::qi::eps >> boost::spirit::qi::phrase_parse(
    input.begin(), input.end(),
    boost::spirit::qi::lit("John") >> boost::spirit::qi::lit("Doe") >> boost::spirit::qi::int_ >> boost::spirit::qi::lit("Software") >> boost::spirit::qi::lit("Engineer") >> boost::spirit::qi::eps
  );
  std::string name;
  int age;
  std::string occupation;
  bool success = boost::spirit::qi::phrase_parse(input.begin(), input.end(), grammar, boost::spirit::qi::space, std::tie(name, age, occupation));
  if (success) {
    std::cout << "Name: " << name << ", Age: " << age << ", Occupation: " << occupation << std::endl;
  }
}
```

**33. Computer Vision**

```cpp
#include <iostream>
#include <opencv2/opencv.hpp>
#include <boost/filesystem.hpp>

int main() {
  std::string path = "images/";
  boost::filesystem::directory_iterator end_itr;
  for (boost::filesystem::directory_iterator itr(path); itr != end_itr; ++itr) {
    cv::Mat image = cv::imread(itr->path().string());
    // ...
  }
}
```

**34. Audio Processing**

```cpp
#include <iostream>
#include <portaudio.h>

int main() {
  PaStreamParameters inputParameters;
  inputParameters.device = Pa_GetDefaultInputDevice();
  inputParameters.channelCount = 1;
  inputParameters.sampleFormat = paFloat32;
  inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
  inputParameters.hostApiSpecificStreamInfo = NULL;

  PaStream* stream;
  PaError err = Pa_OpenStream(&stream, &inputParameters, NULL, 44100, 1024, paNoFlag, NULL, NULL);
  if (err != paNoError) {
    std::cout << "Error opening stream: " << Pa_GetErrorText(err) << std::endl;
    return 1;
  }

  err = Pa_StartStream(stream);
  if (err != paNoError) {
    std::cout << "Error starting stream: " << Pa_GetErrorText(err) << std::endl;
    return 1;
  }

  while (1) {
    float inputBuffer[1024];
    err = Pa_ReadStream(stream, inputBuffer, 1024);
    if (err != paNoError) {
      std::cout << "Error reading stream: " << Pa_GetErrorText(err) << std::endl;
      break;
    }
    // ...
  }

  err = Pa_StopStream(stream);
  if (err != paNoError) {
    std::cout << "Error stopping stream: " << Pa_GetErrorText(err) << std::endl;
    return 1;
  }

  err = Pa_CloseStream(stream);
  if (err != paNoError) {
    std::cout << "Error closing stream: " << Pa_GetErrorText(err) << std::endl;
    return 1;
  }

  return 0;
}
```

**35. Robotics**

```cpp
#include <iostream>
#include <ros/ros.h>

int main(int argc, char** argv) {
  ros::init(argc, argv, "node_name");
  ros::NodeHandle nh;
  ros::Subscriber sub = nh.subscribe("/topic_name", 10, callback);
  ros::Publisher pub = nh.advertise<std_msgs::String>("/topic_name", 10);
  ros::Rate loop_rate(10);

  while (ros::ok()) {
    ros::spinOnce();
    loop_rate.sleep();
  }

  return 0;
}
```

**36. Simulation**

```cpp
#include <iostream>
#include <bullet/btBulletDynamicsCommon.h>

int main() {
  btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(NULL, NULL, NULL, NULL);
  btBoxShape* groundShape = new btBoxShape(btVector3(btScalar(2.0), btScalar(2.0), btScalar(2.0)));
  btRigidBody* groundBody = new btRigidBody(0, NULL, groundShape, btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0)));
  world->addRigidBody(groundBody);

  btCapsuleShape* capsuleShape = new btCapsuleShape(0.25, 0.5);
  btTransform capsuleTransform;
  capsuleTransform.setIdentity();
  capsuleTransform.setOrigin(btVector3(1.0, 1.0, 0.0));
  btRigidBody* capsuleBody = new btRigidBody(1.0, NULL, capsuleShape, btVector3(0.0, 0.0, 0.0));
  capsuleBody->setWorldTransform(capsuleTransform);
  world->addRigidBody(capsuleBody);

  while (true) {
    for (int i = 0; i < 10; i++) {
      world->stepSimulation(0.1, 1);
    }
    // ...
  }

  return 0;
}
```

**37. Optimization**

```cpp
#include <iostream>
#include <boost/optimization.hpp>

int main() {
  boost::optimization::function<double> f = [](const std::vector<double>& x) {
    return x[0] * x[0] + x[1] * x[1];
  };

  boost::optimization::minimizer minimizer;
  minimizer.set_function(f);
  boost::optimization::minimize(minimizer);

  std::cout << "Minimum found at: (" << minimizer.x()[0] << ", " << minimizer.x()[1] << ")\n";
  std::cout << "Minimum value: " << minimizer.value() << "\n";
}
```

**38. Parallel Programming**

```cpp
#include <iostream>
#include <boost/thread.hpp>

int main() {
  boost::thread t1([] {
    // ...
  });
  boost::thread t2([] {
    // ...
  });
  t1.join();
  t2.join();
}
```

**39. High-Performance Computing**

```cpp
#include <iostream>
#include <omp.h>

int main() {
  int n = 10000000;
  int sum = 0;
  #pragma omp parallel for reduction(+:sum)
  for (int i = 0; i < n; i++) {
    sum += i;
  }
  std::cout << "Sum: " << sum << std::endl;
}
```

**40. Embedded Systems**

```cpp
#include <iostream>
#include <termios.h>
#include <wiringPi.h>

int main() {
  wiringPiSetup();
  pinMode(0, INPUT);
  while (true) {
    int value = digitalRead(0);
    std::cout << "Button state: " << value << std::endl;
  }
}
```

**41. WebAssembly**

```cpp
#include <iostream>
#include <emscripten/emscripten.h>

void main_loop() {
  // ...
}

int main() {
  emscripten_set_main_loop(main_loop, 0, 0);
  return 0;
}
```

**42. Rust**

```rust
fn main() {
  println!("Hello, world!");
}
```

**43. Go**

```go
package main

import "fmt"

func main() {
  fmt.Println("Hello, world!")
}
```

**44. JavaScript**

```javascript
console.log("Hello, world!");
```

**45. Python**

```python
print("Hello, world!")
```

**46. Java**

```java
public class Main {
  public static void main(String[] args) {
    System.out.println("Hello, world!");
  }
}
```

**47. C#**

```csharp
public class Program {
  public static void Main(string[] args) {
    Console.WriteLine("Hello, world!");
  }
}
```

**48. PHP**

```php
<?php
echo "Hello, world!";
?>
```

**49. Ruby**

```ruby
puts "Hello, world!"
```

**50. Bash**

```bash
echo "Hello, world!"
```
