Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submitting milestone 17(a) #139

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ac43c7f
Create Sejal Chanchlani
sejalchanchlani Nov 10, 2020
5212258
Create Sejal
sejalchanchlani Nov 10, 2020
47c4d6c
Delete Sejal Chanchlani
sejalchanchlani Nov 10, 2020
5e89959
Create sa.txt
sejalchanchlani Nov 10, 2020
e763e96
Create bg.txt
sejalchanchlani Nov 10, 2020
f202f8f
Add files via upload
sejalchanchlani Nov 10, 2020
46fff1a
Add files via upload
sejalchanchlani Nov 10, 2020
ce1b772
Add files via upload
sejalchanchlani Nov 10, 2020
c665d74
Add files via upload
sejalchanchlani Nov 10, 2020
3cbc0ba
Delete Sejal
sejalchanchlani Nov 10, 2020
9752303
Delete sa.txt
sejalchanchlani Nov 10, 2020
516a6a2
Delete bg.txt
sejalchanchlani Nov 10, 2020
cd41fbe
Create ser.txt
sejalchanchlani Nov 12, 2020
590e5d6
Add files via upload
sejalchanchlani Nov 12, 2020
2770858
Create se.txt
sejalchanchlani Nov 14, 2020
19ba102
Add files via upload
sejalchanchlani Nov 14, 2020
4b2cdf9
Delete se.txt
sejalchanchlani Nov 14, 2020
46ff626
Create ts.txt
sejalchanchlani Nov 16, 2020
1e04672
Add files via upload
sejalchanchlani Nov 16, 2020
dbd52be
Create se.txt
sejalchanchlani Nov 17, 2020
a85603a
Add files via upload
sejalchanchlani Nov 17, 2020
ea71452
Create Milestone-07
sejalchanchlani Nov 22, 2020
d297df5
Delete Milestone-07
sejalchanchlani Nov 22, 2020
fb363db
Create ses.txt
sejalchanchlani Nov 22, 2020
af540d3
Add files via upload
sejalchanchlani Nov 22, 2020
6d52723
Create zs.txt
sejalchanchlani Nov 22, 2020
e93478f
Add files via upload
sejalchanchlani Nov 22, 2020
4a339af
Create cd.txt
sejalchanchlani Nov 23, 2020
fc28cce
Add files via upload
sejalchanchlani Nov 23, 2020
24bbccd
Add files via upload
sejalchanchlani Nov 23, 2020
1564c85
Delete cd.txt
sejalchanchlani Nov 23, 2020
72ec012
Add files via upload
sejalchanchlani Nov 27, 2020
42f42e3
Add files via upload
sejalchanchlani Nov 27, 2020
1f791a5
Add files via upload
sejalchanchlani Nov 28, 2020
20d0e62
Add files via upload
sejalchanchlani Nov 29, 2020
6794723
Create xs.txt
sejalchanchlani Nov 29, 2020
0ffbc4d
Add files via upload
sejalchanchlani Nov 29, 2020
4e08c10
Add files via upload
sejalchanchlani Nov 29, 2020
f170669
Add files via upload
sejalchanchlani Nov 30, 2020
ae1b6e0
Create nh.txt
sejalchanchlani Dec 3, 2020
29d178d
Add files via upload
sejalchanchlani Dec 3, 2020
25ec4b3
Add files via upload
sejalchanchlani Dec 3, 2020
f130403
Delete nh.txt
sejalchanchlani Dec 3, 2020
8bdbf72
Create xs.txt
sejalchanchlani Dec 6, 2020
8446e26
Add files via upload
sejalchanchlani Dec 6, 2020
87d7bcf
Add files via upload
sejalchanchlani Dec 6, 2020
03202bd
Add files via upload
sejalchanchlani Dec 6, 2020
921cb21
Add files via upload
sejalchanchlani Dec 8, 2020
c34c5f3
Add files via upload
sejalchanchlani Dec 9, 2020
ce6b2d7
Delete xs.txt
sejalchanchlani Dec 9, 2020
ce0bef5
Create se.txt
sejalchanchlani Dec 11, 2020
c74f76b
Add files via upload
sejalchanchlani Dec 11, 2020
078d19f
Create serd.txt
sejalchanchlani Dec 14, 2020
3118361
Add files via upload
sejalchanchlani Dec 14, 2020
48c4d16
Create ser.txt
sejalchanchlani Jan 14, 2021
b789276
Add files via upload
sejalchanchlani Jan 14, 2021
71e3936
Add files via upload
sejalchanchlani Jan 14, 2021
d51c0c1
Created using Colaboratory
sejalchanchlani May 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Milestone-17(a)/problem-01-17(a)- recursion -w3resource.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;
void print(int n)
{
if(n==1)
{
cout<<n<<" ";
return;
}
print(n-1);
cout<<n<<" ";
}
int main()
{
int n=50;
print(n);
}
21 changes: 21 additions & 0 deletions Milestone-17(a)/problem-02-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<iostream>
using namespace std;
int add(int n)
{
int sum=0;
if(n==1 || n==0)
{
return n;
}
// add(n-1);
sum=n+add(n-1);
return sum;
}
int main()
{
int n;
cout<<"enter n-"<<endl;
cin>>n;
int x=add(n);
cout<<"addition- "<<x;
}
17 changes: 17 additions & 0 deletions Milestone-17(a)/problem-03-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;
void print(int arr[],int index,int size)
{
if(index>=size)
{
return ;
}
cout<<arr[index]<<" ";
print(arr,index+1,size);

}
int main()
{
int arr[]={1,2,3,4,5};
print(arr,0,5);
}
17 changes: 17 additions & 0 deletions Milestone-17(a)/problem-04-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;
void print(int arr[],int index,int size)
{
if(index>=size)
{
return ;
}
cout<<arr[index]<<" ";
print(arr,index+1,size);

}
int main()
{
int arr[]={1,2,3,4,5};
print(arr,0,5);
}
21 changes: 21 additions & 0 deletions Milestone-17(a)/problem-05-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<iostream>
using namespace std;
int counter=0;
int count_digits(int n)
{

if(n!=0) // if(n<10)
{ // return 1;
counter++; // else
count_digits(n/10); // return 1+count_digits(n/10);
}
return counter;
}
int main()
{
int n;
cout<<"enter n - "<<endl;
cin>>n;
int x=count_digits(n);
cout<<"no of digits - "<<x;
}
18 changes: 18 additions & 0 deletions Milestone-17(a)/problem-06-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;
int sum=0;
int sum_of_digits(int n)
{
if(n==0)
{
return 0;

}
return n%10+sum_of_digits(n/10);
}
int main()
{
int n;
cin>>n;
cout<<"sum of digits- "<<sum_of_digits(n);
}
38 changes: 38 additions & 0 deletions Milestone-17(a)/problem-07-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>

