By GokiSoft.com| 15:35 09/09/2020|
Lập Trình C

[Share Code] Tìm hiểu biến & kiểu dữ liệu trong C - Lập trình C



Nội dung:
- Flowchart
	- ax+b=0
	- ax2 + bx + c = 0
- Code
	- Làm quen với code
	- Chuyển đổi flowchart sang code
	- phép tính +, -, *, * => dòng code căn bản
===============================================





#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	//bat dau code
	const int k = 10;
	//k = 12; => sai vi K la hang so
	
	int a, b;
	//a = 5;
	printf("\nNhap gia tri a = ");
	scanf("%d", &a);
	printf("\nNhap gia tri b = ");
	scanf("%d", &b);
	//b = 7;
	//tinh gia tri c
	int c;
	c = a + b;
	//hien thi ket qua
	printf("\nGia tri c = %d", c);
	printf("\nKet qua a + b = c <> 5 + 7 = 12");
	printf("\nKet qua a(%d) + b(%d) = c(%d)", a, b, c);
	
	float x1, x2;
	x1 = 5.2;
	x2 = 6.8;
	
	float x3 = 5.2, x4 = 6.7;
	
	printf("\nx1=%f, x2=%f", x1, x2);
	
	//ket thuc code
	return 0;
}




Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Do Trung Duc [T2008A]
Do Trung Duc

2020-09-13 04:05:51



#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int a, b, c, d, e, f;
printf("nhapgiatri a= ");
scanf("%d", &a);

printf("nhapgiatri b= ");
scanf("%d", &b);

printf("nhapgiatri c= ");
scanf("%d", &c);

printf("nhapgiatri d= ");
scanf("%d", &d);

printf("nhapgiatri e= ");
scanf("%d", &e);

printf("nhapgiatri f= ");
scanf("%d", &f);

int x;
x= pow(a,6) + b*c*d + e*f;
printf("\nGia tri x = %d", x);

int y;
y = pow(a,3)*pow(b,2) + a*b*d*e*f;
printf("\nGia tri y = %d", y);

return 0;
}