-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject1_halley.c
More file actions
52 lines (28 loc) · 790 Bytes
/
project1_halley.c
File metadata and controls
52 lines (28 loc) · 790 Bytes
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
46
47
48
49
50
51
52
/*** Name: Ahmed Ghoneim..
* This program is made created to calculate when is comet halley going to
* appear ***/
#include<stdio.h>
int main()
{
//Integer Variables
int start_year = 1986;
// The year given by the consumer
int given_year = 0;
int numberof_years = 0;
// the year that comet halley is going to appear in
int appear_year;
int years_till;
printf("Enter Year: ");
scanf("%d",&given_year);
// validating user's input
if(given_year < start_year || given_year == start_year) {
printf("Invalid Input");
return 0;
}
// calculating when comet halley is going to appear
numberof_years = (given_year - start_year)%76;
years_till = 76 - numberof_years;
appear_year = given_year + years_till;
printf("%d", appear_year);
return 0;
}