[ create a new paste ] login | about

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

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

int main()
{
	int i, n;
	int count;
	do
	{
	printf("\nNhap n(n > 0): ");
	scanf("%d", &n);
	  if(n <= 0)
	   {
		printf("\n N phai > 0. Xin nhap lai !");
	   }
	}while(n <= 0);
    i = 1;
	count = 0;
	while(i <= n)
	{
		if(n % i == 0)
		{
		   printf("%4d", i);
		   count++;
		}
			i++;
	}
	printf("\nSo luong cac uoc so cua %d la: %d", n , count);
	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 cuong.luucb8921 on Aug 18
#include<stdio.h>

int main(){
int i;
int n;
int s = 0;
do
{
printf("Nhap vap n:\n");
scanf("%d",&n);
if(n < 1)
{
printf("n phai lon hon bang 1\n");
}
}while(n < 1);

for(i=1;i<=n;i++)
{
if(n%i==0)
{
s = s + 1;
}
}

printf("so uoc nguyen duong cua %d la %d",n,s);
return 0;
}
reply