C PROGRAM:
#include <stdio.h>int main()
{
int num;
printf("Enter an number: ");
scanf("%d", &num);
(num % 2 == 0) ? printf("%d is even.", num) : printf("%d is odd.", num);
return 0;
}
OUTPUT:
C++ PROGRAM:
#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter an number: ";
cin>>num;
(num % 2 == 0) ? cout<<num<< "is even.":cout<<num<<" is odd.";
return 0;
}


No comments:
Post a Comment