[ create a new paste ] login | about

Link: http://codepad.org/7ANa5fgC    [ raw code | output | fork | 1 comment ]

C, pasted on Aug 21:
#include<stdio.h>
#include<conio.h>

int main()
{
	int themang, n, i;

	do
	{
		printf("\nNhap n: ");
		scanf("%d", &n);
	}while(n < 0 && printf("\nLoi: (n >= 0)"));

	themang = n;
	/*do
	{                                 
		i = themang % 10;
		themang /= 10;
	}while(themang != 0);*/                
	
	//có thể viết 
	do
	{
	  i = themang % 10;
	}while(themang /= 10);
	
	printf("\nChu so dau tien la %d", i);


	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by 1461512 on Oct 25
static int BT49(int n)//nhap vao n xuat ra chu so dau tien
{
int kq=0;
while(n >10)
{
n /= 10;
kq = n;
}
return kq;
}
reply