Διδάσκων: Παναγιώτης Ανδρέου

Σχετικά έγγραφα
ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Δομημένος Προγραμματισμός (ΤΛ1006)

The Simply Typed Lambda Calculus

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

2 Composition. Invertible Mappings

Διάλεξη 3: Προγραμματισμός σε JAVA I. Διδάσκων: Παναγιώτης Ανδρέου

C.S. 430 Assignment 6, Sample Solutions

Εισαγωγή στον Προγραµµατισµό. Διάλεξη 2 η : Βασικές Έννοιες της γλώσσας προγραµµατισµού C Χειµερινό Εξάµηνο 2011

derivation of the Laplacian from rectangular to spherical coordinates

Section 8.3 Trigonometric Equations

A ΜΕΡΟΣ. 1 program Puppy_Dog; 2 3 begin 4 end. 5 6 { Result of execution 7 8 (There is no output from this program ) 9 10 }

Homework 3 Solutions

Εισαγωγή στον Προγραμματισμό

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Προγραμματισμός Η/Υ (ΤΛ2007 )

Ανάπτυξη Μεγάλων Εφαρµογών στη Γλώσσα C (2)

Finite Field Problems: Solutions

Block Ciphers Modes. Ramki Thurimella

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

Math 6 SL Probability Distributions Practice Test Mark Scheme

Hancock. Ζωγραφάκης Ιωάννης Εξαρχάκος Νικόλαος. ΕΠΛ 428 Προγραμματισμός Συστημάτων

Κεφάλαιο 4: Συνθήκες Έλεγχου (if-else, switch) και Λογικοί τελεστές / παραστάσεις. (Διάλεξη 8)

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

Συστήματα Διαχείρισης Βάσεων Δεδομένων

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Galatia SIL Keyboard Information

Inverse trigonometric functions & General Solution of Trigonometric Equations

HY150a Φροντιστήριο 3 24/11/2017

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 11/3/2006

UNIVERSITY OF CALIFORNIA. EECS 150 Fall ) You are implementing an 4:1 Multiplexer that has the following specifications:

EE512: Error Control Coding

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ

Σε γενικές γραμμές, είναι καλή πρακτική να γράϕουμε προγράμματα C που αποτελούνται από πολλές και μικρές συναρτήσεις, παρά από λίγες και μεγάλες.

Διάλεξη 9η: Πίνακες (arrays)

Προγραμματισμός Η/Υ (ΤΛ2007 )

PARTIAL NOTES for 6.1 Trigonometric Identities

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Partial Trace and Partial Transpose

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

(C) 2010 Pearson Education, Inc. All rights reserved.

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Problem Set 3: Solutions

Other Test Constructions: Likelihood Ratio & Bayes Tests

