-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode5.c
387 lines (290 loc) · 7.9 KB
/
code5.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<%
#include "header.h"
#include "Physics/Solver.h"
struct employee /* Defines a structure variable named temp */
{
char name[20];
int id;
long class;
} temp;
struct employee student, faculty, staff;
struct a var3;
struct point *p ;
struct point *p = &my_point;
struct point my_point = { 3, 7 };
// struct list_element {
// point p;
// list_element * next;
// };
int main() {
int a = 60; // 60 = 0011 1100
int b = 13; // 13 = 0000 1101
int c = 0;
c = a & b;
// 12 = 0000 1100
// cout << "Line 1 - Value of c is : " << c << endl ;
c = a | b; // 61 = 0011 1101
// cout << "Line 2 - Value of c is: " << c << endl ;
c = a ^ b; // 49 = 0011 0001
//cout << "Line 3 - Value of c is: " << c << endl ;
c = ~a; // -61 = 1100 0011
//cout << "Line 4 - Value of c is: " << c << endl ;
c = a << 2; // 240 = 1111 0000
//cout << "Line 5 - Value of c is: " << c << endl ;
c = a >> 2; // 15 = 0000 1111
//cout << "Line 6 - Value of c is: " << c << endl ;
return 0;
}
float average (int n_args)
{
char newline = '\n';
char tab = '\t';
char backspace = '\b';
char backslash = '\\';
char nullChar = '\0';
char quot = '"';
date my_date = #14-05-1993#;
string mistr = "This\nis\na\ntest\n\nShe \"said, \"How are you?\"\n";
int numbersAdded = 3.0;
int sum = 23.45;
int hex = 0x3F7;
int octal = 07;
int number = 78;
int n = 23e10;
int n2 = 23e-5;
while (numbersAdded < n_args) {
// int number = va_arg (myList, int); // Get next number from list
sum += number;
numbersAdded += 1;
}
va_end (myList);
//float avg = (float)(sum) / (float)(numbersAdded); // Find the average
return avg;
/* my first program in C */
printf("Hello, World! \n");
string mistr = "mi cadena ";
float = 'a';
return 0;
/*
* Comments blocks like this explain what the following code attempts
* to do. These comments often come directly from the design
* statement.
*/
/// <summary>
/// Here is how to use the class: <![CDATA[ <test>Data</test> ]]>
/// </summary>
//"This\nis\na\ntest\n\nShe said, \"How are you?\"\n"
int x; /* A normal integer*/
int *p; /* A pointer to an integer ("*p" is an integer, so p
must be a pointer to an integer) */
p = &x; /* Read it, "assign the address of x to p" */
scanf( "%d", &x ); /* Put a value in x, we could also use p here */
printf( "%d\n", *p ); /* Note the use of the * to get the value */
getchar();
//typedef enum {RANDOM, IMMEDIATE, SEARCH} strategy;
//strategy my_strategy = IMMEDIATE;
bool existe = false;
bool no_existe = true;
}
struct MyStruct {
int m_aNumber;
float num2;
};
struct Books {
char title[50];
char author[50];
char subject[100];
int book_id;
} book;
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
char _temp;
extern int d = 3, f = 5; // declaration of d and f.
int d = 3, f = 5; // definition and initializing d and f.
//byte z = 22; // definition and initializes z.
char x = 'x'; // the variable x has the value 'x'.
// Variable declaration:
extern int a, b;
extern int c;
extern float f;
int main () {
/* variable definition: */
int a, b;
int c;
float f;
/* actual initialization */
a = 10;
b = 20;
a++;
b--;
c = a + b;
printf("value of c : %d \n", c);
f = 70.0/3.0;
printf("value of f : %f \n", f);
return 0;
}
int numbersAdded = 3.0;
int numbersAdded = 3.0; int sum = 23.45; int hex = 0x3F7;
int octal = 07; int number = 78; int n = 23E10; int n2 = 23e-5;
int a = 5;
int b = 20;
int c ;
if ( a && b ) {
printf("Line 1 - Condition is true\n" );
}
if ( a || b ) {
printf("Line 2 - Condition is true\n" );
}
/* lets change the value of a and b */
a = 0;
b = 10;
if ( a && b ) {
printf("Line 3 - Condition is true\n" );
}
else {
printf("Line 3 - Condition is not true\n" );
}
if ( !(a && b) ) {
printf("Line 4 - Condition is true\n" );
}
int main() {
int a = 21;
int b = 10;
int c ;
if( a == b ) {
// cout << "Line 1 - a is equal to b" << endl ;
} else {
// cout << "Line 1 - a is not equal to b" << endl ;
}
if ( a < b ) {
// cout << "Line 2 - a is less than b" << endl ;
} else {
//cout << "Line 2 - a is not less than b" << endl ;
}
if ( a > b ) {
//cout << "Line 3 - a is greater than b" << endl ;
} else {
//cout << "Line 3 - a is not greater than b" << endl ;
}
/* Let's change the values of a and b */
a = 5;
b = 20;
if ( a <= b ) {
//cout << "Line 4 - a is either less than \
// or euqal to b" << endl ;
}
if ( b >= a ) {
// cout << "Line 5 - b is either greater than \
// or equal to b" << endl ;
}
return 0;
}
int main() {
int a = 21;
int b = 10;
int c ;
if( a == b ) {
//cout << "Line 1 - a is equal to b" << endl ;
} else {
//cout << "Line 1 - a is not equal to b" << endl ;
}
if ( a < b ) {
//cout << "Line 2 - a is less than b" << endl ;
} else {
// cout << "Line 2 - a is not less than b" << endl ;
}
if ( a > b ) {
// cout << "Line 3 - a is greater than b" << endl ;
} else {
//cout << "Line 3 - a is not greater than b" << endl ;
}
/* Let's change the values of a and b */
a = 5;
b = 20;
if ( a <= b ) {
// cout << "Line 4 - a is either less than \
// or euqal to b" << endl ;
}
if ( b >= a ) {
// cout << "Line 5 - b is either greater than \
// or equal to b" << endl ;
}
string mi_str = "prueba\
dos";
return 0;
}
int main() {
int a = 21;
int c ;
c = a;
//cout << "Line 1 - = Operator, Value of c = : " <<c<< endl ;
c += a;
//cout << "Line 2 - += Operator, Value of c = : " <<c<< endl ;
c -= a;
//cout << "Line 3 - -= Operator, Value of c = : " <<c<< endl ;
c *= a;
//cout << "Line 4 - *= Operator, Value of c = : " <<c<< endl ;
c /= a;
//cout << "Line 5 - /= Operator, Value of c = : " <<c<< endl ;
c = 200;
c %= a;
//cout << "Line 6 - %= Operator, Value of c = : " <<c<< endl ;
c <<= 2;
//cout << "Line 7 - <<= Operator, Value of c = : " <<c<< endl ;
c >>= 2;
//cout << "Line 8 - >>= Operator, Value of c = : " <<c<< endl ;
c &= 2;
//cout << "Line 9 - &= Operator, Value of c = : " <<c<< endl ;
c ^= 2;
//cout << "Line 10 - ^= Operator, Value of c = : " <<c<< endl ;
c |= 2;
//cout << "Line 11 - |= Operator, Value of c = : " <<c<< endl ;
return 0;
}
int main() {
int a = 4;
double c;
int* ptr;
/* example of sizeof operator */
/* example of & and * operators */
ptr = &a; /* 'ptr' now contains the address of 'a'*/
printf("value of a is %d\n", a);
printf("*ptr is %d.\n", *ptr);
/* example of ternary operator */
a = 10;
// b = (a == 1) ? 20: 30;
printf( "Value of b is %d\n", b );
// b = (a == 10) ? 20: 30;
printf( "Value of b is %d\n", b );
}
int main() {
int a = 21;
int b = 10;
int c ;
c = a + b;
printf("Line 1 - Value of c is %d\n", c );
c = a - b;
printf("Line 2 - Value of c is %d\n", c );
c = a * b;
printf("Line 3 - Value of c is %d\n", c );
c = a / b;
printf("Line 4 - Value of c is %d\n", c );
c = a % b;
printf("Line 5 - Value of c is %d\n", c );
c = a++;
printf("Line 6 - Value of c is %d\n", c );
c = a--;
printf("Line 7 - Value of c is %d\n", c );
}
%>
<div>
</body>
</html>