Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE240 Lecture 15

CSE240 Lecture 15

Introduction to Programming Languages
Getting Started with C++
(202009)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez

January 15, 2017
Tweet

Transcript

  1. jgs CSE 240 Introduction to Programming Languages Lecture 15: Midterm

    Review Javier Gonzalez-Sanchez javiergs@asu.edu PERALTA 230U Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 3 jgs

    Proctoring
  3. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 4 jgs

    Proctoring
  4. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 5 jgs

    Proctoring
  5. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 6 jgs

    Agenda § Sample Exam is available. Test your system ASAP § Midterm Exam available October 15 from 10:30 pm to 11:45 pm Key ideas: a) Show your environment. b) It is a CLOSED BOOK exam. Do not use any material c) Scratch paper is allowed. Empty White Paper. Show it on camera when you show your environment!
  6. jgs Test Yourselves

  7. jgs The following slides shows some examples related to some

    topics This is NOT a comprehensive list of topics Topics in the exam can be found Weeks 1 to 8
  8. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 9 jgs

    Sample Question 1
  9. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 10 jgs

    Sample Question 2
  10. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 11 jgs

    Sample Question 3
  11. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 12 jgs

    Structure § Provide 3 examples of lexical errors in C. § Provide 3 examples of syntactic errors in C. § Provide 3 examples of semantic errors in C. § Provide 3 examples of lexical errors in C++. § Provide 3 examples of syntactic errors in C++. § Provide 3 examples of semantic errors in C++. § Provide 3 examples of lexical errors in Java § Provide 3 examples of syntactic errors in Java § Provide 3 examples of semantic errors in Java § Exemplify a semantic error in Java that is NOT a semantic error in C/C++ § Given char a [5] = {'a', 'b', 'c', '\0'}; Is there is an error in the following line? char * b = a; If so, is it lexical, syntactical, or semantical?
  12. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 13 jgs

    Paradigms § Provide 3 characteristics/features of an imperative programming language § Provide 3 characteristics/features of a functional programming language § Provide 3 characteristics/features of a logic programming language § Provide 3 characteristics/features of an object-oriented programming language § Mention 3 differences (regarding features or capabilities) between C++ and Java (both are object-oriented programming languages).
  13. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 14 jgs

    Recursion § Create a function that print the following. It should be recursive, i.e., DO NOT use for, do/while or while statements here. 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1,
  14. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 15 jgs

    Arrays § Did you now the tic-tac-toe game? Create a 3x3 array to store a tic-tac-toe. Fill the array with ‘X’ or ‘O’. All the cells with the same value. Which data type should be used? Provide your source code using C § Use the language C. Create a struct named ball. Put 2 variables inside: an array of chars to store a color and an integer to store an id. § Ask the user for a number using scanf. § Use the number that the user provides to create an array of balls. The number represent how many elements the array should have. § Store in the first position of the array a ball with color= blue and id=1.
  15. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 16 jgs

    Arrays § Write a C program that, given an array a[ ] with size n and another number x, determines whether or not there exist two elements in a [ ] whose sum is exactly x. It returns 0 (the two elements do not exist) or 1 (the two elements exist). § Write a C program that, given an array of Ball (see question 5) named a[] of n items, prints the id of all the objects with color==red.
  16. Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 17 jgs

    Pointers § In the following code: #include <stdio.h> int main() { int var =10; int *p; p= &var; printf (“\n %p", &var); printf (“\n %p", p); printf (“\n %p", &p); printf (“\n %p", p); printf (“\n %d", var); printf ("\n %d", *p); printf (“\n %d", *( &var)); } Could you explain what is being printed for each printf instruction?
  17. jgs CSE 240 Introduction to Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu

    Spring 2018 Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.