diff --git a/12 may/ass2 q1.cpp b/12 may/ass2 q1.cpp new file mode 100644 index 0000000..1061862 --- /dev/null +++ b/12 may/ass2 q1.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int a, b, c, i,lcm, count=0; + cout<<"Integer A:"<>a; + cout<<"Integer B:"<>b; + cout<<"Integer C:"<>c; + cout<<"numbers are:"; + //brute force approach + for(i=1;i<=a;i++) + { + if(i%b==0 && i%c==0) + { + count++; + cout< +using namespace std; + + +int gcd(int a,int b) +{ + if(b==0) + return a; + else + return gcd(b,a%b); +} + +int main() +{ + int a,b,c; + cout<<"enter value 1:"<>a; + cout<<"enter value 2:"<>b; + c=gcd(a,b); + cout<<"Greatest common divisor is:"< +#include +using namespace std; +int main() +{ + vector ar; + ar.push_back(2); + ar.push_back(4); + ar.push_back(7); + ar.push_back(2); + ar.push_back(7); + ar.push_back(2); + ar.push_back(4); + int p=0,i; + cout<<"Array is:"< +#include +#include +using namespace std; +int main() +{ + vector ar; +/* ar.push_back(17); + ar.push_back(48); + ar.push_back(9); + ar.push_back(9);*/ + ar.push_back(9); + ar.push_back(5); + ar.push_back(3); + int i,j,minx=INT_MAX,b; + cout<<"Array is:"< +#include +using namespace std; +int main() +{ + int n,ans; + cout<<"enter number of bricks:"<>n; + ans=(-1+sqrt(1+8*n))/2; + cout<<"ans is"< +using namespace std; +int main() +{ + int n,i,j; + int A[50][50]={0}; + cout<<"enter range:"<>n; + for(i=0;i=j){ + if(i==j) + { + A[i][j]=A[i][j-1]; + } + else + { + A[i][j]=A[i][j-1]+A[i-1][j]; + } + } + } + } + cout<