c program to find and print all armstrong number between 1 to 500

Armstrong numbers are:

Input :say value is 370.
When doing calculation for armstrong number:
370 is equal to (3*3*3)+(7*7*7)+(0*0*0) so output is 27+343+0 = 370
If input value is similar with output which is 370==370, then 370 is called an armstrong no.

#include
#include
void main()
{
  int number, j, remain;
  int cube=0, sum; 
  printf("\n Armstrong numbers between the limit from 1 to 500 are: \n"); 
  for(number=0;number<=999;number++)   
  {     
  	sum=0;
	j=number;     
	while(j>0)
    {
      remain=j%10;
      cube=remain*remain*remain;
      sum=sum+cube;
      j=j/10; 
    }
     if(number==sum)
     printf("\n%d is an armstrong no.",number);    
  }
     getch();
}

Ouput:

Armstrong numbers between the limit from 1 to 500 are:
1 is an armstrong no.
153 is an armstrong no.
370 is an armstrong no.
371 is an armstrong no.
407 is an armstrong no.

c program to find armstrong number between 0 and 999

Armstrong numbers:

Input :say 370.
Calculating armstrong number: 
  370=(3*3*3)+(7*7*7)+(0*0*0)= 27+343+0 =370 
If input equals output, 370==370, 370 is armstrong number.

#include<stdio.h>
#include<conio.h>
void main()
{
  int num, n, rem;
  int cube=0, sum; 
  printf("n Armstrong numbers between 0 and 999 are: n");
  for(num=0;num<=999;num++)
  {
    sum=0;
    n=num;
    do
    {
      rem=n%10;
      cube=rem*rem*rem;
      sum=sum+cube;
      n=n/10;
    }while(n>0);
    if(num==sum)
    {
      printf("n%d is armstrong number",num);    
    }
  getch();
}

Ouput:

Armstrong numbers between 0 and 999 are:
0 is armstrong number
1 is armstrong number
153 is armstrong number
370 is armstrong number
371 is armstrong number
407 is armstrong number

 

c program to find and print armstrong numbers between 100 and 999

Armstrong numbers:

Input : Say 153.
Calculating armstrong number: 
  153=(1*1*1)+(5*5*5)+(3*3*3)= 1+125+27 =153  
If input equals output, 153==153, 153 is armstrong number.

#include<stdio.h>
#include<conio.h>
void main()
{
  int num, n, rem;
  int cube=0, sum; 
  printf("n Armstrong numbers between 100 and 999 are: n");
  for(num=100;num<=999;num++)
  {
    sum=0;
    n=num;
    do
    {
      rem=n%10;
      cube=rem*rem*rem;
      sum=sum+cube;
      n=n/10;
    }while(n>0);
    if(num==sum)
    {
      printf("n%d is armstrong number",num);    
    }
  getch();
}

Ouput:

Armstrong numbers between 100 and 999 are:

153 is armstrong number
370 is armstrong number
371 is armstrong number
407 is armstrong number

 

Program to find range of different data types in C

ranges of various data types

Data type ranges specifies maximum value and minimum value which can be stored inside a variable of given data type. These data types can be used only when header files are included in program.

Below are the symbolic constants defined in header file which returns max and min limit for specific type of data.

Constants, data types predefined in   header file:

    • INT_MIN: This constant return min value of type integer (-32768)
    • INT_MAX: This constant return max value of type integer (32767)
    • UINT_MAX: This constant return max value of type unsigned integer (65535)
    • SHRT_MIN: This constant return min value of type short (-32768)
    • SHRT_MAX: This constant return max value of type short (32767)
    • USHRT_MAX: This constant return max value of unsigned short (65535)
    • LONG_MIN: This constant return min value of type long (-2147483648)
    • LONG_MAX: This constant return max value of type long (2147483647)
    • ULONG_MAX: This constant return max value of type long (4294967295)
    • CHAR_MIN: This constant return min value of type char regardless of whether type is signed or unsigned by default (-128)
    • CHAR_MAX: This constant return max value of type char regardless of whether type is signed or unsigned by default (127)
    • SCHAR_MIN: This constant return min value of type char (-128)
    • SCHAR_MAX: This constant return max value of type char (127)
    • UCHAR_MAX: This constant return max value of unsigned char (255)

Program to find range of int, char, short int, long int, etc types

program

Output:

output

Explanation:

Output of program shows minimum and maximum value held by any data type. It includes range of int, short int, long int, char, unsigned char types etc.

error: Content is protected !!