From 26184828408a1c9d88e7ccc6d57e4c1206f3f77a Mon Sep 17 00:00:00 2001 From: Shivam Singhal Date: Sun, 4 Jun 2017 14:12:56 +0530 Subject: [PATCH 1/3] Added buzz number program. --- .DS_Store | Bin 14340 -> 14340 bytes Buzz_number.cpp | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Buzz_number.cpp diff --git a/.DS_Store b/.DS_Store index 39daaec68403ee578354fe1cf49b731ffa1c78fd..50e1f7cb64997ecc4a3d4bab43a2d59b6122bc9e 100644 GIT binary patch delta 199 zcmZoEXepSmkL7CErU@G_nz2uOz`vQD!-|h_!e%G2$DEd2RtFgv7+4te7}6Os8A@{V zU0hO1OOhEFKpKEDC~_%Ca+Bi}q?vdNHdiaCurcw~OPF|>H!gA&RZM(?|syckR`EaFB bp~?2@e2fi~6;-u2SE{S=lcZyErFu62f@VV^ 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; +} From 74b6428eed1e09672cc097a619e293123f6b322e Mon Sep 17 00:00:00 2001 From: Shivam Singhal Date: Sun, 4 Jun 2017 15:57:09 +0530 Subject: [PATCH 2/3] Added happy number program. --- Happy_number.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Happy_number.cpp 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; +} From c1f2201e94f795f444ec80aecfffef2f509c9a22 Mon Sep 17 00:00:00 2001 From: Shivam Singhal Date: Tue, 6 Jun 2017 12:50:27 +0530 Subject: [PATCH 3/3] Added union and intersection of 2 arrays. --- Intersection_of_2_arrays.cpp | 30 ++++++++++++++++++++++++++++++ Union_of_2_arrays.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Intersection_of_2_arrays.cpp create mode 100644 Union_of_2_arrays.cpp 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