CSE 240 Midterm Study ASU Gonzales

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following lines represent in LISP the operation of 3 multiplied by 4? (3*4) 3*4 (* 3 4) (multiply 3 4)

(* 3 4)

What is a datatype? A classification that specifies which type of value a variable has and what type of Mathematical, relational or logical operations can be applied to it. An name given to a storage location. A fixed value that a program may not alter during its execution. A name given to a storage location that stores it's address.

A classification that specifies which type of value a variable has and what type of Mathematical, relational or logical operations can be applied to it.

What is a constant? A classification that specifies which type of value a variable has and what type of Mathematical, relational or logical operations can be applied to it. An name given to a storage location. A fixed value that a program may not alter during its execution. A name given to a storage location that stores it's address.

A fixed value that a program may not alter during its execution.

What is a pointer? A classification that specifies which type of value a variable has and what type of Mathematical, relational or logical operations can be applied to it. An name given to a storage location. A fixed value that a program may not alter during its execution. A name given to a storage location that stores it's address.

A name given to a storage location that stores it's address.

Match the line with the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line A. int $ = 1; // in C/C++ B. char @ = 'A'; // in C/C++ C. if = 5; // in C/C++ D. int If = (1<2 <3); // in C/C++ E. int If = (1<2 <3); // in Java F. int x = 0/1; // Java

A. Correct B. Lexical C. Syntactical D. Correct E. Semantic F. Correct

Which of the following methods receive as a parameters an array of integers and the size of the array, and return the sum of all elements in the array? int getAverage(int arr[], int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + arr[i]; } return sum; } int getAverage(int *arr, int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + *(arr+i); } return sum; } int getAverage(int *arr, int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + arr[i]; } return sum; } int getAverage(int arr[], int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + *(arr+i); } return sum; }

All are correct

The principle behind the object-oriented paradigm consists of a number of programming concepts, which does not include the following: Pointers Classes Polymorphism Pointers Inheritance

Pointers , Arrays

Prolog is based on Turing machine Lambda calculus Boolean logic Predicate logic

Predicate logic

What kind of error is in the following line:- int a = ((2*45)*(6/2) hello (4+90)); Lexical Error Semantic Error Correct! Syntactic Error None of the above

What kind of error is in the following line:- int a = ((2*45)*(6/2) hello (4+90)); Lexical Error Semantic Error Syntactic Error None of the above

What is a data type? a specialized format for organizing and storing data a storage location paired with an associated symbolic name a piece of information a set of primary values and the operations defined on these values

a set of primary values and the operations defined on these values

Lexical rules of Java and C/C++ languages include which of the following validations type matching division by zero a variable name should start with a letter, '$' or '_' parameters type in a function declaration should match these in the function call. unicity statement should end with a ';'

a variable name should start with a letter, '$' or '_'

%c

character

Which of the following classes creates and initializes correctly an static variable in C++? class Something { public: static int v; }; Something::v = 1; class Something { public: static int v; }; int v = 1; class Something { public: static int v; }; int Something::v = 1; class Something { public: static int v; }; v = 1;

class Something { public: static int v; }; int Something::v = 1;

The syntactic structure of imperative programming languages normally include which of the following units: operators keywords identifiers conditional statements loop statements variable declaration

conditional statements loop statements variable declaration

functions are created by calling a function-making macro. This macro is called function progn let defun

defun

In the code below: #include<iostream> using namespace std; class MyClass { public: MyClass() {cout << "MyClass constructed\n";} ~MyClass() {cout << "MyClass destroyed\n";} }; int main(){ MyClass * pt = new MyClass[3]; return 0; } a delete instruction is needed before the main() ends. Which of the following options is correct? for (int i =0; i<3; i++) { delete pt[i]; } delete [ ] pt; delete pt; delete * pt;

delete [ ] pt;

Given the following facts. instructor(john,cse300). instructor(mary,cse400). instructor(paul,cse500). enrolled(joseph,cse300). enrolled(joseph,cse400). enrolled(joseph,cse500). enrolled(james,cse300). enrolled(james,cse500). Which query provides a list of all the students enrolled in cse300? X is enrolled cse300. enrolled(cse300, Who). enrolled(cse300). enrolled(Who, cse300).

enrolled(Who, cse300).

Features of the logic paradigm includes expressing computation in terms of logic predicates classes and objects using lambda calculus expressing computation in terms of boolean expressions

