0
Even odd
#include<stdio.h> #include<conio.h> void main() { int a; clrsscr(); printf("enter the value of a\n"); scanf("%d",&a); if(a%2==0) { printf("the number is even"); } else { printf("the number is odd"); } getch(); }
3 Réponses
+ 2
why would you place getch(); at the end?
+ 1
Shiddhat Kumar this code is written for a proprietary C development environment (historically, it was Borland Turbo C). It has nonstandard elements such as: conio.h, clrscr(), getch(), and void main() instead of int main()
If you want it to run on Sololearn then simply comment out or delete the nonstandard lines and declare int main().
#include <stdio.h>
//#include <conio.h>
//void main()
int main()
{
int a;
//clrscr();
.
.
.
//getch();
}
+ 1
Infinity the reason for the getch() at the end is that it prevents the MSDOS window from closing instantly after execution. It gives a pause for input so you may observe the results.