using namespace std;
int gcd(int n1,int n2,int val)
{
cout<<"d"<<endl;
if(val>1)
{
cout<<"s"<<endl;
if(n1%val==0 && n2%val==0)
{
return val;
}

return gcd(n1,n2,val-1);
}
return 0;
}

int main()
{
int n1,n2;
cout<<"enter first number"<<endl;
cin>>n1;
cout<<"enter second number"<<endl;
cin>>n2;
int val;
if(n1>n2)
{
val=n1;
}
else{
val=n2;
}
int x=gcd(n1,n2,val);
cout<<"GCD of"<<n1<<"and"<<n2<<"is "<<x;
}

18 changes: 18 additions & 0 deletions Milestone-17(a)/problem-08-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;
int func(int arr[],int index,int size,int &max)
{
if(index < size)
{
if(max<arr[index])
max=arr[index];

func(arr,index+1,size,max);//calling the function MaxElem itself to compare with further element
}
return max;
}
int main()
{
int arr[]={1,2,5,3,4,10};
cout<<" max element - "<<func(arr,0,6,arr[0]);
}
20 changes: 20 additions & 0 deletions Milestone-17(a)/problem-09-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
#include<string.h>
using namespace std;
void print(string s,int index)
{
if(index>s.size())
{
return;
}
print(s,index+1);
cout<<s[index];
}
int main()
{
string s;
cout<<"enter string"<<endl;
cin>>s;
print(s,0);

}
20 changes: 20 additions & 0 deletions Milestone-17(a)/problem-10-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;
int fact(int n)
{
if(n==0 ||n==1)
{
return n;
}
else
{
return n*fact(n-1);
}
}
int main()
{
int n;
cout<<"enter number - "<<endl;
cin>>n;
cout<<"factorial of "<<n<<" is "<<fact(n);
}
27 changes: 27 additions & 0 deletions Milestone-17(a)/problem-11-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<iostream>
using namespace std;