expressing computation in terms of logic predicates

In C++, implementations of member functions cannot be inside the class definition (for short functions) or outside of the class definition.

false

The Java programming language is weakly typed True False

false

What is the predicate logic expression equivalent to "Charlie owns a computer"? computer_owned_by(charlie). charlie_owns(computer). owns(charlie, computer). computer (owned, charlie).

owns(charlie, computer).

%s

string

Given the following struct: struct contact { char name[32]; int phone; char email[32]; }; Which code can be used to create a contact and store data ? struct contact x; scanf("%s", x.name); scanf("%d", &x.phone); scanf("%s", x.email); struct contact x; scanf("%s", x.name); scanf("%d", x.phone); scanf("%s", x.email); struct contact x; scanf("%s", &x.name); scanf("%d", x.phone); scanf("%s", &x.email); struct contact x; scanf("%s", &x.name); scanf("%d", &x.phone); scanf("%s", &x.email);

struct contact x; scanf("%s", x.name); scanf("%d", &x.phone); scanf("%s", x.email);

Which of the following rules defines " if X is instructor of the course C and Y is enrolled in the course C then X teaches Y" instructor(P,C), enrolled(S,C) :-teaches(P,S). teaches(P,S) :- instructor(P,C); enrolled(S,C). instructor(P,C); enrolled(S,C) :-teaches(P,S). teaches(P,S) :- instructor(P,C), enrolled(S,C).

teaches(P,S) :- instructor(P,C), enrolled(S,C).

The following code is correct and print "Hello" if ( 2 + 2 + 2 + 2) if (1) printf("Hello");

true

The semantic structure of imperative programming languages normally include which of the following validations: type matching division by zero a variable name should start with a letter, '$' or '_' parameters type in a function declaration should match these in the function call. statement should end with a ';' unicity

type matching parameters type in a function declaration should match these in the function call. unicity

It is used to define an alternative name for an existing type: define struct typedef enum

typedef

The semantic structure of imperative programming languages normally include which of the following validations statement should end with a ';' division by zero unicity a variable name should start with a letter, '$' or '_' type matching parameters type in a function declaration should match these in the function call.

unicity, type matching, parameters type....

The following declaration allows all elements in the standard C++ library to be accessed in an unqualified manner (without the std:: prefix) using namespace std; #include <iostream.h> using namespace iostream; #include <iostream>

using namespace std;

During compilation, all the statements of a program in a high-level language are converted (translated) to a low-level language (such as assembly language). True or False

True

Interpretation of a program is the direct execution of one statement at a time sequentially. True or False?

True

Is the following line correct in LISP ( + 1 2 3 4 5 6 7 8 9 0)

True

char, unsigned char, signed char and int are all numeric (integer) types in C programming.

True

Considering the following code struct emp { int id; char *name; }; struct emp john; Which of the following lines are correct? int a = 1; char b[ ] = "John Doe"; emp.id = a; emp.name = b; printf ("%d, %s", emp.id, emp.name); int a = 1; char b[ ] = "John Doe"; john.id = b; john.name = a; printf ("%d, %s", john.id, john.name); int a = 1; char b[ ] = "John Doe"; john.id = a; john.name = b; printf ("%d, %s", john.id, john.name); int a = 1; char b[ ] = "John Doe"; john[0].id = a; john[0].name = b; printf ("%d, %s", john[0].id, john[0].name);

int a = 1; char b[ ] = "John Doe"; john.id = a; john.name = b; printf ("%d, %s", john.id, john.name);

Which of the following lines print a "-15" on the screen int x = -15; printf("%p", &x); int x = -15; int *point = &x; printf("%d", *point); int x = -15; int *point = &x; printf("%p", point); int x = -15; int *point = &x; printf("%d", &x);

int x = -15; int *point = &x; printf("%d", *point);

Which code in C is equivalent to this code in Java int x = 5; float y = 10.3f; System.out.println("hello " + x + " bye " + y); int *x = 5; float *y = 10.3; printf("hello %p bye %p", x, y); int x = 5; float y = 10.3; printf("hello %d bye %f", x, y); int x = 5; float y = 10.3; printf("hello %d bye %f", &x, &y); int x = 5; float y = 10.3f; printf("hello %i bye %f", x, y);

