#include <iostream> using namespace std; class sample //class creation { public: static int a; // datatype static void data() { cout<<"i am the best"; } //function }; int sample::a=10; //declaring datatype int main() { cout<<sample::a<<"\n"; //printing data sample::data(); //printing function without return type return 0; }
#include <iostream> using namespace std; int main() { int n[5], i, num_elements; cout << "Enter the number of elements (up to 3): "; cin >> num_elements; if (num_elements > 3) { cout << "Number of elements exceeds the limit of 3." << end; return 1; } cout << "Enter " << num_elements << " elements:" << endl; for (i = 0; i < num_elements; i++) { cin >> n[i]; } int temp, j; for (i = 1; i < num_elements; i++) { j = i; while (j > 0 && n[j] < n[j - 1]) { temp = n[j]; n[j] = n[j - 1]; n[j - 1] = temp; ...
Comments
Post a Comment