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(); }

3rd Jan 2024, 1:39 PM
Shiddhat Kumar
Shiddhat Kumar - avatar
3 Réponses
+ 2
why would you place getch(); at the end?
3rd Jan 2024, 2:49 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 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(); }
3rd Jan 2024, 4:59 PM
Brian
Brian - avatar
+ 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.
3rd Jan 2024, 5:13 PM
Brian
Brian - avatar