int x = 5; float y = 10.3; printf("hello %d bye %f", x, y);

Which lines in C++ are equivalent to this code in Java int x = 5; char a = 'A'; System.out.print( "Hello " + x + ", " + a ); int x =5; char a = 'A'; cout << "Hello %d , %c" << x << a ; int x =5; char a = 'A'; cout >> "Hello " >> x >> ", " >> a ; Correct! int x =5; char a = 'A'; cout << "Hello " << x << ", " << a ; int x =5; char a = 'A'; cout ("Hello %d , %c", x , a );

int x =5; char a = 'A'; cout << "Hello " << x << ", " << a ;

Write this statement as a Prolog clause. If weather is cold, everyone likes it. likes(weather, everyone):-cold(weather). cold(weather), likes(X). likes(X, weather) :- cold(weather). weather(cold) :-everyone(likes).

likes(X, weather) :- cold(weather).

Which of the following are NOT primitive data types in C? double long bool short String char int float

long bool short String

Which rule defines in Prolog the following sentence: "If someone owns something, he loves it" owns(Who, What), loves(Who, What). loves(Who, What); owns(Who, What). loves(Who, What):-owns(Who, What). loves(Who, What). owns(Who, What). owns(Who, What):-loves(Who, What).

loves(Who, What):-owns(Who, What).

%p

memory address

Given the following struct: struct contact { char name[32]; int phone; char email[32]; }; Which code can be used to create a contact and store data ? A. struct contact x; scanf("%s", &x.name); scanf("%d", x.phone); scanf("%s", &x.email); B. struct contact x; scanf("%s", x.name); scanf("%d", x.phone); scanf("%s", x.email); C. struct contact x; scanf("%s", &x.name); scanf("%d", &x.phone); scanf("%s", &x.email); D. struct contact x; scanf("%s", x.name); scanf("%d", &x.phone); scanf("%s", x.email);

D.

Which of the following lines (in Java, C, or C++) is equivalent to this expression in LISP A. (- (* 1 2) (+ 3 4) (/ 5 6) 7 ) B. 1 - 2 * 3 - 4 / 5 - 6 - 7 C. ( 1- 2) + (3 * 4) / ( 5* 6) - 7 D. (1 * 2) - (3 + 4) - (5 / 6) - 7 E. (1 - 2) * (3 - 4) * (5 - 6) / 7

D. (1 * 2) - (3 + 4) - (5 / 6) - 7

What are 3 features of imperative languages?

Divides program into functions and procedures Local and Global Variables Data Structures Conditional Statements

The compiler execute the program. True or False

False

The scope resolution operator (::) is used to overload a function or an operator in object-oriented paradigm.

False

%f

Floating point

What is printed on screen after running this program #include <stdio.h> int main() { int i=0; char a[ ] = "H2o2"; while(a[i] != '\0') { *(a+1)= *(a+i) + 2; i++; } char *q = a; q[2] = '#'; printf("%s", a); return 0; } H3#2 I3#3 I3p2 H4#2

H4#2

What is printed after running this program? #include<iostream> using namespace std; class GrandPa { public: virtual void foo() { cout<<"Hi, I am a GrandPa"<< endl; } }; class Dad : public GrandPa { public: void foo() { cout<<"Hi, I am a Dad"<< endl; } }; class Kid : public Dad { public: void foo() { cout<<"Hi, I am a Kid"<< endl; } }; int main(){ GrandPa * john = new Kid; john -> foo(); delete john; return 0; } Hi, I am a Kid Hi, I am a Dad Hi, I am a GrandPa

Hi, Im a kid

What are 3 characteristics of object oriented programming languages?

Inheritance Polymorphism public private protected Class vs instance variables

%d

Integer

This programming language uses two-step translation with intermediate codes for execution. C C++ Java C# LISP

Java

What are 3 characteristics of functional programming languages?

Lisp: Simpler mathematics closer to mathematical functions

Do these two different queries produce the same result in prolog? ?- N is -(+(1,2),3). ?- N is (1+2)-3. True False

True

What is the output of the below code? #include <stdio.h> int fun (int n) { if (n == 4) return n; else return 2*fun(n+1); } int main() { printf("%d", fun(3)); return 0; }

8

