[ create a new paste ] login | about

Link: http://codepad.org/LYoGM6yI    [ raw code | output | fork | 4 comments ]

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

int main()
{

	int n;
	do
	{
		printf("\nNhap n(n >= 0): ");
		scanf("%d", &n);
		if(n < 0)
		{
			printf("\nN phai >= 0. Xin nhap lai !"); 
		}
	}while(n < 0);

	
	printf("\nSo %d gom toan cac chu so le hay khong ?\n", n);
	bool Check = true;
	while(n /= 10)
	{
		if((n % 10) % 2 == 0)
		{
			Check = false;
		    break;
		}
	}
	if(Check == true)
	{
		printf("Dung !");
	}
	else
	{
		printf("Sai");
	}
	getch();
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
Line 17: error: conio.h: No such file or directory
In function 'main':
Line 20: error: 'bool' undeclared (first use in this function)
Line 20: error: (Each undeclared identifier is reported only once
Line 20: error: for each function it appears in.)
Line 20: error: expected ';' before 'Check'
Line 25: error: 'Check' undeclared (first use in this function)
Line 25: error: 'false' undeclared (first use in this function)
Line 29: error: 'true' undeclared (first use in this function)


Create a new paste based on this one


Comments:
posted by khanhtienfz on Jun 25
include<stdio.h>
#include<stdlib.h>

int main()
{

int n;
do
{
printf("\nNhap n(n >= 0): ");
scanf_s("%d", &n);
if (n < 0)
{
printf("\nN phai >= 0. Xin nhap lai !");
}
} while (n < 0);
do{

int k = n % 10;

if (k % 2 == 1)
{
continue;
}

if (k % 2 == 0)
{
printf("\nCac chu so cua so nguyen duong n khong le hoan toan");
goto Khaipro;
}

} while (n /= 10);

printf("\nCac chu so cua so nguyen duong cua n toan le ");

Khaipro:
printf("\n\n");
system("pause");
return 0;

}

reply
posted by maiphu.2510@gmail.com on Aug 13
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n;
int s;
printf("\nNhap n = ");
scanf("%d",&n);

int t=n;
while(n!=0)
{
s=(n%10);
if(s%2==1)
{
printf("\n%d khong hoan toan la chu so chan",t);
break;
}
else
{
n=(n/10);
if(n==0)
{
printf("\n%d hoan toan la chu so chan",t);
}

}
}

getch();
return 0;
}

reply
posted by tanghocle456@gmail.com on Aug 8
#include <iostream>

using namespace std;

int main() {
int n,i=0,k,m=0;

do{
cout << "Nhap n (n>=0): " << endl;
cin >> n;
}while(n<=0 && cout << "Sai dieu kien.."<< endl);

while(n != 0) {
k = n%10;
i++;
if(k%2 != 0) {
m++;
}
n/=10;
}
if(i==m) cout << 1;
else cout << 0;

return 0;
}

reply
posted by minhnhut18c on Nov 10
#include <iostream>
#include<conio.h>

using namespace std;

void main()
{

int n, i = 0, k, m = 0;

do
{

cout << "Nhap n (n>=0): " << endl;
cin >> n;
if (n <= 0)
cout << "sai nhap lai" << endl;
} while (n <= 0);

while (n != 0) {
k = n % 10;
i++;
if (k % 2 != 0) {
m++;
}
n /= 10;
}
if (i == m) cout << "la so le" << endl;
else cout << "la so chan" << endl;

_getch();
}
reply