From b9251283622061084aaddae1509bbd9e91158d69 Mon Sep 17 00:00:00 2001 From: Chirag Chandel Date: Thu, 15 Jun 2023 22:13:24 +0530 Subject: [PATCH] File name 'Empty' added in set code snippet --- snippets/set/empty.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 snippets/set/empty.cpp diff --git a/snippets/set/empty.cpp b/snippets/set/empty.cpp new file mode 100644 index 00000000..66667073 --- /dev/null +++ b/snippets/set/empty.cpp @@ -0,0 +1,36 @@ +/* + Author : Chirag Chandel + Date : 15/06/2023 + Time : 10:00 + Description : This method returns true if their is no any element present in the set else returns false. +*/ + +#include +#include + +int main() { + // Create a set object holding integers + std::set s1{ 14, 12, 15, 11, 10 }; + std::set s2{}; + + std::bool check1 = s1.empty(); + std::bool check2 = s2.empty(); + + // print message if set is not empty + if (check1) { + std::cout << "Set is Empty" << std::endl; + } + else { + std::cout << "Set is Not Empty" << std::endl; + } + + //print message if set is empty + if (check2) { + std::cout << "Set is Empty" << std::endl; + } + else { + std::cout << "Set is Not Empty" << std::endl; + } + + return 0; +} \ No newline at end of file