final
Write in LISP the operation of 3 multiplied by 4?
(* 3 4)
What is the output of this code? (setf a 0) (defun fun(n) (if (= n 0) (setf a (+ a n)) (progn (setf a (+ a n)) (fun (- n 1))) ) ) (fun 4) (print a)
10
What is printed by the following program? #include <stdio.h> void fun(int x) { if (x>0) { printf("%d", x); fun(x-1); printf("%d", x); } else { printf("@"); } } int main() { fun(5); }
54321@12345
What is the result of the following two lines? (setf the List '(2 3 7 9 10)) (first (rest (rest theList)))
7
What is the value returned for the following LISP expression (+ 1 (if (< 2 1) (* 3 3) 6 ) )
7
The principle behind the object-oriented paradigm consists of a number of programming concepts, which does not include the following: Classes, Inheritance, Polymorphism, Arrays, Pointers
Arrays and Pointers
In a C Program, which of the following is true:
C allows empty parameters or two parameters for main.
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line int $ = 1; // in C/C++
Correct
Is the following true or false with respect to inheritance? When a base class is privately inherited, a private member of base class becomes private member of derived class
False
#include <stdio.h> int main(){ int i= 0; char a[] = "H202"; while (a[i]!= '\0') { *(a+1) =*(a+i) +1; i++; } char *q; q = a; q[2] = '#'; printf("%s", a); return 0; }
H3#2
What is printed : #include <stdio.h> int i = 1; void foo(int m, int *n){ printf("i = %d m = %d n = %d\n", i,m,*(ask)n); i = 5; m = 3, *n=4; printf("i = %d m = %d n = %d\n", i,m,*(ask)n); } void main(){ int j = 2; foo(j, &i); printf("i = %d j = %d\n", i, j);
i = 1 m = 2 n = 1 i = 4 m = 3 n = 4 i = 4 j = 2
?- owner(jane, dog(X)) :- big(X),spots(X). What would be the English meaning for this Prolog statement
jane is the owner of some dog if that dog is big and has spots.
Match the following: 1) Data Type 2)Variable 3) Constant 4) Pointer A) Fixed value that the program may not alter during its execution. B) A classification that specifies which type of value a variable has and what type of mathematical, relational or logical operators. C) A name given to a storage location that stores an address. D) A name given to a storage location
1 - B 2 - D 3 - A 4 - C
Match the following elements. Which one is a fact? Which one is a rule? 1) human(socrates). 2) human(aristoteles). 3) mortal(X) :- human(X). 4) human(X) :- animal(X), mammal(X).
1) Fact 2) Fact 3) Rule 4) Rule
Given this 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 all the 3 of them with values. Select ALL the possible options. 1) Rectangle a[2]; a[0].set_values(1,1); a[1].set_values(2,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); 3) Rectangle *a = new Rectangle[2]; a[0]->set_values(1,1); a[1]->set_values(2,2); 4) Rectangle a = new Rectangle[2]; a[0].set_values(1,1); a[1].set_values(2,2);
1) Rectangle a[2]; a[0].set_values(1,1); a[1].set_values(2,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);
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 1) 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; }; 2) 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; }; 3) 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; }; 4) 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; };
1) 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; };
Which lines in C++ are equivalent to this code in Java int x =5; char a = 'A'; System.out.print( "Hello " + x + ", " + a ); 1) int x =5; char a = 'A'; cout << "Hello " << x << ", " << a 2) int x =5; char a = 'A'; cout << "Hello %d , %c" << x << a ; 3)int x =5; char a = 'A'; cout ("Hello %d , %c", x , a ); 4) int x =5; char a = 'A'; cout >> "Hello " >> x >> ", " >> a ;
1) int x =5; char a = 'A'; cout << "Hello " << x << ", " << a
What is the predicate logic expression equivalent to "Charlie owns a computer"? 1) owns(charlie, computer). 2) computer (owned, charlie). 3)computer_owned_by(charlie). 4) charlie_owns(computer).
1) owns(charlie, computer).
"What is printed on screen when you run the following program? #include <iostream> using namespace std; void recursive(int x){ if(x<10){ cout <<x<<"",""; recursive(x+1); cout<<x<<"",""; }else{ cout<<""A,"";}} int main(){ recursive(1);}"
1,2,3,4,5,6,7,8,9,A,9,8,7,6,5,4,3,2,1,
What is equivalent code in C++ for the following LISP statement 111
111
What is printed on the screen after executing the lines below? int x[3] = {1,2,3}; printf("%d",sizeof x) ;
12
What is the last value printed on the screen after running the following LISP code? (setf num 1) (dotimes (x 4) (setf num (+ num num))) (print num)
16
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"<< end1; } void function(){ cout<< "function"<< end1; } ~Base(){ cout<<"Base destructor"<<end1; } }; class Derived : public base{ public: Derived(int n) : Base(n){ cout<< "Derived constructor"<<end1; } ~Derived() { cout<< "Derived constructor"<<end1; } }; int main(){ Derived myPQ1(50); myPQ1.function(); myPQ1.function(); Derived *(ask)myPQ2; myPQ2 = new Derived(50); myPQ2->function(); myPQ2->function(); delete myPQ2; }
2
In the following code, how many times the destructor of the class "Derived" is executed? class Base { public: Base(int n) { cout << "Base constructor" << endl; } void function() { cout << "function" << endl; } ~Base() { count << "Base destructor" << 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; myPQ2 = new Derived(50); myPQ2->function(); myPQ2->function(); delete myPQ2; )
2
Running the following program. How many times will "good bye" be printed on the screen? 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); //Access Object q1.add(2); q1. add(8); //Access Object Pointer q1.remove(); q2->remove(); delete q2; return 0; }
2
Which of the following lines (in Java, C, or C++) is equivalent to this expression in LISP (- (* 1 2) (+ 3 4) (/ 5 6) 7 ) 1) (1 - 2) * (3 - 4) * (5 - 6) / 7 2) (1 * 2) - (3 + 4) - (5 / 6) - 7 3) ( 1- 2) + (3 * 4) / ( 5* 6) - 7 4) 1 - 2 * 3 - 4 / 5 - 6 - 7
2) (1 * 2) - (3 + 4) - (5 / 6) - 7
Which of the following classes creates and initializes correctly an static variable in C++? 1) class Something { public: static int v; }; v = 1; 2) class Something { public: static int v; }; int Something::v = 1; 3) class Something { public: static int v; }; Something::v = 1; 4) class Something { public: static int v; }; int v = 1;
2) class Something { public: static int v; }; int Something::v = 1;
What is printed by the following program? #include <iostream> using namespace std; int i = 5; class A { public: A() {i=10;} ~A() {i=20;} }; int foo() { i=30; A a; return 0; } int main() { foo(); cout<<i; return 0; }
20
What does the below program print on the screen? int main() { int i=3, *j, k; j=&i; printf("%d\n", i**j*i-*j); return 0; )
24
What is printed by the print instruction in the second line? (setf theList '(2 3 7 9 10) ) (print (first ( rest theList ) ) )
3
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; cout<<Exam::total;}
3
"What is printed on screen after running this program? #include <iostream> using namespace std; int main(){ int array[5] = {10, 20, 30, 40, 50}; int *(ask)p = array; cout << *(ask)(p+1) + *(ask)(&*(ask)p) +1;}"
31
"What is printed on screen after running this program? #include <iostream> using namespace std; int main(){ int Employees[3][3] = {{10,20,30},{15,25,35},(1,2,3}}; cout << Employees[1][2] - Employee[2][1]<<endl;}"
33
Which of the following lines print a "-15" on the screen 1) int x = -15; printf("%p", &x); 2) int x = -15; int *point = &x; printf("%d", &x); 3) int x = -15; int *point = &x; printf("%p", point); 4) int x = -15; int *point = &x; printf("%d", *point);
4
What is the output of the following code #include <stdio.h> void main() { char a[10][5] = {"hi", "hello", "fellows"}; printf("%d", sizeof(a[2])); }
5
what is printed by the following code? (defun fun(n) (if (= n 0) () (fun (- n 1)) ) n ) (print (fun 5))
5
Given the following facts cat(tom). black_spots(tom). dog(pluto). white_spots(pluto) Which rule defines in Prolog the following sentence: "If someone owns something, he loves it" 1) loves(Who, What); owns(Who, What). 2) owns(Who, What), loves(Who, What). 3) loves(Who, What). owns(Who, What). 4) owns(Who, What):-loves(Who, What). 5) loves(Who, What):-owns(Who, What).
5) loves(Who, What):-owns(Who, What).
Assume that a string is declared as char str[ ] = "heLLo"; What is the return value of sizeof(str) ?
6
How many times the message "constructing" is printed on the screen? #include <iostream> using namespace std; class Rectangle { public: Rectangle(){ cout<<"contructing"<<end1; } ~Retangle(){ cout<<"decontructing"<<end1; } }; class Box: public Retangle { public: Box(){ cout<<"constructing"<<end1; } ~Box(){ cout<<"destructing"<<end1; } }; int main(){ Box *(ask)a= new Box[3]; delete[]a; return 0; }
6
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
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
What is the value of the variable total printed by the following program? #include <iostream> using namespace std; int total = 0; class A { public: A() {total++;} ~A() {total++;} }; class B: public A { public: B() {total++;} ~B() {total++;} }; class C: public B { public: C() {total++;} ~C() {total++;} }; int main() { A a; B b; C *c(pointer) = new C; delete c; cout << total; return 0; }
9
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 A) class Person { public: Person() { //code } Person(char*(ask) lName, int year) { // code } private: char*(ask) lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char*(ask) lName, int year, char*(ask) univer) :Person(lName, year) { //code } private: char *(ask)university; }; ------------------------------------ B)class Person { public: Person() { //code } Person(char*(ask) lName, int year) { // code } private: char*(ask) lastName; int yearOfBirth; }; class Student extends Person { public: Student() { //code } Student(char*(ask) lName, int year, char*(ask) univer) { Person(lName, year); //code } private: char *(ask)university; }; --------------------------------- C) class Person { public: Person() { //code } Person(char*(ask) lName, int year) { // code } private: char*(ask) lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char*(ask) lName, int year, char*(ask) univer) { Person(lName, year); //code } private: char *(ask)university; }; ----------------------------- D)class Person { public: Person() { //code } Person(char*(ask) lName, int year) : Student (char*(ask) lName, int year, char*(ask) univer) { // code } private: char*(ask) lastName; int yearOfBirth; }; class Student : public Person { public: Student() { //code } Student(char*(ask) lName, int year, char*(ask) univer) { //code } private: char *(ask)university; };
A
Which rules in Prolog match the following definition of a bad dog: A dog is bad if it bites the postman, chews the newspaper, or chases the cat. A)bad_dog(Dog) :- is_dog(Dog), bites(Dog, Postman), is_postman(Postman). bad_dog(Dog) :- is_dog(Dog), chews(Dog, Newspaper), is_newspaper(Newspaper). bad_dog(Dog) :- is_dog(Dog), chases(Dog, Cat), is_cat(Cat). B) bad_dog(Dog) :- is_dog(Dog); bites(Postman). bad_dog(Dog) :- is_dog(Dog); chews(Newspaper). bad_dog(Dog) :- is_dog(Dog); chases(Cat). C)is_dog(Dog), bites(Dog, Postman), is_postman(Postman):-bad_dog(Dog). is_dog(Dog), chews(Dog, Newspaper), is_newspaper(Newspaper):-bad_dog(Dog). is_dog(Dog), chases(Dog, Cat), is_cat(Cat):-bad_dog(Dog). D)bad_dog(Dog) :- is_dog(Dog); bites(Postman); is_postman(Postman). bad_dog(Dog) :- is_dog(Dog); chews(Newspaper); is_newspaper(Newspaper). bad_dog(Dog) :- is_dog(Dog); chases(Cat); is_cat(Cat).
A
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)
A.
"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? For instance, the following lines will print 15 int balance[5] = {1, 2, 3, 4, 5}; printf(""%d"", getAverage( balance, 5 ) ); A. int getAverage(int arr[], int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + *(arr+i); } return sum; } B. int getAverage(int *arr, int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + arr[i]; } return sum; } C. int getAverage(int arr[], int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + arr[i]; } return sum; } D. int getAverage(int *arr, int size) { int sum = 0; for (int i = 0; i < size; ++i) { sum = sum + *(arr+i); } return sum; }"
ALL
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? A)enrolled(cse300). B) enrolled(Who, cse300). C) enrolled(cse300, Who). D) X is enrolled cse300.
B
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 *(ask) pt; pt = new MyClass[3]; //add code here return 0;} a delete instruction is needed before the main() ends. Which of the following options is correct? A.delete * pt; B.delete [ ] pt; C.for (int i =0; i<3; i++) { delete pt[i]; } D.delete pt;"
B
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 *(ask)johnDoe = new Kid; johnDoe->foo(); delete johnDoe; return 0; } A)Hi, I am a GrandPa B)Hi, I am a Kid C)Hi, I am a Dad D)Nothing
B
Given the 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. 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[3]; a[0].setValues(1,1); a[1].setValues(2,2); a[2].setValues(3,3); D)Rectangle *a = new Rectangle[3]; a[0]->setValues(1,1); a[1]->setValues(2,2); a[2]->setValues(3,3); E)Rectangle *a = new Rectangle[3]; a[0].setValues(1,1); a[1].setValues(2,2); a[2].setValues(3,3);
B, C & E
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; return 5 / 6; } B)if (1 < 2) { cout<< 3 * 4; cout << 5 / 6; } C) if (1 < 2) return 3 * 4; else return 5 / 6; D) if (1 < 2) cout<< 3 * 4; else cout << 5 / 6;
C
What is printed by this program? #include <iostream> using namespace std; class A { public: void m() {cout << "AAA";} }; class B: public A { public: virtual void m() {cout << "BBB";} }; class C: public B { public: void m() {cout << "CCC";} }; int main() { B *b <ask b> = new C; b->m(); return 0; }
CCC
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line int x = 0/1; // Java
Correct
Which of the following lines (in Java, C, or C++) is equivalent to this expression in LISP (- (* 1 2) (+ 3 4) (/ 5 6) 7 ) 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
D
?- 10 + 5 is 15. How will prolog respond to this query?
False
Given the following fact and rule: fun(1, 2). fun(N, F) :- N>0, N1 is N - 1, fun(N1, F1), F is N * F1. What is the result of the query ?- fun (2,2).
False
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
False
The scope resolution operator (::) is used to overload a function or an operator in object-oriented paradigm.
False
Select all the options that apply. A Prolog program consist of Goals / Questions Rules Predicates If-else Conditions Classes and Objects Facts Data Types
Goals / Questions Rules Predicates If-else Conditions Facts
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line char @ = 'A'; // in C/C++
Lexical
Prolog is based on
Predicate logic
Select all the options that apply to complete the following sentence. A Prolog program consist of
Rules, Goals / Questions & Facts
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line int If = (1<2 <3); // in C/C++
Semantic
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line int If = (1<2 <3); // in Java
Semantic
What is the error type (lexical, syntactic, or semantic) or with "correct" when there are no errors (lexical, syntactic, or semantic) in the line if = 5; // in C/C++
Syntactical
What is the result of executing the following line? What is the return value shown by the interpreter? (and (< 4 (* 3 5)) (not (>= 4 6)) )
T
What is a similarity between a struct and enum?
They let you define new data structures
15 is 10 + 5. How will Prolog respond to this query?
True
A programming language can belong to multiple paradigms
True
Compilation of a program is the translation of all statements of a program into assembly language before any statement is executed.
True
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 result of the query? ?- fun (1,2).
True
Given the following fact and rule. fun(1, 2). fun(N, F) :- N>0, N1 is N - 1, fun(N1, F1), F is N * F1. What is the result of the query ?- fun (2,4).
True
Is the following line correct in LISP ( + 1 2 3 4 5 6 7 8 9 0)
True
Is the following true or false with respect to inheritance? When a base class is privately inherited, public members of the base class become private members of the derived class
True
Is the following true or false with respect to inheritance? When a base class is publicly inherited, protected members of base class becomes protected members of derived class
True
Is the following true or false with respect to inheritance? When a base class is publicly inherited, public members of the base class becomes public members of derived class
True
Logic programming describes what the problem is by a set of conditions and constraints, and leaves the computer to match the problem to the existing knowledge of facts and rules and to find solutions to the problem
True
One feature of the functional paradigm is a higher level of abstraction compared with Imperative and Object-Oriented paradigms
True
What is printed on the screen by the print instruction in the code below? (print ( and (< (* 3 5 ) ) ( not (>= 4 6 ) ) ) )
True
char, unsigned char, signed char and int are all numeric (integer) types in C programming.
True
Features of the imperative or procedural paradigm includes
conditional statements & manipulation of named data (variables)
functions are created by calling a function-making macro. This macro is called
defun
Given the following facts. instructor(john, cs265). instructor(mary, cs311). instructor(paul, cs446). enrolled(joseph, cs311) enrolled(joseph, cs365) enrolled(joseph, cs446) enrolled(danielle, cs365) enrolled(danielle, cs446) Which query provides a list of all the students enrolled in cs365?
enrolled(Who, cs365).
Features of the functional paradigm includes
expresses computations in terms of mathematical functions & simpler semantics
Features of the logic paradigm includes
expressing computation in terms of logic predicates
Write in Prolog the statement "pizza is a food"
food(pizza).
What is equivalent code in C++ for the following LISP statement (if (< 1 2) (+ 3 4) (- 5 6) )
if (1 < 2) return 3 + 4; else return 5 - 6;
What would be the English meaning for this Prolog statement ?- owner(jane, dog(X)) :- big(X),spots(X). A)a big dog with spots is the owner of jane B) jane is a owner of a dog and the owner of something big and the owner of something with spots. C) if jane is the owner of X then X is big and has spots . D ) jane is the owner of some dog if that dog is big and has spots.
jane is the owner of some dog if that dog is big and has spots.
The semantic structure of imperative programming languages normally include which of the following validations
parameters type in a function declaration should match these in the function call., unicity and type matching
Prolog is based on
predicate logic
Which of the following are NOT primitive data types in C? int, short, long, char, String, bool, float, double.
short, long, String, bool
Given the following facts. instructor(john, cs265). instructor(mary, cs311). instructor(paul, cs446). enrolled(joseph, cs311) enrolled(joseph, cs365) enrolled(joseph, cs446) enrolled(danielle, cs365) enrolled(danielle, cs446) 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" 1) teaches(P,S) :- instructor(P,C); enrolled(S,C). 2) instructor(P,C), enrolled(S,C) :-teaches(P,S). 3) teaches(P,S) :- instructor(P,C), enrolled(S,C). 4) instructor(P,C); enrolled(S,C) :-teaches(P,S).
teaches(P,S) :- instructor(P,C), enrolled(S,C).
Given the following fact and rule. fun(1, 2). fun(N, F) :- N>0, N1 is N - 1, fun(N1, F1), F is N * F1. What is the result of the query ?- fun (2,4).
true
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;