-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp2.cpp
45 lines (36 loc) · 989 Bytes
/
app2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Using while statement
Description:
You enter any number and the system tells you if it is even or odd number.
To halt the process type 0 or any negative number;)
This is implemented by using while loop. Simple like that:)
Iteration statements
The iteration statements repeatedly execute a statement.
while ( expression ) statement (1)
Author: Borin (https://br.linkedin.com/in/borinvini)
Edited by j3
date: jun, 12/2020
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int number;
printf("Please enter any number (To exit, type 0 or any negative number): ");
scanf_s("%d", &number);
while (number > 0)
{
if (number % 2 == 0)
{
printf("Even number!\n");
}
else
{
printf("Odd number!\n");
}
printf("Please enter any number (To exit, type 0 or any negative number): ");
scanf_s("%d", &number);
}
//system("pause");
return 0;
}