Skip to content

Commit d63e665

Browse files
authored
basics
1 parent a03ec5e commit d63e665

File tree

68 files changed

+2679
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2679
-0
lines changed

01_datatypes/datatypes.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//author :shreyamalogi
2+
3+
/*
4+
5+
6+
7+
*/
8+
9+
#include<iostream>
10+
using namespace std;
11+
12+
int main(){
13+
14+
int a; //declaration
15+
a=12; //initialisation
16+
17+
cout<<"size of int "<<sizeof(a)<<endl;
18+
19+
float b;
20+
cout<<"size of float "<<sizeof(b)<<endl;
21+
22+
char c;
23+
cout<<"size of char "<<sizeof(c)<<endl;
24+
25+
bool d;
26+
cout<<"size of bool "<<sizeof(d)<<endl;
27+
28+
short int si;
29+
long int li;
30+
cout<<"size of shortint "<<sizeof(si)<<endl;
31+
cout<<"size of longint "<<sizeof(li)<<endl;
32+
33+
34+
35+
return 0;
36+
}

02_if else/I_01_if else.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//author :shreyamalogi
2+
3+
// if else
4+
5+
#include<iostream>
6+
using namespace std;
7+
8+
int main()
9+
{
10+
int n=15;
11+
if(n>10)
12+
{
13+
cout<<"greater";
14+
}
15+
else
16+
{
17+
cout<<"smaller";
18+
}
19+
return 0;
20+
}
21+
22+
//greater

02_if else/I_02_if elseif else.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//author :shreyamalogi
2+
3+
/*
4+
print greater than elements
5+
use if else lader
6+
7+
*/
8+
9+
10+
//IF-ELSEIF-ELSE
11+
12+
#include<iostream>
13+
using namespace std;
14+
15+
int main ()
16+
{
17+
int tt;
18+
cin>>tt;
19+
while(tt--){
20+
21+
int n;
22+
cin>>n;
23+
24+
if(n>1 && n<10)
25+
cout<<"greater than 1 and less than 10";
26+
27+
else if (n>=20 && n<=30)
28+
cout<<"greater than 20 nad less than 30 ";
29+
30+
else
31+
cout<<"greater than 30";
32+
}
33+
return 0;
34+
}
35+
36+
//
37+
//3
38+
//2
39+
//greater than 1 and less than 10
40+
//21
41+
//greater than 20 nad less than 30
42+
//65
43+
//greater than 30
44+

02_if else/I_03_armstrong no.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//author :shreyamalogi
2+
3+
//armstrong number (cubes and add)
4+
5+
6+
//Armstrong number is a number that is equal to the sum of cubes of its digits.
7+
//For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers
8+
9+
#include<iostream>
10+
#include<math.h>
11+
using namespace std;
12+
13+
int main(){
14+
int n;
15+
cin>>n;
16+
17+
int sum=0;
18+
int originaln=n;
19+
while(n>0){
20+
int lastdigit = n%10;
21+
sum+= pow(lastdigit, 3);
22+
n = n/10;
23+
}
24+
25+
if(sum==originaln){
26+
cout<<"armstrong"<<endl;
27+
}
28+
else{
29+
cout<<"not armstrong"<<endl;
30+
}
31+
32+
33+
return 0;
34+
}
35+
36+
//
37+
//20
38+
//not armstrong
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//author :shreyamalogi
2+
3+
/*
4+
5+
check the maximum from three given numbers
6+
using nested if else
7+
8+
*/
9+
10+
11+
#include<bits/stdc++.h>
12+
13+
using namespace std;
14+
15+
int main()
16+
{
17+
int a,b,c;
18+
cin>>a>>b>>c;
19+
20+
//a is greater than b
21+
if(a>b){
22+
if(a>c){
23+
cout<<a<<endl;
24+
}
25+
else{
26+
cout<<c<<endl;
27+
}
28+
}
29+
30+
//b is greater than a (compare b and c)
31+
else {
32+
if(b>c)
33+
cout<<b<<endl;
34+
else
35+
cout<<c<<endl;
36+
}
37+
38+
return 0;
39+
}
40+
41+
42+
//12 56 32
43+
44+
//56
45+

