-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIf-else_WhileLoop_Patterns.cpp
More file actions
88 lines (81 loc) · 1.86 KB
/
If-else_WhileLoop_Patterns.cpp
File metadata and controls
88 lines (81 loc) · 1.86 KB
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
85
86
87
88
#include <iostream>
using namespace std;
int main(){
// *******positive or negative*******
/*
int a;
cin >> a;
if(a >0){
cout << "a is positive" << endl;
}
else if (a < 0){
cout << "a is negative" << endl;
}
else{
cout << "A is 0" << endl;
}
*/
// ******greater*******
/*
int a,b;
cout << "Enter A and B" << endl;
cin >>a >> b;
if (a > b){
cout << "A is greater" << endl;
}
else if (b > a){
cout << "B is greater" << endl;
}
else{
cout << "Both are equal" << endl;
}
*/
// *******identify the given character is upper or lowercase or numerical
/*
char ch;
cout << "Enter the character" << endl;
cin >> ch;
if (ch >= 'A' && ch <= 'Z'){
cout << "The given charater is a uppercase character" << endl;
}
else if (ch >= 'a' && ch <= 'z'){
cout << "The given character is a lowercase character" << endl;
}
else if (ch >= '0' && ch <= '9'){
cout << "The given character is a numerical" << endl;
}
*/
// *******sum of n natural numbers*******
/*
int n;
cout << "Enter how much numbers sum you want" << endl;
cin >> n;
int i = 1;
int sum = 0;
while (i <= n){
sum += i;
i++;
}
cout << "The sum of "<< n << " numbers is: " << sum<< endl;
*/
// ********sum of all even numbers between 0 to n********
/*
int n;
cout << "Enter the number " ;
cin >> n;
int i = 2;
int sum = 0;
while(i <= n){
sum += i;
i += 2;
}
cout << "Sum of even numbers between 0 to " << n <<" is " << sum ;
*/
// ********Celcius to farenheit table********
float c = 0,f;
while (c <= 100){
f = ((9*c)/5)+32;
cout << c <<" c = " << f << " f"<< endl;
c++;
}
}