0% found this document useful (0 votes)
13 views2 pages

For-If Else

hgfd

Uploaded by

LUÂN LÝ MINH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

For-If Else

hgfd

Uploaded by

LUÂN LÝ MINH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>

int main() {
int a, b, tong = 0;

scanf("%d", &a);
scanf("%d", &b);

if (a < 0 || b < 0) {
printf("a va b phai khong am\n");
} else if (a > b) {
printf("a phai nho hon hoac bang b\n");
} else {
for (int i = a; i <= b; i++) {
if (i % 3 == 0) {
tong += i;
}
}
printf("Tong: %d\n", tong);
}

return 0;
}
#include <stdio.h>

int main() {
int m, n;

scanf("%d", &m);
scanf("%d", &n);

if (m <= 0) {
printf("m = %d, m phai nguyen duong\n", m);
} else if (n <= 0) {
printf("n = %d, n phai nguyen duong\n", n);
} else {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
printf("*");
} if (i!=m) {
printf("\n");
}
}
}

return 0;
}

You might also like