Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

* Phan Thành Tài

Bài 8
#include <iostream>

using namespace std;

int main() {
int n = 7;
float m;
float sum = 0;
while ( n > 0) {
cin >> m;
if (m == -1) {
break;
} else if ( m > 0) {
sum = sum + m;
cout << sum << endl;
n --;
} else if (m == 0) {
n --;
}
}
return 0;
}

Bài 2
#include <iostream>

using namespace std;

int main() {
float a;
cin >> a;
cout << a*a*a*a << endl;
return 0;
}
Bài 4
#include <iostream>

using namespace std;

int main() {
char c = 'h';
char c1 = c - 7;
char c2 = c + 18;
cout << c1 << endl << c2 << endl;
return 0;
}

Bài 6

#include<iostream>
using namespace std;

signed main() {
bool b = true;

// Đưa b về false
b = !b;

// Checker
cout << typeid(b).name(); // should be 'b' which stands for boolean
cout << "\n" << b << "\n"; // should be 0

// Đưa b trở về giá trị true ban đầu


b = !b;

// Checker
cout << typeid(b).name(); // should be 'b' which stands for boolean
cout << "\n" << b << "\n"; // should be 1
return 0;
}

You might also like