-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.cpp
89 lines (64 loc) · 1.46 KB
/
all.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Logging my c++ learning progress
with this main file */
// First program
#include <iostream>
using namespace std;
int main(){
cout<< "hello\n\nbasic 2 line "<<endl;
}
// Second program (add 2 numbers)
#include <iostream>
using namespace std;
int main(){
int x,y;
cout<<"\n Program to find sum of 2 numbers\n";
cout<<"\n Enter a number: "; cin>>x;
cout<< "Enter 2nd number: "; cin>>y;
cout<<"Sum is: "<<x+y;
}
// Third program (Quotient and remainder)
#include <iostream>
using namespace std;
int main(){
int x,y;
cout<<"Enter a dividend: ";
cin>>x;
cout<<"Enter a divisor: ";
cin>>y;
cout<<"The quotient is: "<<x/y<<endl;
cout<<"The remainder is: "<<x%y<<endl;
}
// Fourth program (odd/even)
#include <iostream>
using namespace std;
int main(){
int n;
cout<<"Enter a number: ";
cin>>n;
if(n%2==0){
cout<<"Number is even";
}
else{
cout<<"number is odd";
}
}
// 5th program (check vowel or consonant)
#include <iostream>
using namespace std;
int main(){
char c;
bool smallVowel, bigVowel;
cout<<"Enter an alphabet: ";
cin>>c;
smallVowel = (c=='a'|| c=='e'|| c=='i'|| c=='o'|| c=='u');
bigVowel = (c=='A'|| c=='E'|| c=='I'|| c=='O'|| c=='U');
if(!isalpha(c)){
cout<<"Invalid character!!!";
}
else if(smallVowel || bigVowel){
cout<<"The letter is a vowel";
}
else{
cout<<"The letter is a consonant";
}
}