-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lecture4 IntegerVariables.c
55 lines (38 loc) · 1.01 KB
/
Lecture4 IntegerVariables.c
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
53
54
55
#include <stdio.h>
#include <stdlib.h>
//Written by Bunyamin Yavuz in 2022
//Integer variables
int main()
{
/*
-----integer assignment-----
int variablename = (value);
example;
int number = 10;
*/
//Local integer assignment
int num1 = 8;
int num2 = 5;
//Default value 0
int sum = 0;
int divison = 0;
// int = int (+,-,/,%) int formula
sum = num1 + num2;
divison = num1/num2;
// %d is used to format integer and print it
//Output is 13
printf("The sum of two number taken : %d\n",sum);
//Output is 1 (Compiler converts integer if it is not)
printf("The division of two numbers taken : %d\n",divison);
//Let's do the same thing by using scanf function
int x,y;
int sum1 = 0;
// & is address operator, to determine the location in the memory
printf("Enter x: ");
scanf("%d",&x);
printf("Enter y: ");
scanf("%d",&y);
sum1 = x + y;
printf("Sum of x and y : %d",sum1);
return 0;
}