QUESTIONS Question Options Answer & Explanation. A. Yes B. No
|
|
|
- Lora Mills
- 9 years ago
- Views:
Transcription
1 QUESTIONS Sr. no. Question Options Answer & Explanation 1 For the following statements, would arr[3] and ptr[3] fetch the same character? char arr[]= Surprised char *ptr= Surprised A. Yes B. No Answer: A Both pointers and array can be used to store a string. 2 What will be the result of assigning a value to an array element whose index exceeds the size of the array? 3 Are ++*ptr and *ptr++ same? A. Compilation error B. The element is initialized to 0. C. The compiler will automatically increase the size of the array. D. The program may crash if some important data gets overwritten. A. Yes B. No Answer: D The program may crash is the correct answer.but modern compiler will take care of this kind of situations. Answer: B ++*ptr increments the value being pointed to by ptr. *ptr++ means grab the Value of (*ptr) and then increment it. 4 What does the array arr refer to? int* arr[8]; A. Array of integers B. Array of integer pointers Answer: B It is an array which can store integer pointers
2 C. A pointer to an array of integers D. Any of above. 5 What is the output of the following code snippet? 1. int x = 5, y = 15; 2. int * p1, * p2; 3. p1 = &x; 4. p2 = &y; 5. *p1 = 10; 6. *p2 = *p1; 7. p1 = p2; 8. *p1 = 20; 9. printf("%d %d",x,y); A B C D What is a "void" pointer? A. Variable with data type as "void" B. Pointer returning variable of type "void" C. It has no associated data type D. It can hold address of any datatype Answer:C In line 5, *p1 = 10; so the value of variable x is changed to 10. In line 6, *p2 = *p1 value of variable y is changed to 10 In line 7, p1 = p2 pointer p1 points to variable y now In line 8, *p1 = 20 value of variable y is now changed to 20 Answer: C,D A void pointer is a pointer that has no associated datatype with it.it can hold address of any datatype and can be typcasted to any datatype. 7 What will be the output of the following program? #include<stdio.h> int main() char *name="india"; int x; char *cptr = name; while(*cptr!= '\0') cptr++; x = cptr - name; printf("%d", x); return 0; A. 3 B. 4 C. 5 D. 6 E. compilation error Answer: C Program is calculating string length using pointer.
3 8 What will be the output of the program? #include<stdio.h> main() int a[3] [4]=1,2,3,4,4,3,2,1,1,3,4,1; printf("%d",*(*(a+1)+2)); 9 What will happen when the following program is compiled and run? #include<stdio.h> int main() int a[]=1,2,3,4,5; int b[]=1,2,3,4,5; if(a==b) printf("yes"); else printf("no"); return 0; 10 Given the following program, which statement will produce a compilation error? #include<stdio.h> main() A. 1 B. 2 C. 3 D. 4 A. yes B. no C. The program will encounter a compilation error. D. There will be a runtime error in the program. A. Statement 1 B. Statement 2 C. Both D. None Answer:B a:- base address of multidimensional array (a+1) :- increments the value of array pointer by 1 that in turn points to row 2 of array(property of multidimensional array pointer as it points to array of pointers(which are pointing to 1D arrays)). (*(a+1)+2) now points to exact same location as a[1] [2]. Answer: B If statement will compare the base address of two arrays a and b,and they are not same. So condition becomes false and program prints no Answer:A Addition of pointers are not allowed in C,whereas subtraction is allowed. int k1=1; int k2=5; int *ptr1=&k1; int *ptr2=&k2;
4 printf("%d\n",((ptr1- ptr2))); //Statement 1 printf("%d\n",*(ptr1+ptr2)); // Statement 2 11 Find the output: main() char * A[] = "C", "C++", "JAVA", "PHP"; char **B[] = A+2, A+1, A+3, A, ***C; C = B; ++C; printf("%s", *(*C+1)+1); A. C++ B. ++ C. AVA D. JAVA 12 a[x][y][z] is same as A. *(*(*(a+x)+y)+z) B. *(*(*(a+z)+y)+x) C. *(*(*(a+x+y))+z) D. None of the above Answer: C Assume the following memory locations for different strings and the pointers. C= B will initialize it to C => C has address 208 *C+1 => its pointing to next location of 108 (116) *(*C+1)+1 => pointing to 2nd character at 116 printing *(*C+1)+1 will print all characters from 2nd character of JAVA Answer: A Multidimensional arrays are indexed in the order of highest to lowest. Here, a[x] and *(a+x) refer to the same plane. Pointer arithmetic is done internally by the compiler the way it is
5 13 char abc[14] = "C Programming"; printf("%s", abc + abc[3] - abc[4]); What would this print? A. C Programming B. rogamming C. Runtime Error D. Compilation Error suggested in the answers. Answer : B abc[3] = r = 114(ASCII) abc[4] = o = 111(ASCII) = (abc ) = (abc + 3) 14 What does this mean int ** fun(int **) A. A function accepting pointer to pointer to an int and returns pointer to pointer to an int B. A function accepting pointer to pointer to an int and returns pointer to an int C. A function accepting pointer to an int and returns pointer to pointer to an int D. None of the above Answer : A Explanation : int indicates an integer variable int * indicates a pointer to an integer variable int ** indicate a pointer to pointer to an integer variable 15 Assume that the size of an integer is 4 bytes. What will be the output of the following code: int a[2][2]=2,3,1,6; printf( %d,&a[0][1] - &a[0][0]); 16 Assume the following C variable declaration A. 1 B. 2 C. 4 D. 8 E. Garbage value A. I, II, and IV only B. II, III, and IV only Answer: A Subtracting pointers gives total number of objects between them Answer: A
6 int *A[10],B[10][10] Among the following expressions I A[2] II A[2][1] III B[1] IV B[2][3] Which will not give compiletime errors if used as left hand sides of assignment statements in a C program? C. II and IV only D. IV only I is valid, assigning value to pointer A[2], II is valid, possible due to array styled indexing of pointers IV is valid, simple assignment to 2-dimensional array Example: int *A[10], B[10][10]; int C[2]=1,6; A[2]=C; A[2][1]=5; B[2][3]=4 17 I strlen II strchr III strcat IV strcmp Among the above list which of the following are string functions defined? (A) I only (B) I, III only (C) I, III, IV only (D) All of the Above Answer: D strlen: Computes string length strchr: Search string for a character strcat: Concatenating two strings strcmp: Compare two strings Programming Questions Program 0: Largest Sum Contiguous Subarray Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of integer which returns the largest sum. Lets take the example of array 5,-3, 4 Possible contiguous subarray combinations are 5, -3, 4, 5,-3, -3,4, 5,-3,4 The contiguous subarray 5,-3,4 has got the largest sum 6
7 Input Constraints: First line : array size (N), where 1<= N<=100 Second line : N integers of separated by spaces where each number Ni satisfies <= Ni <=10000 Output Constraints: Single integer SUM which is the largest of sum of all possible contiguous subarray Public Test Cases: id Input Output Private Test Cases: id Input Output Code: In general one would approach this problem by iterating for all possible start and end combinations which would make N*(N-1)/2 combinations.
8 But instead of this one could solve this using pre-computation i.e, let us consider cur_max(i) is sum of maximum sum contiguous subarray ending at index i, then cur_max(i) is given by, cur_max(i) = max(cur_max(i-1)+val(i),val(i)) where val(i) is value at index i. Maximum sum subarray can be found by finding the maximum of all cur_max. By using the precomputed cur_max of i-1 we can compute cur_max of i. Hence the below logic becomes a optimal computation of largest sum contiguous subarray. #include<stdio.h> #define MAX 100 int main() int size,input[max],i; scanf("%d",&size); for(i=0;i<size;i++) scanf("%d",&input[i]); //curr_max computes the largest contiguous maximum sum ending at cur_idx //max_so_far (global maxima)computes the largest contiguous maximum sum till the cur_idx long max_so_far = input[0]; long curr_max = input[0]; for (i = 1; i < size; i++) curr_max = (input[i]>curr_max+input[i])? input[i] : curr_max+input[i]; max_so_far =(max_so_far>curr_max)? max_so_far : curr_max; printf("%ld",max_so_far); return 0; Program 1: Find whether two given strings are permutations of each other Write a program to find whether two given strings are permutations of each other. A string str1 is a permutation of str2 if all the characters in str1 appear the same number of times in str2 and str2 is of the same length as str1. Input: Two strings S1 and S2 Output: yes - if they satisfy given criteria
9 no - otherwise Constraints: 1 <= len(s1), len(s2) <= 100. Characters from ASCII range 0 to 127. White space will not be given in the string. Public Test cases: Number Input Output 1. india daini yes 2. hellobye hellobye! no 3. iloveindia loveindiai yes yes 5. aaa aa no Private Test cases: Number Input Output 1. iitmadras. yes madras.iit 2. nptelisbest yes ptenlisestb 3. abcdefg no aabbccddeeffgg no #$%& yes &%$# 6. (abc) no (xyz) 7. "hellobye" "byehello" yes Solution program 1: #include<stdio.h> int main() int acount[128] = 0, bcount[128] = 0, c = 0;
10 char a[100]; char b[100]; scanf("%s",a); scanf("%s",b); //now take every character from string 'a' and using ASCII value increment corresponding index in array 'acount' while (a[c]!= '\0') acount[(int)a[c]]++; c++; c = 0; //now take every character from string 'b' and using ASCII value increment corresponding index in array 'bcount' while (b[c]!= '\0') bcount[(int)b[c]]++; c++; for (c = 0; c < 128; c++) //if any single character also mismatch then return no if (acount[c]!= bcount[c]) printf("no"); return 0; //satisfy criteria so return true printf("yes"); return 0; Program 2: Find balancing index in array Write a program that given a number n and a sequence of n integers, it outputs the first(lowest) index i where the following condition is satisfied:
11 Sum of elements at lower indices(<i) = sum of elements at higher indices ( >i) if the above condition does not hold for any index then output -1 The Sum of lower indices(<i) when i=0, should be initialized to 0 and the higher indices(>i) should be initialized to A[1] + A[2] +A[3]...A[N-1], where N is the size of the array. Output the index of an array such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in an array A let: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0 3 is a valid answer, because: A[0] + A[1] + A[2] = A[4] + A[5] + A[6] Input: The size of array N, followed by N numbers. Output: index i - if i is the lowest index of the array satisfying the required condition -1 - if there does not exist any such index Constraints: 2 <= sizeof array <= 100 All entries of array,arr[i] will follow the following property <= Arr[i] <= 1000 Public Test cases: Number Input Output
12 Private Test cases: Number Input Output Solution program 2: #include <stdio.h> int main() int arr_size,i,ans=-1,sum=0,leftsum=0 ; scanf("%d",&arr_size); int arr[arr_size];// = -7, 1, 5, 2, -4, 3, 0; for(i=0;i<arr_size;i++) scanf("%d",&arr[i]); /* Find sum of the whole array */ for (i = 0; i < arr_size; i++) sum += arr[i]; for( i = 0; i < arr_size; i++) sum -= arr[i]; // sum is now right sum for index i if(leftsum == sum) ans=i; break;
13 leftsum += arr[i]; printf("%d",ans); return 0; Programming 3 The depth of a alphabet is the number of parentheses it is surrounded by. So write a C program to find the depth of each alphabet in the input. ( a ( b ) ( ( c d ) e ) f ) g g is at depth 0 a and f are at depth 1 b and e are at depth 2 c and d are at depth 3 Input Constraints: Number of characters in a input ranges from The input will have only (, ) and letters from English alphabet There will be no repetition of letters. Only lowercase letters are used. The letters can be in any sequence. Input: An array of characters Output: The depth of each letter separated by a space. The order of the depth of the letters should be the same order that the letters appear in the input. To mark the end of the output it should end with a space and a # character. Example 1: Input: (a(b)((cd)e)f)g Output: # Example 2: Input: p(r(q))(s) Output: #
14 In this example, letters are appearing in the order p followed by r followed by q and s. They have depth of 0, 1, 2 and 1 respectively. Note that the depth is not printed in the order p,q,r,s (the alphabetical order) but p,r,q,s (the order in which they appear in the input string). Public Test cases: Number Input Output 1. (a(b)((cd)e)f)g # 2. a(b(c))(d) # 3. a(b(c))(d(fe)) # Private Test cases: Number Input Output 1. a(b(c))(d(f()e)) # 2. () # 3. ab()(c(d(e(f)()(g)h))) # 4. ((((a))b))cdegfhi(jklmnop) # 5. ((a))((b(c)((d(e(f(g(h(i(j(k(l)))))))))))) # 6. ((a))((b(c)((d()(e(f(g(h(i(j(k(l)))))())))))))(m(n() (o(p(q(r(s(t()(u(v(w(x(y(z)))))(())))))()))()))) # 7. ()(()((()))) # 8. (a)b(c(def)g(h(ijkl(mn)o)p)) # 9. (z) 1 # 10. ((x)) 2 # 11. a 0 # 12. abc(d) # Solution: #include<stdio.h>
15 #include<string.h> int main() int a=0,i,set=0; char input[100]; scanf("%s",input); for(i=0;input[i]!='\0';i++) switch(input[i]) case '(': a++; break; case ')': a--; break; default : printf("%d ",a); set = 1; if(set==0) printf(" #"); else printf("#"); return 0;
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
arrays C Programming Language - Arrays
arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)
5 Arrays and Pointers
5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE
PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :
Variables, Constants, and Data Types
Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class: L&L, 2.1-2.3, App C 1 Primitive Data There are eight
Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example
Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]
Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts
C++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
Passing 1D arrays to functions.
Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,
COMPUTER SCIENCE. Paper 1 (THEORY)
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
Conditionals (with solutions)
Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;
Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists
Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Arrays in Java. Working with Arrays
Arrays in Java So far we have talked about variables as a storage location for a single value of a particular data type. We can also define a variable in such a way that it can store multiple values. Such
3.GETTING STARTED WITH ORACLE8i
Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer
Fundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
Pseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
Chapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs
Writing Simple C Programs ESc101: Decision making using if- and switch statements Instructor: Krithika Venkataramani Semester 2, 2011-2012 Use standard files having predefined instructions stdio.h: has
Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays
Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
Playing with Numbers
PLAYING WITH NUMBERS 249 Playing with Numbers CHAPTER 16 16.1 Introduction You have studied various types of numbers such as natural numbers, whole numbers, integers and rational numbers. You have also
9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
Statements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
Answers to Review Questions Chapter 7
Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
Unit 6. Loop statements
Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now
Stacks. Linear data structures
Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations
In this Chapter you ll learn:
Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis
Data Structures using OOP C++ Lecture 1
References: 1. E Balagurusamy, Object Oriented Programming with C++, 4 th edition, McGraw-Hill 2008. 2. Robert Lafore, Object-Oriented Programming in C++, 4 th edition, 2002, SAMS publishing. 3. Robert
Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC
Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:
Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:
Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,
C PROGRAMMING FOR MATHEMATICAL COMPUTING
UNIVERSITY OF CALICUT SCHOOL OF DISTANCE EDUCATION BSc MATHEMATICS (2011 Admission Onwards) VI Semester Elective Course C PROGRAMMING FOR MATHEMATICAL COMPUTING QUESTION BANK Multiple Choice Questions
Section IV.1: Recursive Algorithms and Recursion Trees
Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller
1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++
Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The
CS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
Basics of I/O Streams and File I/O
Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading
CS106A, Stanford Handout #38. Strings and Chars
CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes
Chapter 13 Storage classes
Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same
Tutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus [email protected] The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C
Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in
B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011
NEW Detailed Syllabus of B.Sc.(Computer Science) and B.Sc.(IT) Effective From July 2011 SEMESTER SYSTEM Scheme & Syllabus for B.Sc. (CS) Pass and Hons. Course Effective from July 2011 and onwards CLASS
4. Binomial Expansions
4. Binomial Expansions 4.. Pascal's Triangle The expansion of (a + x) 2 is (a + x) 2 = a 2 + 2ax + x 2 Hence, (a + x) 3 = (a + x)(a + x) 2 = (a + x)(a 2 + 2ax + x 2 ) = a 3 + ( + 2)a 2 x + (2 + )ax 2 +
Introduction to Java. CS 3: Computer Programming in Java
Introduction to Java CS 3: Computer Programming in Java Objectives Begin with primitive data types Create a main class with helper methods Learn how to call built-in class methods and instance methods
Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment
Chapter 3. if 2 a i then location: = i. Page 40
Chapter 3 1. Describe an algorithm that takes a list of n integers a 1,a 2,,a n and finds the number of integers each greater than five in the list. Ans: procedure greaterthanfive(a 1,,a n : integers)
CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java
CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section
C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu
C / C++ and Unix Programming Materials adapted from Dan Hood and Dianna Xu 1 C and Unix Programming Today s goals ú History of C ú Basic types ú printf ú Arithmetic operations, types and casting ú Intro
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc
Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc
Moving from C++ to VBA
Introduction College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 309 Numerical Analysis of Engineering Systems Fall 2014 Number: 15237 Instructor: Larry
Chapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
How To Write Portable Programs In C
Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important
KITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php [email protected] [email protected] Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
SQL Server Database Coding Standards and Guidelines
SQL Server Database Coding Standards and Guidelines http://www.sqlauthority.com Naming Tables: Stored Procs: Triggers: Indexes: Primary Keys: Foreign Keys: Defaults: Columns: General Rules: Rules: Pascal
Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar
Lexical Analysis and Scanning Honors Compilers Feb 5 th 2001 Robert Dewar The Input Read string input Might be sequence of characters (Unix) Might be sequence of lines (VMS) Character set ASCII ISO Latin-1
Semantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.
Section 2.5 Cardinality (another) Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted A = B, if and only if there is a bijection from A to B. If there is an injection
PHP Tutorial From beginner to master
PHP Tutorial From beginner to master PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c
Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Visual Logic Instructions and Assignments
Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.
1 Description of The Simpletron
Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies
JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
An Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
Chapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;
50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)
Simple C Programs. Goals for this Lecture. Help you learn about:
Simple C Programs 1 Goals for this Lecture Help you learn about: Simple C programs Program structure Defining symbolic constants Detecting and reporting failure Functionality of the gcc command Preprocessor,
Project 2: Bejeweled
Project 2: Bejeweled Project Objective: Post: Tuesday March 26, 2013. Due: 11:59PM, Monday April 15, 2013 1. master the process of completing a programming project in UNIX. 2. get familiar with command
Boolean Data Outline
1. Boolean Data Outline 2. Data Types 3. C Boolean Data Type: char or int 4. C Built-In Boolean Data Type: bool 5. bool Data Type: Not Used in CS1313 6. Boolean Declaration 7. Boolean or Character? 8.
Chapter 9, More SQL: Assertions, Views, and Programming Techniques
Chapter 9, More SQL: Assertions, Views, and Programming Techniques 9.2 Embedded SQL SQL statements can be embedded in a general purpose programming language, such as C, C++, COBOL,... 9.2.1 Retrieving
How to Reduce the Disk Space Required by a SAS Data Set
How to Reduce the Disk Space Required by a SAS Data Set Selvaratnam Sridharma, U.S. Census Bureau, Washington, DC ABSTRACT SAS datasets can be large and disk space can often be at a premium. In this paper,
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
Lecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
Number Representation
Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data
Compiler Construction
Compiler Construction Lecture 1 - An Overview 2003 Robert M. Siegfried All rights reserved A few basic definitions Translate - v, a.to turn into one s own language or another. b. to transform or turn from
Compiler Construction
Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation
Selection Statements
Chapter 5 Selection Statements 1 Statements So far, we ve used return statements and expression ess statements. e ts. Most of C s remaining statements fall into three categories: Selection statements:
Excel: Introduction to Formulas
Excel: Introduction to Formulas Table of Contents Formulas Arithmetic & Comparison Operators... 2 Text Concatenation... 2 Operator Precedence... 2 UPPER, LOWER, PROPER and TRIM... 3 & (Ampersand)... 4
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations
