-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpret.c
712 lines (495 loc) · 12 KB
/
interpret.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<%
//string kds = 1 + 2;
//float kdx = 2 + 2.5;
// int num=212, tc;
// int respuesta, respuesta2;
// for (tc = 0; tc <= 2; ++tc){
// respuesta = num >> tc ;
// respuesta2 = num << tc;
// }
// int jc = 12, kc = 25;
// int lc = jc & kc;
// int llc = 12, mc = 25;
// int nc = llc | mc;
// int oc = 12, pc = 25;
// int qc = oc^pc;
// int rc = ~35;
// int sc = ~(-12);
// char ll = "hola";
// int negativo = -1;
// int a = 20;
// char b = 'h';
// bool c = true;
// bool d;
// float normalizationFactor = 22.442e2;
// int uno = 0xF;
// int dos = 00001111;
// string hola = "hola mundo";
// date fecha = #14-04-1991#;
// int e, f=12, g = true, h;
// int i = 1 + 2;
// string j = "hola " + "mundo";
// string k = 'j'+'i';
// bool l = 0+1;
// int m = 6*5;
// int o = 10/5;
// float p = 20.5-6.5;
// int q = 10-6.5;
// bool r = p > q;
// bool s = p < q;
// int u ;
// bool ra ;
// if (ra){
// int t = 75;
// u = t;
// }
// else{
// u = 32;
// }
// u++;
// int v;
// /* for loop execution */
// for( v = 10; v < 20; v = v + 1 ){
// u++;
// }
// for( v = 10; v < 20; v = v + 1 ){
// u--;
// }
// int w = 0;
// while (w < 5){
// u += 10;
// w++;
// }
// int x = 10;
// int y;
// /* do loop execution */
// do {
// x = x + 1;
// y++;
// }while( x < 20 );
// const int aa = 20;
// int ab = aa;
// const char ac= 'j';
// char ad = ac;
// bool af = false;
// bool ag = !af;
// int ij, jk;
// int ae;
// string er;
// while (ij <= 5)
// {
// jk=1;
// while (jk <= ij )
// {
// jk++;
// er = er + "x";
// }
// ij++;
// }
// int i2=1,j2;
// do
// {
// j2=1;
// do
// {
// // printf("*");
// j2++;
// }while(j2 <= i2);
// i2++;
// // printf("\n");
// }while(i2 <= 5);
// int i3,j3,n = 20;
// bool tr = true;
// for(i3 = 7;i3 <= n;i3 ++)
// {
// for(j3=3;j3<=10;j3++)
// {
// if(tr)
// {
// er = er + "jim-bob-rob";
// break;
// }
// }
// tr = false;
// }
// int ic = 5, cc, dc, ec, fc,gc,hc;
// cc = ic;
// dc = cc;
// cc += ic; // c = c+a
// ec= cc;
// cc -= ic; // c = c-a
// fc = cc;
// cc *= ic; // c = c*a
// gc =cc;
// cc /= ic; // c = c/a
// hc=cc;
// cc %= ic; // c = c%
// int dos = 6 , tres = 6;
// string cuatro;
// if (!(dos == tres)){
// cuatro = "si funciona Rafa";
// }
// int num=212, i;
// int respuesta = 0, respuesta2 =0;
// for (i=0; i < 3; i++){
// respuesta = num >> i;
// respuesta2 = num << i;
// }
// int num2 = 10, count, sum = 0;
// // for loop terminates when n is less than count
// for(count = 1; count <= num2; ++count)
// {
// sum += count;
// }
// /* local variable definition */
// int a = 10, cont = 0 ;
// /* while loop execution */
// while( a < 20 ) {
// //cont++;
// a++;
// if( a > 15) {
// /* terminate the loop using break statement */
// cont++;
// break;
// }
// }
// /* local variable definition */
// int aas = 10;
// /* do loop execution */
// do {
// if( aas == 15) {
// /* skip the iteration */
// aas = aas + 1;
// continue;
// }
// //printf("value of a: %d\n", a);
// aas++;
// } while( aas < 20 );
// char operator = 'a';
// int firstNumber = 10,secondNumber = 23;
// int result;
// switch(operator)
// {
// case '+':
// result = firstNumber+secondNumber;
// break;
// case '-':
// result = firstNumber-secondNumber;
// break;
// case '*':
// result = firstNumber*secondNumber;
// break;
// case '/':
// result = firstNumber/secondNumber;
// break;
// default:
// result = 18061993;
// }
//char cha,nplname[10], *ch , *plname[20] ;
//int mark[5] = {19, 10, 8, 17, 9};
// int x = mark[0];
// int mark2[3][2] = {19, 10, 8, 17, 9, 12};
// mark2[0][1] = 12;
// int c[2][3] = {1, 3, 0, -1, 5, 9};
// int dos = c[0][1];
// int c[3][4] = {0, 1, 2, 3, /* initializers for row indexed by 0 */
// 4, 5, 6, 7 , /* initializers for row indexed by 1 */
// 8, 9, 10, 11 /* initializers for row indexed by 2 */
// };
// int mark[5] = {19, 10, 8, 17, 9};
// mark[0] = 12;
// int x = -9 * 4;
// int suma (int a, int b){
// return a+b;
// }
// int e = 3;
// int d = 4;
// int res = suma(e,d);
// int displayNumbers(int num[])
// {
// // Instead of the above line,
// // void displayNumbers(int num[][2]) is also valid
// int i, j;
// // printf("Displaying:\n");
// return num[0];
// }
// int sdf;
// sdf = displayNumbers(mark);
// int max(int num1, int num2) {
// /* local variable declaration */
// int result;
// if (num1 > num2)
// result = num1;
// else
// result = num2;
// return result;
// }
// int maxre = max(10,20);
// /* function definition to swap the values */
// void swap(int *x, int *y) {
// int temp;
// temp = *x; /* save the value at address x */
// *x = *y; /* put y into x */
// // *y = temp; /* put temp into y */
// // return;
// }
// int sp1 = 100;
// int sp2 = 200;
// // swap(&a, &b);
// /* function definition to swap the values */
// void swap2(int x, int y) {
// int temp;
// temp = x; /* save the value of x */
// x = y; /* put y into x */
// y = temp; /* put temp into y */
// return;
// }
// int increment(int var)
// {
// var = var+1;
// return var;
// }
// int num1=20;
// int num2 = increment(num1);
// //swap2(sp1,sp2);
// void swapnum ( int var1, int var2 )
// {
// int tempnum ;
// /*Copying var1 value into temporary variable */
// tempnum = var1 ;
// /* Copying var2 value into var1*/
// var1 = var2 ;
// /*Copying temporary variable value into var2 */
// var2 = tempnum ;
// }
// swapnum(sp1,sp2);
// int var = 5;
// int varp = &var;
// int* pc;
// int c;
// c=22;
// //int uno = &c; // Address of c: 2686784
// int dos = c; // Value of c: 22
// pc = &c;
// //int tres = pc; // Address of c: 2686784
// int cuatro = *pc; // Value of c: 22
// c=11;
// // int cinco = pc; // Address of pointer pc: 2686784
// int seis = *pc; // Content of pointer pc: 11
// *pc=2;
// // int siete = &c; // Address of c: 2686784
// int ocho = c; // Value of c: 2
// int increment2(int *var)
// {
// *var = *var+1;
// return *var;
// }
// int num1=20;
// int num2 = increment2(&num1);
// void swapnum ( int *var1, int *var2 )
// {
// int tempnum ;
// tempnum = *var1 ;
// *var1 = *var2 ;
// *var2 = tempnum ;
// }
// void swap(int * n1, int * n2)
// {
// // pointer n1 and n2 points to the address of num1 and num2 respectively
// int temp;
// temp = *n1;
// *n1 = *n2;
// *n2 = temp;
// }
// int num3 = 35, num4 = 45 ;
// swap ( &num3, &num4 );
// void call_by_reference(int *y) {
// *y += 10;
// }
// int b=10;
// call_by_reference(&b);
// int mark2[3][2] = {19, 10, 8, 17, 9, 12};
// int az = mark2[0][1];
// mark2[0][1] = 1993;
// int mark1[6] = {19, 10, 8, 17, 9, 12};
// mark1[1] = 1993;
// int mark1pos = mark1[2];
// struct StudentData{
// string *stu_name;
// int stu_id;
// int stu_age;
// };
// struct StudentData student;
// student.stu_name = "Chaitanya";
// // student.stu_id = 1234;
// // student.stu_age = 25;
// // string nombreantes = student.stu_name;
// // student.stu_name = "Jimmy";
// // string nombre = student.stu_name;
// enum Security_Levels
// {
// black_ops,
// top_secret,
// secret,
// non_secret
// } my_security_level, dos, tres; // don't forget the semi-colon ;
// my_security_level = top_secret;
// string sec_level;
// if ( my_security_level == black_ops )
// {
// sec_level = "black_ops";
// }
// else if ( my_security_level == top_secret )
// {
// sec_level = "top_secret";
// }
// else if ( my_security_level == secret )
// {
// sec_level = "secret";
// }
// else if ( my_security_level == non_secret )
// {
// sec_level = "non_secret";
// }
// my_security_level = secret;
// int a;
// int b = 0;
// /* for loop execution */
// for( a = 10; a < 20; a = a + 1 ){
// // printf("value of a: %d\n", a);
// b ++;
// }
// int count;
// int c;
// for (count=10; count > 0; count--) {
// // runs all of the code between the { and }
// // 10 times, starting at 10 and working down to 1.
// c++;
// }
// int suma(int num1, int num2){
// return num1 + num2;
// }
// int resta(int num1, int num2){
// return num1 - num2;
// }
// int multiplicacion(int num1, int num2){
// return num1 * num2;
// }
// int division(int num1, int num2){
// return num1 / num2;
// }
// int operar(int num1, int num2, string operation){
// int result;
// if (operation == "Addition"){
// result = suma(num1,num2);
// }
// else if (operation == "Substraction"){
// result = resta(num1,num2);
// }
// else if (operation == "Multiplication"){
// result = multiplicacion(num1,num2);
// }
// else if (operation == "Division"){
// result = division(num1,num2);
// }
// return result;
// }
// int array[10] = { 21,56,23,12,87,9,54,32,32,98} ;
// int n = 10, c, d, swap;
// int array[10] = {21,56,23,12,87,9,54,32,32,98};
// int c,i,j;
// for( i=0; i<10;i++)
// {
// for( j=0;j<10-1;j++)
// {
// if(array[j]<array[j+1])
// {
// int temp=array[j];
// array[j]=array[j+1];
// array[j+1]=temp;
// }
// }
// }
// for (c = 0 ; c < ( n - 1 ); c++)
// {
// for (d = 0 ; d < n - c - 1; d++)
// {
// if (array[d] > array[d+1]) /* For decreasing order use < */
// {
// swap = array[d];
// array[d] = array[d+1];
// array[d+1] = swap;
// }
// }
// }
// int asd = array[1];
// int factorial(int i) {
// if(i <= 1) {
// return 1;
// }
// return i * factorial(i - 1);
// }
// int fibonacci(int i) {
// if(i == 0) {
// return 0;
// }
// if(i == 1) {
// return 1;
// }
// return fibonacci(i-1) + fibonacci(i-2);
// }
// int i = factorial(2);
// int operar(int num1, int num2, string operation){
// int result;
// if (operation == "Addition"){
// result = num1 + num2;
// }
// else if (operation == "Substraction"){
// result = num1 - num2;
// }
// else if (operation == "Multiplication"){
// result = num1 * num2;
// }
// else if (operation == "Division"){
// result = num1 / num2;
// }
// return result;
// }
int c = 22;
int* pc ;
int uno = &c; // Address of c: 2686784
int p1 = c; // Value of c: 22
pc = &c;
//int tres = pc; // Address of c: 2686784
int p2 = *pc; // Value of c: 22
c=11;
// int cinco = pc; // Address of pointer pc: 2686784
int p3 = *pc; // Content of pointer pc: 11
*pc=2;
// int siete = &c; // Address of c: 2686784
int p4 = c; // Value of c: 2
int a[10] = {1, 2, 0, 0, 4, 5, 6, 9, 9, 17};
int sum_array(int a[])
{
int i, sum=0;
for (i=0; i<10; i++)
{
sum = sum + a[i];
}
return sum;
}
int sum;
sum = sum_array(a);
%>
<div>
</body>
</html>