Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkonde committed Jan 19, 2022
1 parent 8569fe5 commit 2e1e9e1
Show file tree
Hide file tree
Showing 21 changed files with 348 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language = "bash"
run = ""
7 changes: 7 additions & 0 deletions 1. Hello World.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World"<<endl;
return 0;
}
16 changes: 16 additions & 0 deletions 10. Vowel or Consonant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<iostream>
using namespace std;
int main()
{
char a;
cin>>a;
if( a=='a' || a=='e' || a=='i' || a=='o' || a=='u'|| a=='A' || a=='E' || a=='O' || a=='U' || a=='I' )
{
cout<<"Vowel"<<endl;
}
else
{
cout<<"Consonant"<<endl;
}
return 0;
}
20 changes: 20 additions & 0 deletions 11. Largest of three number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a>b && a>c)
{
cout<<"a is greator"<<endl;
}
else if(b>a && b>c)
{
cout<<"b is greator"<<endl;
}
else
{
cout<<"c is greator"<<endl;
}
return 0;
}
29 changes: 29 additions & 0 deletions 12. Roots of Quadratic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float a, b, c, x1, x2, discriminant, realPart, imaginaryPart;
cout << "Enter coefficients a, b and c: ";
cin >> a >> b >> c;
discriminant = b*b - 4*a*c;
if (discriminant > 0) {
x1 = (-b + sqrt(discriminant)) / (2*a);
x2 = (-b - sqrt(discriminant)) / (2*a);
cout << "Roots are real and different." << endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
else if (discriminant == 0) {
cout << "Roots are real and same." << endl;
x1 = -b/(2*a);
cout << "x1 = x2 =" << x1 << endl;
}
else {
realPart = -b/(2*a);
imaginaryPart =sqrt(-discriminant)/(2*a);
cout << "Roots are complex and different." << endl;
cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;
}
return 0;
}
19 changes: 19 additions & 0 deletions 13. Leap Year.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<iostream>
using namespace std;
int main()
{
int year;
cin>>year;
if(year%4==0)
{
if(year%100==0 and year%400==0)
{
cout<<"Leap year"<<endl;
}
else
{
cout<<"Not a leap year"<<endl;
}
}
return 0;
}
14 changes: 14 additions & 0 deletions 14. Sum of N numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
int sum=0;
for(int i=0;i<=a;i++)
{
sum=sum+i;
}
cout<<"Sum is: "<<sum<<endl;
return 0;
}
14 changes: 14 additions & 0 deletions 15. Factorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
int fact=1;
for(int i=1;i<=a;i++)
{
fact=fact*i;
}
cout<<"fact is: "<<fact<<endl;
return 0;
}
12 changes: 12 additions & 0 deletions 16. Multiplication Table.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=1;i<=10;i++)
{
cout<<a<<"*"<<i<<"="<<a*i<<endl;
}
return 0;
}
17 changes: 17 additions & 0 deletions 17. Fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;
int main()
{
int a=0,b=1,temp;
int c,d;
cin>>c;
cout<<a<<","<<b<<",";
for(int i=1;i<c;i++)
{
d=a+b;
a=b;
b=d;
cout<<d<<",";
}
return 0;
}
20 changes: 20 additions & 0 deletions 18. Fibonacci Series.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;
int main()
{
int a=0,b=1,temp;
int c,d;
cin>>c;
cout<<a<<","<<b<<",";
for(int i=1;i<=c;i++)
{
if(d<=c)
{
cout<<d<<",";
d=a+b;
a=b;
b=d;
}
}
return 0;
}
18 changes: 18 additions & 0 deletions 19. HCF and GCD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a,b,hcf=0;
cin>>a>>b;
int c=max(a,b);
for(int i=1;i<=c;i++)
{
if(a%i==0 && b%i==0)
{
hcf=i;
}
}
cout<<hcf;
return 0;
}
10 changes: 10 additions & 0 deletions 2. Cin Cout.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter a integer: ";
cin>>a;
cout<<a<<endl;
return 0;
}
55 changes: 55 additions & 0 deletions 20. LCM.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a,b;
int l[100],m[100];
cin>>a>>b;
int p,q;
int c=max(a,b);
for(int i=1;i<=c;i++)
{
p=a*i;
l[i]=p;

}
for(int i=1;i<=c;i++)
{
q=b*i;
m[i]=q;
}
for(int i=1;i<=c;i++)
{
for(int j=1;j<=c;j++)
{
if(l[i]==m[j])
{
cout<<l[i];
}
}
}
return 0;
}
/* #include <iostream>
using namespace std;
int main()
{
int n1, n2, max;
cout << "Enter two numbers: ";
cin >> n1 >> n2;
// maximum value between n1 and n2 is stored in max
max = (n1 > n2) ? n1 : n2;
do
{
if (max % n1 == 0 && max % n2 == 0)
{
cout << "LCM = " << max;
break;
}
else
++max;
} while (true);
return 0;
}
*/
12 changes: 12 additions & 0 deletions 3. Sum of Int.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"Enter first integer: ";
cin>>a;
cout<<"Enter second integer: ";
cin>>b;
cout<<"Sum is: "<<a+b<<endl;
return 0;
}
13 changes: 13 additions & 0 deletions 4. Dividend, Divisor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<iostream>
using namespace std;
int main()
{
int divisor,dividend;
cout<<"Enter divisor: ";
cin>>divisor;
cout<<"Enter dividend: ";
cin>>dividend;
cout<<"Remainder is: "<<int(divisor%dividend)<<endl;
cout<<"Quotient is: "<<int(divisor/dividend)<<endl;
return 0;
}
10 changes: 10 additions & 0 deletions 5. Sizeof.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<iostream>
using namespace std;
int main()
{
cout<<"Size of int is: "<<sizeof(int)<<endl;
cout<<"Size of float is: "<<sizeof(float)<<endl;
cout<<"Size of double is: "<<sizeof(double)<<endl;
cout<<"Size of char is: "<<sizeof(char)<<endl;
return 0;
}
15 changes: 15 additions & 0 deletions 6. Swap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,temp;
cin>>a>>b;
swap(a,b);
cout<<a<<" "<<b<<endl;
/*
temp=a;
a=b;
b=temp;
cout<<a<<" "<<b; */
return 0;
}
9 changes: 9 additions & 0 deletions 7. ASCII.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char a;
cin>>a;
cout<<"ASCII value is: "<<int(a)<<endl;
return 0;
}
12 changes: 12 additions & 0 deletions 8. Multiplication.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main()
{
float a,b;
double c;
cin>>a>>b;
c=a*b;
cout<<"Multiplication is: "<<c<<endl;
cout<<"Multiplication is: "<<a*b<<endl;
return 0;
}
24 changes: 24 additions & 0 deletions 9. Even Odd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a & 1)
{
cout<<"Odd"<<endl;
}
else
{
cout<<"Even"<<endl;
}
if(a%2==0)
{
cout<<"Even"<<endl;
}
else
{
cout<<"Odd"<<endl;
}
return 0;
}

0 comments on commit 2e1e9e1

Please sign in to comment.