Counting the number digits in the given number

January 09, 2019

 NUMBER OF DIGIT IN THE 
GIVEN NUMBER
Image result for DIGITS



                               This code is to count how many digits in the given number.
For example, We are entering 5627 then the output is 4.Because digits in the given number is 4.

C language code for counting the digits: 

#include<stdio.h>
 #include<conio.h>
 int main()
 {
 int num,a,b=0;
 clrscr();
 printf("Enter an integer: \n");
 scanf("%d",&num);
 a=num;
 while(a!=0)
{ a=a/10;
++b;
}
printf("Number of Digits in %d:%d is ",num,b);
getch();
return 0;
}

------------------------------------------------------------------------------------
Output:
Enter an integer: 7648
Number of Digits in 7648 is 4.


Counting the number digits in the given number Counting the number digits in the given number Reviewed by Amit Waghmare on January 09, 2019 Rating: 5

Check the given number is even or odd

January 04, 2019

EVEN or ODD

Image result for EVEN OR ODD NUMBER quotes

c language code to check the number is even or odd:

#include<stdio.h>
#include<conio.h>
int main()
{int a;
printf("\nEnter any number: ");
scanf("%d",&a);
if(a%2==0)
{printf("\n%d is Even Number",a);
}
else
{printf("\n%d is Odd Number",a);
}
return 0;
}
---------------------------------------------------------------------------------------------
Output:
Enter any number:45
45 is Odd Number

Enter any number:80
80 is Even Number


Check the given number is even or odd Check the given number is even or odd Reviewed by Amit Waghmare on January 04, 2019 Rating: 5

C language code for Armstrong Number

January 04, 2019


 ARMSTRONG NUMBER

Image result for Armstrong number

                                     

 An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Also in the above image, we can see the example of Armstrong number.

C language code for Armstrong no:-

#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,b=0,t;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
t=n;
while(n>0)
{
a=n%10;
n=n/10;
b=b+a*a;
}
if(b==t)
printf("armstorng no");
else
printf("not an armstrong");
getch();
return 0;
}

------------------------------------------------------------------------------------------------------------------
Output:
Enter the number:153
Armstrong no

Enter the number:435
not an armstrong



Image result for armstrong no quote



C language code for Armstrong Number C language code for Armstrong Number Reviewed by Amit Waghmare on January 04, 2019 Rating: 5