Running the following program, How many times the message "constructing" is printed on the screen? #include<iostream> using namespace std; class Rectangle { public: Rectangle(){ cout <<"constructing"<<endl; } ~Rectangle(){ cout <<"destructing"<<endl; } }; class Box : public Rectangle { public: Box(){ cout <<"constructing"<<endl; } ~Box(){ cout <<"destructing"<<endl; } }; int main(){ Box * a = new Box[5]; delete[] a; return 0; }

10

What is printed on screen when you run the following program? Be careful, do not add extra characters, not even spaces, unless they are part of your answer. #include<iostream> using namespace std; void recursive(int x) { if (x<5) { cout << x; recursive(x+1); cout << "B"; } else { cout << "A"; } } int main(){ recursive(1); }

1234ABBBB

What is printed on the screen after executing the lines below (in your personal computer)? int x[4] = {1, 2, 3, 0}; printf("%d",sizeof x) ;

16

Which of the following options is the code in C++ for a) A class Student that inherits from a class Person. b) A constructor in Student that calls (is able to call) a constructor in Person When the body of the method is not relevant to answer the question, it has been replaced for a comment // code Correct! class Person { public: Person() { //code } Person(char* lName, int year) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* lName, int year, char* univer) :Person(lName, year) { //code } private: char *university; }; class Person { public: Person() { //code } Person(char* lName, int year) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* lName, int year, char* univer) { Person(lName, year); //code } private: char *university; }; class Person { public: Person() { //code } Person(char* lName, int year) : Student (char* lName, int year, char* univer) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* lName, int year, char* univer) { //code } private: char *university; }; class Person { public: Person() { //code } Person(char* lName, int year) { // code } private: char* lastName; int yearOfBirth; }; class Student extends Person { public: Student() { //code } Student(char* lName, int year, char* univer) { Person(lName, year); //code } private: char *university; };

1st one

In the following code, how many times the destructor of the class "Derived" is executed? #include<iostream> using namespace std; class Base { public: Base(int n){ cout <<"Base constructor"<<endl; } ~Base(){ cout <<"Base destructor"<<endl; } void function(){ cout << "function" << endl; } }; class Derived : public Base { public: Derived(int n) : Base (n){ cout <<"Derived constructor"<<endl; } ~Derived(){ cout <<"Derived destructor"<<endl; } }; int main(){ Derived myPQ1(50); myPQ1.function(); myPQ1.function(); Derived *myPQ2 = new Derived(50); myPQ2 -> function(); myPQ2 -> function(); delete myPQ2; return 0; }

2

In the following code, how many times the destructor of the class "Base" is executed? #include<iostream> using namespace std; class Base { public: Base(int n) { cout<<"Base Constructor\n"; } void function() { cout<<"function\n"; } ~Base() { cout<<"Base destructor\n"; } }; class Derived : public Base { public: Derived(int n) : Base(n) { cout<<"Derived Constructor\n"; } ~Derived() { cout<<"Derived destructor\n"; } }; int main(){ Derived myPQ1(50); myPQ1.function(); Derived *myPQ2 = new Derived(50); myPQ2->function(); delete myPQ2; return 0; }

2

Running the following program. How many times will the message "good bye!" be printed on the screen? #include<iostream> using namespace std; class CSE { public: CSE(int v) { cout<<"constructor\n"; } void add(int v) { cout<<"adding\n"; } int remove(){ cout<<"removing\n"; return 0; } ~CSE() { cout<<"good bye!\n"; } }; int main(){ CSE q1(5); CSE *q2 = new CSE(5); q1.add(2); q1.add(8); q1.remove(); q2->remove(); delete q2; return 0; }

2

What is the output of the following program? #include <stdio.h> typedef enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun} WEEK; int main() { WEEK day; day = Wed; printf("%d",day); return 0; }

2

What is printed on screen after running this code? int main () { int Employees[3][3] = {{10,20,30},{1,2,3},{15,25,35} }; cout << Employees[2][1] - Employees[1][2] ; return 0; }

22

