C,
pasted
on Sep 2:
|
#include<stdio.h>
#include<conio.h>
int main()
{
long n, t;
int dem;
printf("\nNhap n: ");
scanf("%d", &n);
dem = 0;
t = n;
while(t != 0)
{
dem++;
t /= 10;
}
printf("\n%d", dem);
getch();
return 0;
}
|
Output:
|
Line 17: error: conio.h: No such file or directory
|
|
Create a new paste based on this one
Comments:
posted by
yonnon
on Jul 12
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cout <<"Enter your sentence: ";
cin >> n;
int temp=0;
while(n>0){
temp++;
n/=10;
}
cout<<temp<<
endl;
cin.ignore();
return 0;
}
reply
posted by
cuong.luucb8921
on Sep 1
#include<stdio.h>
int main(){
int n;
int t;
int sochuso=0;
do
{
printf("Nhap vap n:\n");
scanf("%d",&n);
if(n < 1)
{
printf("n phai lon hon bang 1\n");
}
}while(n < 1);
t=n;
while(t!=0)
{
sochuso = sochuso + 1;
t = t/10;
}
printf("So luong chu so cua %d la : %d",n,sochuso);
return 0;
}
reply
posted by
luongphongnhan
on Oct 22
#include<iostream>
using namespace std;
int demChuSo(int a) {
int dem = 0;
int phanDu;
while (a!= 0)
{
phanDu = a % 10;
dem += 1;
a /= 10;
}
return dem;
}
int main() {
int so;
do
{
cout << "Moi nhap so: ";
cin >> so;
if (so <= 0) {
cout << "Vui long nhap lai, so phai lon hon 0!";
}
} while (so<=0);
cout << "So vua nhap co so chu so la: " << demChuSo(so) << endl;
system("pause");
return 0;
}
reply
posted by
lehoangan01
on Nov 3
#include <iostream>
using namespace std;
int main(){
long long n;
int count = 0;
cout << " pls input n" << endl;
cin >> n;
while ( n != 0 ){
n /= 10;
count++;
}
cout << "the number of digit of n is " << count << endl;
return 0;
}
reply