Showing posts with label or. Show all posts
Showing posts with label or. Show all posts

C and C++ Programs to Check Whether a Number is Strong Number or Not

This post contains C and C++ program to check whether a given number is Strong number or not. A strong number is a number for which the sum of factorials of its digits is equal to the number itself. The first one is C program to check whether the input number is a strong number or not. An example is 145. 1!+4!+5!=1+24+120=145 Therefore 145 is a strong number.

C Program:

#include<stdio.h>
long int factorial(int n)

{

C and C++ Program to Check Whether a Given Number is Even or Odd

C and C++ programs to check whether a given number is Odd or even

C Program

#include<stdio.h>
void main()
{
int n;
printf("Enter an integer\n");
scanf("%d",&n);
if ( n%2 == 0 )
printf("Even");
else
printf("Odd");
}

C++ Program

#include<iostream.h>
void main()
{
int n;
cout<<"Enter an integer\n";
cin>>n;
if ( n%2 == 0 )
cout<<"\nEven";
else
cout <<"\nOdd";
}