long convert_binary(int n)
{
// static long bin,rem,fact=1;
static long bin,rem,fact=1;
cout<<"statcic bin -"<<bin<<endl;
if(n!=0)
{
rem=n%2;
bin=bin+rem*fact;
fact=fact*10;
convert_binary(n/2);
}
return bin;

}
int main()
{

int n;
cout<<"enter decimal number"<<endl;
cin>>n;
cout<<"binary number - "<<convert_binary(n);

}
31 changes: 31 additions & 0 deletions Milestone-17(a)/problem-12-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<iostream>
using namespace std;
int count=0;
bool prime(int ind,int n)
{
if(ind<n)
{
if(n%ind==0)
{
count=1;
return false;
}
prime(ind+1,n);
}
return true;
}
int main()
{
int n;
cout<<"enter number - ";
cin>>n;
prime(2,n);
if (count==0)
{
cout<<"prime number"<<endl;
}
else
{
cout<<"not a prime number "<<endl;
}
}
22 changes: 22 additions & 0 deletions Milestone-17(a)/problem-13-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>
using namespace std;
void print(int val,int n)
{
if(val>n)
{
return;
}
cout<<val<<" ";
print(val+2,n);
}
int main()
{
int n;
cout<<"enter n -"<<endl;
cin>>n;
cout<<"printing even numbers- ";
print(2,n);
cout<<endl;
cout<<"printing odd numbers - ";
print(1,n);
}
29 changes: 29 additions & 0 deletions Milestone-17(a)/problem-16-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<iostream>
#include<string.h>
using namespace std;
string palindrome(char s1[],int size,int index)
{
static string s2;
if(index>=size)
{
return s2;
}

palindrome(s1,size,index+1);
s2+=s1[index];
return s2;

}
int main()
{
char s1[20];
string s;
cout<<"enter any string "<<endl;
cin>>s1;
int size=strlen(s1);
s=palindrome(s1,size,0);
if(s1==s)
cout<<"yes";
else
cout<<"no";
}
32 changes: 32 additions & 0 deletions Milestone-17(a)/problem-17-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<iostream>
using namespace std;
int pow(int x,int p)
{
if(p==0)
{
return 0;
}
else if(p==1)
{
return x;
}
else
{
if(p%2==0)
{
int y=pow(x,p/2);
return y*y;
}
else
return pow(x,p-1);
}
}
int main()
{
int x,p;
cout<<"enter number whose power needs to be calculated"<<endl;
cin>>x;
cout<<"enter power - ";
cin>>p;
cout<<"ans- "<<pow(x,p);
}
24 changes: 24 additions & 0 deletions Milestone-17(a)/problem-19-17(a).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;
string copystring(string s1,int index,int size)
{
static string s2="";
if(index>=size)
{
return s2;
}
else
{
s2=s2+s1[index];
copystring(s1,index+1,size);
}
return s2;
}
int main()
{
string s1;
cout<<"enter string"<<endl;
cin>>s1;
string s=copystring(s1,0,s1.size());
cout<<"copied string - "<<s;
}
Loading