diff --git a/.DS_Store b/.DS_Store index 39daaec68..50e1f7cb6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Buzz_number.cpp b/Buzz_number.cpp new file mode 100644 index 000000000..3d39c50f6 --- /dev/null +++ b/Buzz_number.cpp @@ -0,0 +1,17 @@ +//A buzz number is a number that is either divisble by 7 or has last digit as 7. +#include +using namespace std; +int main() +{ + int n,t; + cin >> t; + while(t--) + { + cin >> n; + if((n%7==0)||(n%10==7)) + cout << n << " is a buzz number" << endl; + else + cout << n << " is not a buzz number" << endl; + } + return 0; +} diff --git a/Happy_number.cpp b/Happy_number.cpp new file mode 100644 index 000000000..ca252bd6e --- /dev/null +++ b/Happy_number.cpp @@ -0,0 +1,26 @@ +/* A happy number is a number whose sum of digits is calculated until the sum is a single digit, + and this sum turns out to be 1 */ +#include +using namespace std; +int main() +{ + int n,k,s=0,d; + cout << "Enter a number:"; + cin >> n; + s=n;k=n; + while(k>9) + { + while(k!=0) + { + d=n%10; + s+=d; + n/=10; + } + k=s; + s=0; + } + if(k==1) + cout << n << " is a happy number" << endl; + else + cout << n << " is not a happy number" << endl; +} diff --git a/Intersection_of_2_arrays.cpp b/Intersection_of_2_arrays.cpp new file mode 100644 index 000000000..e2c064e1b --- /dev/null +++ b/Intersection_of_2_arrays.cpp @@ -0,0 +1,30 @@ +#include +int main() +{ + int i,j,m,n; + cout <<"Enter size of array 1:"; + cin >> m; + cout <<"Enter size of array 2:"; + cin >> n; + int a[m]; + int b[n]; + cout <<"Enter elements of array 1:"; + for(i=0;i> a[i]; + for(i=0;i> b[i]; + i=0;j=0; + while((ib[j]) + j++; + else + { + cout << a[i++]<<" "; + j++; + } + } + return 0; +} diff --git a/Union_of_2_arrays.cpp b/Union_of_2_arrays.cpp new file mode 100644 index 000000000..4046e1ae8 --- /dev/null +++ b/Union_of_2_arrays.cpp @@ -0,0 +1,33 @@ +#include +int main() +{ + int m,n,i=0,j=0; + cout << "Enter size of both arrays:"; + cin >> m >> n; + int a[m]; + int b[n]; + cout << "Enter elements of array 1:"; + for(i=0;i>a[i]; + cout << "Enter elements of array 2:"; + for(i=0;i> b[i]; + i=0;j=0; + while((ib[j]) + cout << b[j++] <<" "; + else + { + cout << a[i++]; + j++; + } + } + while(i