02_if else/I_05_oddeven.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//author :shreyamalogi
2+
3+
/*
4+
5+
check if it odd or even using
6+
if lese statements
7+
8+
*/
9+
10+
11+
#include<bits/stdc++.h>
12+
13+
using namespace std;
14+
15+
int main()
16+
{
17+
int n;
18+
cin>>n;
19+
20+
if(n%2!=0)
21+
cout<<"odd"<<endl;
22+
else
23+
cout<<"even"<<endl;
24+
25+
return 0;
26+
}
27+

02_if else/I_06_triangle type.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//author :shreyamalogi
2+
//which type of triangle it is
3+
4+
#include <iostream>
5+
using namespace std;
6+
7+
int main()
8+
{
9+
10+
int sidea, sideb, sidec;
11+
cout << "Input three sides of triangle: \n ";
12+
cin >> sidea >> sideb >> sidec;
13+
14+
if (sidea == sideb && sideb == sidec)
15+
{
16+
cout << "This is an equilateral triangle. \n ";
17+
}
18+
else if (sidea == sideb || sidea == sidec || sideb == sidec)
19+
{
20+
cout << "This is an isosceles triangle. \n ";
21+
}
22+
else
23+
{
24+
cout << "This is a scalene triangle. \n ";
25+
}
26+
27+
return 0;
28+
}
29+
30+
31+
// 12 3 4
32+
//This is a scalene triangle.
33+
34+
// 1 2 2
35+
//This is an isosceles triangle.
36+
37+
// 12 12 12
38+
//This is an equilateral triangle.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//author :shreyamalogi
2+
3+
/*
4+
5+
6+
7+
*/
8+
9+
10+
#include <iostream>
11+
using namespace std;
12+
13+
int main()
14+
{
15+
char c;
16+
int isLowercaseVowel, isUppercaseVowel;
17+
18+
cout << "Enter an alphabet: ";
19+
cin >> c;
20+
21+
isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
22+
23+
isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
24+
25+
if (isLowercaseVowel || isUppercaseVowel)
26+
cout << c << " is a vowel.";
27+
else
28+
cout << c << " is a consonant.";
29+
30+
return 0;
31+
}
32+
33+
34+
//Enter an alphabet: a
35+
//a is a vowel.
36+
37+
//Enter an alphabet: k
38+
//k is a consonant.
39+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//author :shreyamalogi
2+
3+
//while loop
4+
//infinite loop for 10 times
5+
6+
#include<iostream>
7+
8+
using namespace std;
9+
10+
int main()
11+
{
12+
int i=0; //i is just our varibal
13+
while(i<10)
14+
{
15+
cout<<"hi"<<endl;
16+
i++;
17+
}
18+
return 0;
19+
}
20+
21+
//hi
22+
//hi
23+
//hi
24+
//hi
25+
//hi
26+
//hi
27+
//hi
28+
//hi
29+
//hi
30+
//hi
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
//author :shreyamalogi
3+
4+
/*
5+
6+
while loop satisfying both thec conditions
7+
for 10 times with test cases
8+
9+
*/
10+
11+
12+
#include<iostream>
13+
14+
using namespace std;
15+
16+
int main()
17+
{
18+
int t;
19+
cin>>t;
20+
while(t--){
21+
22+
int i;
23+
cin>>i;
24+
while(i<10 && i>5)
25+
{
26+
cout<<"hi"<<endl;
27+
i++;
28+
}
29+
30+
}
31+
return 0;
32+
}
33+
34+
35+
//4 test cases
36+
//2 no output
37+
//6 6 ki 4 his ostai
38+
//hi
39+
//hi
40+
//hi
41+
//hi
42+
//7 7 ki 3 times hi
43+
//hi
44+
//hi
45+
//hi
46+
//3 3 ki no output cuz it is less rthan 5
47+
48+

0 commit comments

Comments
 (0)