Assalamu `alaikum wr. wb.

Προγραμματισμός Η/Υ (ΤΛ2007 )

ΕΡΓΑΣΤΗΡΙΟ 5 ΣΗΜΕΙΩΣΕΙΣ

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

Εισαγωγή στον Προγραμματισμό

Second Order RLC Filters

Η γλώσσα C. Δείκτες (pointers)

Αντικειμενοστρεφής Προγραμματισμός

Υπολογισμός - Εντολές Επανάληψης

Congruence Classes of Invertible Matrices of Order 3 over F 2

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Code Breaker. TEACHER s NOTES

Reminders: linear functions

Section 7.6 Double and Half Angle Formulas

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

ST5224: Advanced Statistical Theory II

Every set of first-order formulas is equivalent to an independent set

Matrices and Determinants

Γλώσσα Προγραμματισμού C++ Εισαγωγή - Μια πρώτη ματιά

ΤΕΧΝΟΛΟΓΙΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΝΟΣΗΛΕΥΤΙΚΗΣ

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

Instruction Execution Times

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

ΗΥ-150. Προγραµµατισµός. Πίνακες (Arrays)

Διδάσκων: Παναγιώτης Ανδρέου

Example Sheet 3 Solutions

ΕΠΛ232 Προγραμματιστικές Τεχνικές και Εργαλεία Δείκτες και Συναρτήσεις (Κεφάλαιο 11, KNK-2ED)

Πανεπιστήμιο Πελοποννήσου. Σχολή Θετικών Επιστημών & Τεχνολογίας. Τμήμα Επιστήμης & Τεχνολογίας Υπολογιστών. Προγραμματισμός Ι Εργαστήριο

Δομημένος Προγραμματισμός (ΤΛ1006)

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

Approximation of distance between locations on earth given by latitude and longitude

Math221: HW# 1 solutions

ΗΥ-150. Πίνακες (Arrays)

Διάλεξη 5: Δείκτες και Συναρτήσεις

Εργαστήριο 1: Επανάληψη Βασικών Εννοιών στη Γλώσσα C

SUPERPOSITION, MEASUREMENT, NORMALIZATION, EXPECTATION VALUES. Reading: QM course packet Ch 5 up to 5.6

Δομημένος Προγραμματισμός (ΤΛ1006)

Right Rear Door. Let's now finish the door hinge saga with the right rear door

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. ΕΠΛ342: Βάσεις Δεδομένων. Χειμερινό Εξάμηνο Φροντιστήριο 10 ΛΥΣΕΙΣ. Επερωτήσεις SQL

Homework 8 Model Solution Section

Η εντολή if-else. Η απλή μορφή της εντολής if είναι η ακόλουθη: if (συνθήκη) { Η γενική μορφή της εντολής ifelse. εντολή_1; εντολή_2;..

6.3 Forecasting ARMA processes

TMA4115 Matematikk 3

Transcript:

Διάλεξη 5: Φροντιστήριο για Συμβολοσειρές (Strings),Δείκτες (pointers) και ΠίνακεςΔεικτών Διδάσκων: Παναγιώτης Ανδρέου ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 1

Which one of the following variable names is NOT valid? go_cart go4it 4season run4 _what ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 2

Which one of the following is NOT a valid C identifier? S 1 1 S ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 3

Which one of the following is NOT a valid identifier? ident while bignumber g42277 peaceful_in_space ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 4

Which one of the following is true for identifiers that begin with an underscore? They are generally treated differently by preprocessors and compilers from other identifiers. They are case-insensitive. They are reserved for usage by standards committees, system implementers, and compiler engineers. Applications programmers are encouraged to employ them in their own code in order to mark certain symbols for internal usage. They are deprecated by Standard C and are permitted only for backward compatibility with older C libraries. ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 5

int x = 2 * 3 + 4 * 5; What value will x contain in the sample code above? 22 26 46 50 70 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 6

int i = 4; int x = 6; double z; z = x / i; printf("z=%.2f\n", z); What will print when the sample code above is executed? z=0.00 z=1.00 z=1.50 z=2.00 z=null ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 7

int z, x=5, y=-10, a=4, b=2; z = x++ - --y * b / a; What number will z in the sample code above contain? 5 6 10 11 12 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 8

When applied to a variable, what does the unary "&" operator yield? The variable's value The variable's binary form The variable's address The variable's format The variable's right value ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 9

In a C expression, how is a logical AND represented? @@.AND. &&.AND ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 10

Which one of the following will read a character from the keyboard and will store it in the variable c? c = getc(); getc( &c ); c = getchar( stdin); getchar( &c ) c = getchar(); ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 11

"My salary was increased by 15%!" Select the statement which will EXACTLY reproduce the line of text above. printf("\"my salary was increased by 15/%\!\"\n"); printf("my salary was increased by 15%!\n"); printf("my salary was increased by 15'%'!\n"); printf("\"my salary was increased by 15%%!\"\n"); printf("\"my salary was increased by 15'%'!\"\n"); ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 12

Which one of the following printf() format specifiersindicates to print a double value in decimal notation, left aligned in a 30-character field, to four (4) digits of precision? %-30.4e %4.30e %-4.30f %-30.4f %#30.4f ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 13

c = getchar(); What is the proper declaration for the variable c in the code above? char *c; unsigned intc; intc; unsigned char c; char c; ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 14

int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; What value does testarray[2][1][0] in the sample code above contain? 3 5 7 9 11 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 15

int i,j; int ctr = 0; int myarray[2][3]; for (i=0; i<3; i++) for (j=0; j<2; j++) { myarray[j][i] = ctr; ++ctr; } What is the value of myarray[1][2]; in the sample code above? 1 2 3 4 5 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 16

char* myfunc (char *ptr) { ptr += 3; return (ptr); } int main() { char *x, *y; x = "HELLO"; y = myfunc (x); printf ("y = %s \n", y); return 0; } What will print when the sample code above is executed? y = HELLO y = ELLO y = LLO y = LO x = O ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 17

char *ptr; char mystring[] = "abcdefg"; ptr = mystring; ptr += 5; What string does ptrpoint to in the sample code above? fg efg defg cdefg None of the above ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 18

int x = 3; if( x == 2 ); x = 0; if( x == 3 ) x++; else x += 2; What value will x contain when the sample code above is executed? 1 2 3 4 5 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 19

int x = 0; for (x=1; x<4; x++); printf("x=%d\n", x); What will be printed when the sample code above is executed? x=0 x=1 x=3 x=4 x=5 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 20

x = 3, counter = 0; while ((x-1)) { ++counter; x--; } Referring to the sample code above, what value will the variable counter have when completed? 0 1 2 3 4 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 21

int x[] = { 1, 4, 8, 5, 1, 4 }; int *ptr, y; ptr = x + 4; y = ptr - x; What does y in the sample code above equal? -3 0 4 4 + sizeof( int) 4 * sizeof( int) ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 22

void myfunc (int x) { if (x > 0) myfunc(--x); printf("%d, ", x); } int main() { myfunc(5); return 0; } What will the above sample code produce when executed? 0, 1, 2, 3, 4, 4, 4, 3, 2, 1, 0, 0, 5, 4, 3, 2, 1, 0, 0, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 23

int x = 5; int y = 2; char op = '*'; switch (op) { default : x += 1; case '+' : x += y; case '-' : x -= y; } After the sample code above has been executed, what value will the variable x contain? 4 5 6 7 8 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 24

#include <stdio.h> void func() { int x = 0; static int y = 0; x++; y++; printf( "%d -- %d\n", x, y ); } int main() { func(); func(); return 0; } What will the code above print when it is executed? 1 --1 1 --1 1 --1 2 --1 1 --1 2 --2 1 --0 1 --0 1 --1 1 --2 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 25

short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} }; printf( "%d\n", sizeof( testarray ) ); Assuming a short is two bytes long, what will be printed by the above code? It will not compile because not enough initializers are given. 6 7 12 24 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 26

int x = 0; for ( ; ; ) { if (x++ == 4) break; continue; } printf("x=%d\n", x); What will be printed when the sample code above is executed? x=0 x=1 x=4 x=5 x=6 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 27

#include <stdio.h> int i; void increment( int i ) { i++; } int main() { for( i = 0; i < 10; increment( i ) ) { } printf("i=%d\n", i); return 0; } What will happen when the program above is compiled and executed? It will not compile. It will print out: i=9. It will print out: i=10. It will print out: i=11. It will loop indefinitely. ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 28

int i = 4; switch (i) { default: ; case 3: i += 5; if ( i == 8) { i++; if (i == 9) break; i *= 2; } i -= 4; break; case 8: i += 5; break; } printf("i = %d\n", i); What will the output of the sample code above be? i= 5 i= 8 i= 9 i= 10 i= 18 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 29

int y[4] = {6, 7, 8, 9}; int *ptr = y + 2; printf("%d\n", ptr[ 1 ] ); What is printed when the sample code above is executed? 6 7 8 9 The code will not compile. ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 30

char txt [20] = "Hello world!\0"; How many bytes are allocated by the definition above? 11 bytes 12 bytes 13 bytes 20 bytes 21 bytes ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 31

long factorial (long x) {???? return x * factorial(x - 1); } With what do you replace the???? to make the function shown above return the correct answer? if (x == 0) return 0; return 1; if (x >= 2) return 2; if (x == 0) return 1; if (x == 1) return 1; ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 32

char * dwarves [] = { "Sleepy", "Dopey" "Doc", "Happy", "Grumpy" "Sneezy", "Bashful", }; How many elements does the array dwarves (declared above) contain? Assume the C compiler employed strictly complies with the requirements of Standard C. 4 5 6 7 8 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 33

char *buffer = "0123456789"; char *ptr = buffer; ptr += 5; printf( "%s\n", ptr ); printf( "%s\n", buffer ); What will be printed when the sample code above is executed? 0123456789 56789 5123456789 5123456789 56789 56789 0123456789 0123456789 56789 0123456789 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 34

int fibonacci (int n) { switch (n) { default: return (fibonacci(n - 1) + fibonacci(n - 2)); case 1: case 2: } return 1; } The function above has a flaw that may result in a serious error during some invocations. Which one of the following describes the deficiency illustrated above? For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes. An error in the algorithm causes unbounded recursion for all values of n. A break statement should be inserted after each case. Fall-through is not desirable here. The fibonacci() function includes calls to itself. This is not directly supported by Standard C due to its unreliability. Since the default case is given first, it will be executed before any case matching n. ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 35

int a [8] = { 0, 1, 2, 3 }; The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements? Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled. The remaining elements are initialized to zero(0). It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized. As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively. They are left in an uninitialized state; their values cannot be relied upon. ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 36

int x[] = {1, 2, 3, 4, 5}; int u; int *ptr = x;???? for( u = 0; u < 5; u++ ) { printf("%d-", x[u]); } printf( "\n" ); Which one of the following statements could replace the???? in the code above to cause the string 1-2-3-10-5-to be printed when the code is executed? *ptr+ 3 = 10; *ptr[ 3 ] = 10; *(ptr+ 3) = 10; (*ptr)[ 3 ] = 10; *(ptr[ 3 ]) = 10; ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 37

int a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d ", b, a++, a, ++a); What will be the output when following code is executed? 12,10,11,13 22,10,11,13 12,12,12,12 22,12,13,14 22,13,13,14 ΕΠΛ035 Δομές Δεδομένων και Αλγόριθμοι για Ηλ. Μηχ. Και Μηχ. Υπολ. 38