What is printed by the print instruction in the second line? (setf theList '(2 3 7 9 10) ) (print (first ( rest theList ) ) ) (3) 3 7 (2) 2

3

What does the below program print on the screen? #include <stdio.h> int main() { int i=3, *j, k; j=&i; printf("%d\n",i* *j *i - *j); return 0; }

3*3*3-3 = 24

What is printed on screen after running this program? Be careful, do not add extra characters, not even spaces, unless they are part of your answer. #include<stdio.h> void main () { int i = 0; char a[] = "2020"; while (a[i] != '\0') { *(a + i) = *(a + i) + 1; i++; } char *q = a; q[2]='B'; printf("%s\n", a); }

31B1

What is the value in the variable Exam::total that is printed when this program is executed? #include<iostream> using namespace std; class Exam { public: static int total; Exam() { total++; } }; int Exam::total = 0; int main(){ Exam a, b, c; Exam *d, *e, *f = new Exam; cout << Exam::total; }

4

What is printed by the following code? int main () { int array[5] = {10,30,50,70,90}; int *p = array; cout << *(p+1) + *(&*p) + 1; return 0; }

41

Given the following fact and rule. (some extra white-spaces has been added to facilitate reading) fun(1, 2). fun(N, F) :- N>0, N1 is N - 1, fun(N1, F1), F is N * F1. What is the value of the variable X after running the following query? ?- fun (4,X).

48

What is the value returned for the following LISP expression (+ 1 (if (< 2 1) (* 3 3) 6 ) )

7

What is the last value printed on the screen after running the following LISP code? (setf num 1) (dotimes (x 3) (setf num (+ num num) ) ) (print num)

8

Which of the following programs are correct in C ? (select all that apply) typedef enum { red, amber, green} traffic_light; main( ) { traffic_light x = red; while (1) switch (x) { case amber: x = red; printf("R"); break; case red: x = green; printf("G"); break; case green: x = amber; printf("A"); break; } } typedef int booOoolean; typedef char FlagType; int main() { booOoolean x = 0; int counter; FlagType xx = 'A'; // comment } typedef enum {false, true} booOoolean; typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days; int main() { booOoolean a = false; int counter; days x = Mon, y = Fri; while (x != y) x++; }

All are correct

Which of the followings are correct declarations of the main() method (i.e., the entry point of a program)? Correct! int main() { return 0; } void main (int argc, char *argv [ ]) { } void main () { } int main (int argc, char *argv [ ]) { return 0; } public static void main (string [ ] argv ) { } main() { return 0; }

All will run except: public static void main (string [ ] argv ) { }

What is a variable? A classification that specifies which type of value a variable has and what type of Mathematical, relational or logical operations can be applied to it. An name given to a storage location. A fixed value that a program may not alter during its execution. A name given to a storage location that stores it's address.

An name given to a storage location.

What is equivalent code in C++ for the following LISP statement (if (< 1 2) (* 3 4) (/ 5 6) ) A. if (1 < 2) cout<< 3 * 4; else cout << 5 / 6; B. if (1 < 2) return 3 * 4; else return 5 / 6; C. if (1 < 2) { cout<< 3 * 4; return 5 / 6; } D. if (1 < 2) { cout<< 3 * 4; cout << 5 / 6; }

B

Given this class definition #include<iostream> using namespace std; class Rectangle { private: int width, height; public: void setValues(int a, int b); int area(); }; void Rectangle::setValues(int a, int b) { width=a; height=b; } int Rectangle::area() { return width*height; } Which of the following instruction(s) create an array of 3 Rectangles and initialize all the 3 of them with values. Select ALL the possible options - there are Negative Scores for Incorrect Answers. A. Rectangle *a = new Rectangle[3]; a[0]->setValues(1,1); a[1]->setValues(2,2); a[2]->setValues(3,3); B. Rectangle *a[3]; a[0] = new Rectangle; a[0]->setValues(1,1); a[1] = new Rectangle; a[1]->setValues(2,2); a[2] = new Rectangle; a[2]->setValues(3,3); C. Rectangle a = new Rectangle[3]; a[0].setValues(1,1); a[1].setValues(2,2); a[2].setValues(3,3); Correct! D. Rectangle a[3]; a[0].setValues(1,1); a[1].setValues(2,2); a[2].setValues(3,3); Correct Answer Rectangle *a = new Rectangle[3]; a[0].setValues(1,1); a[1].setValues(2,2); a[2].setValues(3,3);

B,C,D

In a C Program, which of the following is true: C allows one parameter or two parameters for main. C allows empty parameters or two parameters for main. C allows more than two parameters for main. C allows only one parameter for main.

C allows empty parameters or two parameters for main.

Given the following class definition: class Rectangle { private: int width, height; public: void set_values (int,int); int area (); }; Which of the following instruction(s) create an array of 2 Rectangles and initialize them (the 2 Rectangles) with values. Select ALL the possible options. Rectangle *a[2]; a[0] = new Rectangle; a[0]->set_values(1,1); a[1] = new Rectangle; a[1]->set_values(2,2); Rectangle a = new Rectangle[2]; a[0].set_values(1,1); a[1].set_values(2,2); Rectangle *a = new Rectangle[2]; a[0]->set_values(1,1); a[1]->set_values(2,2); Correct! Rectangle a[2]; a[0].set_values(1,1); a[1].set_values(2,2);

Rectangle *a[2]; a[0] = new Rectangle; a[0]->set_values(1,1); a[1] = new Rectangle; a[1]->set_values(2,2); Rectangle a[2]; a[0].set_values(1,1); a[1].set_values(2,2);

What are 3 characteristics of logical programming languages?

Set of fact, rules and questions no datatypes no conditions no loops get rid of programming

What is printed on the screen by the print instruction in the code below? (print ( and (< (* 3 5 ) ) ( not (>= 4 6 ) ) ) )

T

In C, when you pass an array as a parameter to a function, what is actually passed? All the values in array An array cannot be passed as a parameter to a function The address of the first element in the array The value of the first element in the array

The address of the first element in the array

15 is 10 + 5. How will Prolog respond to this query? True False

True

Compilation of a program is to execute all the statements of the program completely. True or False

True

Which of the following options is the code in C++ for A class Student that inherits from a class Person. A constructor in Student that calls (is able to call) a constructor in Person When the body of the method is not relevant to answer the question, it has been replaced for a comment // code class Person { public: Person() { //code } Person(char* lName, int year) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* n, int y, char* u):Person(n, y) { //code } private: char *university; }; class Person { public: Person() { //code } Person(char* n, int y) { // code } private: char* lastName; int yearOfBirth; }; class Student extends Person { public: Student() { //code } Student(char* n, int y, char* u) { Person(n, y); //code } private: char *university; }; class Person { public: Person() { //code } Person(char* n, int y) : Student (char* n, int y, char* u) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* n, int y, char* u) { //code } private: char *university; }; class Person { public: Person() { //code } Person(char* n, int y) { // code } private: char* lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char* n, int y, char* u) { Person(n, y); //code } private: char *university; };

first one is correct

Write in Prolog the statement "pizza is a food" pizza(food). pizza_food. is(pizza, food). food(pizza).

food(pizza).

#include <stdio.h> int main() { int a[5]={3,1,5,20,25}; int i, j, m; i= *(a+1) - 1; j= a[1] + 1; m= a[j] + a[i]; printf("%d,%d,%d",i ,j, m); return 0; }

i = 1-1 = 0 j = 1+1 = 2 m = 5 + 3 = 8

What is printed by the following code? #include <stdio.h> int i=10; int bar(int m, int *n) { printf("i=%d k=%d l=%d\n", i,m,*n); } int foo(int k, int *l) { printf("i=%d k=%d l=%d\n", i,k,*l); k = 3; *l = 4; bar(k, l); } int main() { int j = 15; foo(j, &i); printf("i=%d j=%d\n", i, j); return 0; } i = 10 k = 15 l = 10 i = 10 k = 3 l = 4 i = 10 j = 15 i = 10 k = 15 l = 10 i = 4 k = 3 l = 4 i = 4 j = 15 i = 10 k = 15 l = 10 i = 10 k = 3 l = 10 i = 10 j = 15 i = 4 k = 3 l = 4 i = 4 j = 15

i = 10 k = 15 l = 10 i = 4 k = 3 l = 4 i = 4 j = 15

What is printed by the following code? #include <stdio.h> int foo(int *n) { *n = 30; } int main() { int i=15; foo(&i); printf("i=%d\n",i); i=10; foo(&i); printf("i=%d\n",i); return 0; } i = 10 i = 10 i = 15 i = 15 i = 30 i = 30 i = 15 i = 10

i = 30 i = 30

The lexical structure of all programming languages are similar and normally include which of the following units identifiers loop statements keywords operators literals

identifiers keywords operators literals


Set pelajaran terkait

Professional Nursing Chapters 1-4

View Set

Chapter 19: PREPU Management of patients with upper respiratory disorders

View Set

Chapter 11 - Organizational Design

View Set