-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_types.c
More file actions
78 lines (52 loc) · 1.48 KB
/
Copy pathdata_types.c
File metadata and controls
78 lines (52 loc) · 1.48 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <stdio.h>
int main(){
// first C program
// printf("Hello world!\n");
// Variables in C programming
// int age=33;
//int marks=87;
//printf("I am %d years old ",age); // %d is a format specifier
//printf("\n You scored %d in your exams.",marks);
// Different data types in C programming
/*
int (4 bytes) || %d
double (8 bytes) || %lf
float (4 bytes) || %f
char (1 byte) || %c
*/
/** int num1=21;
float num2=64.94f;
double num3=59893.5587765244;
double expo=45.6e7;
char character='B';
printf("int=%d",num1);
printf("\n float=%.3f",num2);
printf(" \n double=%.4lf",num3);
printf(" \n double=%.2lf",expo);
printf(" \n char=%c",character);
/// Size of() Operator under gcc data_types.c
printf("\nSize of int=%zu bytes",sizeof(num1));
printf("\nSize of float=%zu bytes",sizeof(num2));
printf("\nSize of double=%zu bytes",sizeof(num3));
printf("\nSize of double=%zu bytes",sizeof(expo));
printf("\nSize of char=%zu byte",sizeof(character));
**/
//// using the scanf() to take user input
/*int age;
printf("How old are you?");
scanf("%d",&age); // & represents the memory address of stored data
double decimals;
printf("Enter a double:");
scanf("%lf",&decimals);
printf(" Decimals=%.4lf \n",decimals);
printf("Age=%d",age);
*/
/// for multiple user input
int num;
float alp;
printf("Enter input");
scanf("%d %f",&num,&alp);
printf("integer=%d.",num);
printf("\n Float=%f",alp);
return 0;
}