Programming in C++ Solution Manuals MODULE 1:

Size: px
Start display at page:

Download "Programming in C++ Solution Manuals MODULE 1:"

Transcription

1 MODULE 1: 1. What do you mean by variables and keywords in C++? Can we declare a keyword as variable? Variable is a storage place inside a computer where we can store some constant values. Variable name must be alphabetic, alphanumeric, string but it can t be constant value. Keywords are the special type of words that contains some special identification by the compiler. The keyword can t be a variable. 2. What do you mean by scope of the variable means? What is Local Scope and What is global scope? Declaration of a variable within the program is called as scope of the variable. There are 2 types of variables. Local Scope: If the variable is declared within the void main( ) function then that is called as local scope. Global Scope: If the variable is declared outside the variable then it is called as Global scope and the variable is said to be global variable. Example: 3. What do you mean by a datatype? What is the use of an enum datatype? Data types are used to define a variable. Name Description Size Range char Character or small integer. 1byte signed: -128 to 127 unsigned: 0 to 255 short int (short) Short Integer. 2bytes signed: to unsigned: 0 to 65535

2 int Integer. 4bytes signed: to unsigned: 0 to long int (long) Long integer. 4bytes signed: to unsigned: 0 to bool Boolean value. It can take one of two values: true or false. 1byte true or false float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits) double Double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits) long double Long double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits) wchar_t Wide character. 2 or 4 bytes 1 wide character enum datatype: enum is an user defined datatype in which we can attach a name to a numbers, thereby it increases comprehensibility of the code. The enum keyword automatically assigns 0,1,2,3,4, so on to the elements inside the enum data type. Example: #include <iostream.h> enum Language English, French, German, Italian, Spanish ; int main() Language tongue = German; cout << "\n Current language is " << tongue; return 0; Output: Current language is 2 4. What is the use of typedef datatype? Sometimes it might be required to own types based on other existing data type. On that case typedef is used. Its syntax is: typedef existing_type new_type_name; Example: typedef char C; typedef char g[89]; typedef char *p; 5. What is stream? What is the use of streams in C++?

3 It is a special type of string that contains the input and output instructions. Streams are two types: istream: It is an input stream. The user can input the data in istream. The istream contains the objects cin>>. ostream: It is an output stream. The user can display the data in ostream. The ostream contains the object cout<<. 6. What do you mean by a manipulator? Manipulator are the operators that are used to format the data display. The most commonly used manipulators are endl and setw. endl manipulator are used to end the existing line. setw is used to set the width of a necessary field. Example: cout<< Hello <<endl; Example: setw(5); cout<<345<<12; 7. What are the different derived datatypes? The different derived datatypes are: Array: An array is the collection of variables having similar datatype. Function: Function is the block of statements that can be executed at a time. Pointer: Pointer is used for allocating any memory location of the variables. Structure/Union/Class: Structure/Union/Class is the collection of dissimilar datatype. 8. What is the difference between the address stored in a pointer & value stored at that address? We can assign the address stored in a pointer by the ampersand (&) which is called as reference operator. But we can assign the value stored at that address by asterisks (*) which is called as indirection operator. Example: Let us consider a variable p whose address is 2000 and the value stored at the address of p is 25. So *p will be 25 and &p will be What is the difference in structure and union? The total memory occupied by the structure is equal to the total size of the variable. As for example: struct student int rollno; //size of int is 2byte char name[30]; //size of char is 1byte and name[30] is 30byte float mark; //size of float is 4byte ; Here the size of the structure is = 36 byte But the total memory occupied by the union is maximum size of the variable declared inside the union. Example:

4 union student int rollno; //size of int is 2byte char name[30]; //size of char is 1byte and name[30] is 30byte float mark; //size of float is 4byte ; Here the size of the structure is max(2,30,4) = 30 byte 10. What is the use of scope resolution operator in C++? Scope resolution operator is used for two purposes: It is used to define the global variable. Example: #include<iostream.h> int i=20; void main( ) cout<<"the global value of I is "<<::i It is used to define a method outside the class or structure or union. Example: #include<iostream.h> class student void mark( ); student : : mark(int x) cout<<"enter mark"<<endl; cin>>x; cout<<"your mark is"<<x; void main( ) student s; s.mark( ); 11. What is array of structure? What is pointer to array? If we declare an structure with an array then it is called as array of structure. If we declare an array and the array elements can be accessed by the pointer then it is called as pointer to array. 12. What is a class? What is an object?

5 Class is the user defined datatype that contains data members, member functions or methods (the functions that are declared inside the class).object is an instance of the class. By using the objects we can access the methods or data members. Example for the Class and Object: #include<iostream.h> class computer //declaration of the class //Access Specifier int i, j; software( ) //declaration of method cout<<"enter Software id"; cin>>i; void main( ) computer abc; //initialisation of object abc.software( ); //accessing the methods through the object Here we have declare the class as computer and the object as abc. 13. What do you mean by control structures in C++? Control structures are most important in structured language C++. Generally control structures have body. Some examples of control structure are: Jumping(goto statement) Looping(while, do while, for) Conditional Statements(if, if else, if elseif if, switch case) 14. What is looping? Looping is the continuous execution of block of statement or single statement for a certain conditions. Looping statements in C++ are: while( ), do while( ) and for( ) loop. 15. What is branching? Branching is the execution of statement or block of statement for a certain condition. Branching statements are if, if else, if else if else, switch( ) case. Branching is also called as decision making in C++. It is also called as conditional statements in C What do you mean by an array? How integer array is different from character array? An array is the collection similar datatype that have the common name. An array can be represented as:

6 Datatype <variable name> [size]; Example: int A[6]; An integer array is different from character array. Because in integer array we have to define the array as int. So the data inside integer array is always acts as integer type. But in character array we have to define the array by the data type as char type. So the array items in an character array can be character type. 17. What is the size of an array S[n][m][l]? Give an example. The size of the array S[n][m][l] is n*m*l*(size of the data type). Example the size of int S[5][6][10] is 5*6*10*(size of int that is 2) = 600byte 18. What do you mean by function? What are the types of function? Function is the block of statement which can be executed at a time. The different type of functions is: 1. User define function: The function that can be declared by the user. 2. In built or library functions: These functions are already defined inside the C++ compiler. 19. How to declare an user defined function? The general syntax of the user define functions are: #include<iostream.h> void main( )... fun( );... //Calling of the function void fun( ) //Defining the function... //Declaring the function What do you mean by function prototyping? How function prototyping is different in C and C++? In C++ a template is used when we define or declared a function. When function is called, the compiler uses the template to ensure that proper argument is passed, and the return value is treated correctly. Any violation in matching the arguments or the return types will be caught by the compiler at the time of compilation itself. These checks and controls did not exist in the C function prototyping. In this way, function prototyping is different in C and C What do you mean by nested loop and nesting of functions?

7 Nested loop: is the loop in which contains another loop. That means there are two loops, one is outer loop and another is inner loop. Example: For(int i=0; i<=9; i++) for(int j=8; j<=0; j--) cout<< Hello ; Nesting of function: During declaration of function if we declare a function inside the definition then it is called as nesting of function. Example: Function1( ) Declaration; Function2( ); Function2( ) Declaration; 22. What is the basic difference in call by value and call by reference? In call by value the value of the variable is passed inside the function, where as in call by value the address is passed inside the function. 23. What is inline function? Why inline function is used in C++? By declaring a function as inline means the compiler replaces the function call with the corresponding function code. To eliminate the cost of calls to small functions C++ uses the inline function. For defining a function inline we must write the keyword inline before the function. The general declaration of the inline function is: inline function-header function body Example: inline double cube(double a) return(a*a*a); 24. What are the situations where inline expansions may not work? Some of the situations where inline expansions may not work are: 1. For function returning values, if a loop, a switch, or a goto exists.

8 2. For functions not returning values, if a return statement exists. 3. If inline functions are recursive. 25. What is difference between inline function and macro. Inline function Macro 1. It is a member function. 2. class <class_name> inline return. type function_name(arg 1, arg 2,... arg n) 3. It expands when it call. 4. It takes more time for execution. 5. It takes less memory space. 6. It checks error. 7. Example: #include<iostream.h> class circle int r; float a; inline void get( ); inline void cal( ); ; inline void circle : : get( ) cout<<"enter Radius"; cin>>r; inline void circle : : cal( ) a = 3.141* r * r; cout<<"area = " <<a; void main( ) circle obj; obj.get( ); obj.cal( ); 1. It is a preprocessor. 2. # define macro_name macro_val 3. It expands before compilation of program. 4. It takes less time for execution. 5. It takes more memory space. 6. It does not check error. 7. Example: #define Area(r)(3.141*r*r) #include<iostream.h> void main( ) int r; float a; cout<<"enter Radius"; cin>>r; a = Area(r); cout<<"area"<<a;

9 26. What do you mean by function overloading? Explain. Overloading means to the use of the same thing for different purposes. That means we can use the same function name to create functions that perform a variety of different tasks. This is also called as function polymorphism. #include<iostream.h> int volume(int); double volume(double, int); long volume(long, int, int); int main( ) cout<<volume(10)<<endl; cout<<volume(2.5,8)<<endl; cout<<volume(100l,75,15)<<endl; return 0; int volume(int s) return(s*s*s); double volume(double r, int h) return(3.141*r*r*h); long volume(long l, int b, int h) return(l*b*h); OUTPUT: What is the use of friend function? Give an example. As a non-member function cannot have an access to private data of a class, still we want to share a particular function with more than one class. In such situations we can use friend functions that will be friendly with both the classes, thereby allowing the functions to have an access to the private data member of these classes. The function declaration should be preceded by the keyword friend. Example: #include<iostream.h> #include<conio.h>

10 class sample int a; int b; void setvalue( ) a=35; b=67; friend float mean(sample s); ; float mean(sample s); return float(s.a+s.b)/2.0; Programming in C++ Solution Manuals void main( ) sample x; x.setvalue( ); cout<<"mean is"<<mean(x)<<endl; getch( ); Some important points about friend function: It can declare any section of a class(private, protected, public) has same effect. It is a non-member function. It must have argument of class type. It need not require object for its execution. It is used to access private section data of a class. 28. What is the difference between malloc( ) and new? The new operator automatically computes the size of the data object we need not used sizeof( ) operator. It automatically returns the correct pointer type. It need not used cast operator. It is possible to initialized the object while creating the memory space. The new and delete can be overloaded. 29. How to read and print one character (including spaces) at a time from keyboard? ANS: #include<iostream.h> #include<conio.h> void main( )

11 Char ch; cout<< Enter a character, ch=getch( ); cout<< out of character <<ch; 30. What is the difference between macro and inline member function? Macro Inline function It is a preprocessor. Syntax: #define <macro name> <macro declaration> It expands before compilation It does not check the error. It can be a member function. Syntax: class<class_name> inline <return type> method(arg1, arg2,...arg n) It expands at the time of execution of program. It checks the error. 31. What do you mean by static member function and static member function? Static member function: These function is the class member functions. It is used only static member data or methods. It has no this pointer. It can be accessed by class name but not object. It can be declared with the keyword static. Syntax: class<class_name> static <return_type> method(arg1, arg2,..., arg n) statements;

12 ; Static data member: It is initialized to zero when the first object of its class is created. No other initialization is permitted. Only one copy of the that member is created for the entire class and is shared by all the objects of that class, no matter how many objects are created. Static data member can be visible within the class, but its life time is total the program. Example: static int count; 32. What do you mean by recursive function? Explain with an example. Recursive Function: If a function calls itself then it is called as recursive function. Example: C++ Program to calculate factorial of a number using recursion. #include<iostream.h> #include<conio.h> int fact(int); void main() int a,b=0,c; clrscr(); cout<<"enter the N value:"; cin>>a; while(a<0) cout<<"\n\enter only positive number.\n"; cout<<"enter N value:"; cin>>a; b=fact(a); cout<<b; getch(); int fact(int x) if(x==0) return(1); else return((x)*(fact(x-1)));

13 33. Write a program to check prime number using recursion. #include<iostream.h> int isprime(int); int main() int num,prime; cout<<"enter a positive number: "; cin>>num; prime = isprime(num); if(prime==1) cout<<num<< <<"is a prime number"<<endl; else cout<<num<< << is not a prime number"; return 0; int isprime(int num) static int i=2; if(i<=num/2) if(num%i==0) return 0; else i++; isprime(num); return 1; Output: Enter a positive number: is a prime number 34. What are the different functions used in handling of strings? 1. strlen() function: This function counts and returns the number of characters in a string. The length does not include a null character. Syntax: n=strlen(string); Where n is integer variable. Which receives the value of length of the string. Example: length = strlen( Hollywood ); The function will assign number of characters 9 in the string to a integer variable length.

14 2. strcat() function: Programming in C++ Solution Manuals when you combine two strings, you add the characters of one string to the end of other string. This process is called concatenation. The strcat( ) function joins 2 strings together. It takes the following form strcat(string1,string2) string1 & string2 are character arrays. When the function strcat is executed string2 is appended to string1. the string at string2 remains unchanged. Example: strcpy(string1, Soumya ); strcpy(string2, Sourabha ); cout<<strcat(string1,string2); From the above program segment the value of string1 becomes SoumyaSourabha. The string at str2 remains unchanged as Sourabha. 3. strcmp() function: In C++ you cannot directly compare the value of 2 strings in a condition like if (string1==string2) Most libraries however contain the strcmp( ) function, which returns a zero if 2 strings are equal, or a non zero number if the strings are not the same. The syntax of strcmp( ) is given below: strcmp(string1,string2) String1 & string2 may be string variables or string constants. String1 & string2 may be string variables or string constants some computers return a negative if the string1 is alphabetically less than the second and a positive number if the string is greater than the second. Example: strcmp( Newyork, Newyork ) will return zero because 2 strings are equal. strcmp( their, there ) will return a 9 which is the numeric difference between ASCII i and ASCII r. strcmp( The, the ) will return 32 which is the numeric difference between ASCII T & ASCII t. 4. strcmpi() function: This function is same as strcmp() which compares 2 strings but not case sensitive. Example strcmpi( THE, the ); will return strcpy() function: C++ does not allow you to assign the characters to a string directly as in the statement name= Robert ; Instead use the strcpy(0 function found in most compilers the syntax of the function is illustrated below.

15 strcpy(string1,string2); strcpy function assigns the contents of string2 to string1. string2 may be a character array variable or a string constant. strcpy(name, Robert ); In the above example Robert is assigned to the string called name. 6. strlwr () function: This function converts all characters in a string from uppercase to lowercase. Syntax: strlwr(string); For example: strlwr( SOUMYA ) converts to soumya. 7. strrev() function: This function reverses the characters in a string. Syntax: strrev(string); For ex strrev( program ) reverses the characters in a string into margrop. 8. strupr() function: This function converts all characters in a string from lower case to uppercase. Syntax : strupr(string); For example strupr( soumya ) will convert the string to SOUMYA. Example: C++ Program for Sub String. #include<iostream.h> #include<conio.h> void main() char a[30],b[30]; int i, j, l1, l2, c, f; clrscr( ); cout<<"output\n"; cout<<"\n\n"; cout<<"\nenter First String:"; cin>>a; cout<<"\nenter String to Search:"; cin>>b; l1=strlen(a); l2=strlen(b); j=0; c=0; f=0; for(i=0;i<l1;i++) x:

16 if(b[j]==a[i]) c++; f=1; j++; if(c==l2)goto y; else if(f==1) j=0; c=0; f=0; goto x; y: if(c==l2) cout<<"\n\t\tword Found"; else cout<<"\n\t\tword Not Found"; getch(); Programming in C++ Solution Manuals 35. Write a program in C++ using switch case statement to calculate the grade of BPUT. #include<iostream.h> #include<conio.h> void main( ) int mark, index; cout<<"enter the Mark of a student(between 100):\t"; cin>>mark; index= mark/10; switch(index) case 10: case 9: cout<<"\n The grade is => O"; break; case 8: cout<<"\n The grade is => E"; break; case 7: cout<<"\n The grade is => A"; break; case 6: cout<<"\n The grade is => B"; break; case 5: cout<<"\n The grade is => C"; break; case 4: case 3: cout<<"\n The grade is => D"; break; case 2: case 1:

17 case 0: cout<<"\n The grade is => F.\n You are failed."; break; default: cout<<"\ninvalid Mark. Please Enter Mark between 0 to 100"; getch( ); Output: Enter the Mark of a student(between 100): 83 The grade is => E 36. Write a C++ program for Check for Vowel using switch case statement. #include<iostream.h> #include<conio.h> void main( ) char ch; clrscr(); cout<<"enter any character"; cin>>ch; switch(ch) case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': cout<<"the Entered Character <<ch<< is a Vowel ; break; default: cout<<ch<< is not a vowel"; break; getch(); 37. Write a C++ Program For Binary to Decimal. #include<iostream.h> #include<conio.h> #include<math.h> void main() int s=0,z=0,n,t;

18 clrscr(); cout<<"enter the n value"; cin>>n; while(n>0) t=n%10; s=s+(t*pow(2,z++)); cout<<"s="<<s<<endl; n=n/10; cout<<"given number is="<<s<<endl; getch(); Programming in C++ Solution Manuals 38. Write a C++ program to find the sum of digits. #include<iostream.h> #include<conio.h> main() int n,q,r,s=0; clrscr(); cout<< \n Enter the no"; cin>>n; while(n!=0) q=n/10; r=n-q*10; s=s+r; n=q; cout<< \n the sum of digits : <<s; getch(); 39. Write a C++ program to find all the sum of sequences of even & odd number. #include<iostream.h> #include<conio.h> void main( ) int i, range, sum=0; clrscr( ); cout<<"enter Range";

19 cin>>range; for(i=0; i<=range; i=i+2) sum = sum + i; cout<<"\n\n\tthe sum of Even Number Sequence is "<<sum; for(i=1; i<=range; i=i+2) sum = sum + i; cout<<"\n\n\tthe sum of Odd Number Sequence is "<<sum; getch( ); 40. Example: C++ program to find permutation. #include<iostream.h> #include<stdlib.h> int lev=-1,n,val[50],a[50]; void main() int i,j; clrscr(); cout<<"enter how many numbers"<<endl; cin>>n; for(i=0;i<n;i++) val[i]=0; j=i+1; cin>>a[j]; visit(0); getch(); visit(int k) int i; val[k]=++lev; if(lev==n) for(i=0;i<n;i++) cout<<a[val[i]]; cout<< ;

20 for(i=0;i<n;i++) if(val[i]==0) visit(i); lev--; val[k]=0; 41. Write a program to calculate the square of a number using the pointer arithmatic concept. #include<iostream.h> #include<conio.h> void main( ) int x, y, *ptr; cout<<"enter the number to calculate the square"; cin>>x; ptr=&x; *ptr=(*ptr)*(*ptr); cout<<"the square is %d"<<x; getch( ); output: Enter the number to calculate the square 5 The square is Write a program to calculate the length of string using pointer. #include<iostream.h> #include<conio.h> void main( ) char str[20]; int len=0; char *ptr; clrscr( ); cout<<"enter a string"; gets(str); ptr=str; for(len=0; *ptr!='\0'; ptr++) len++; cout<<"the length of the string is"<<len<<endl;

21 getch( ); output: Enter a string SOUMYASOURABHA The length of the string is 14 Programming in C++ Solution Manuals 43. Write a C++ program to reverse a string using pointer. #include<iostream.h> #include<conio.h> void main( ) char str[30]=""; int i; clrscr( ); cout<<"please Enter a string to reverse"; cin>>str; for(i=0; str[j]!='\0'; i++) cout<<"the reverse string is"; i--; for(; i>=0; i--) cin>>str[i]; getch( ); 44. What do you mean by typecasting? Explain Explicit and implicit conversion. What are the rules associated with type conversion? Type conversion is done in two ways: 1. Implicit conversions 2. Explicit conversions 1. Implicit type Conversion: Whenever C++ finds mixed data type in an expression, it performs the conversion automatically. C++ automatically converts any intermediate values to the proper type so that the expression can be evaluated without losing any significance. This automatic conversion is known as implicit conversion. Example: Implicit conversation: #include<iostream.h>

22 #include<conio.h> void main( ) int x; float y, sum, avg; clrscr( ); x=80; y=40.8; sum=x+y; cout<<"the sum is : "<<sum; avg=sum/2; cout<<"\nthe average is : "<<avg; getch( ); Output: The sum is : The average is : Explicit Conversion: Besides implicit conversion, sometimes we want to force a type conversion in a way that is different from automatic conversion. As for example if you want to calculate the ratio of male to female in a town then the expression will be ratio = no-of-female/ no-of-male; Because no-of-female and no-of-male are declared as integer, the decimal part of the result of the division would be lost and ratio would represent a wrong figure. This problem can be solved by converting locally one of the variables to the floating point as: ratio = (float) no-of-female/no-of-male; The operator (float) converts the no-of-female to floating point for the purpose of evaluation of the expression and then using rule of automatic conversion. The division is performed in floating point made this retaining the fractional part of result. The process of such a local conversion is known as explicit conversion or casting a value. The syntax is: (type_name) expression. Example: average = sum/(float) i ; Example: Example of Explicit conversion: #include<iostream.h> #include<conio.h> void main( ) int a =76; float f = 7.9; double d = 98.99; char c = 'L'; signed s = -1; clrscr( ); cout<<"\n int in char format: "<<a; cout<<"\n float in int format: "<<(int)f; cout<<"\n double in char format: <<(char)d; cout<<"\n char in int format: "<<(int)c; cout<<"\n signed in unsigned format: (unsigned)s; getch( );

23 Output: int in char format: L float in int format: 7 double in char format: b char in int format: 76 signed in unsigned format: Rules for Type Conversion: If one operand is unsigned int, the other will be converted into unsigned int and the result will be unsigned into long int and the result will be long int. If one of the operand is unsigned long int, the other will be converted into unsigned long int and the result will be unsigned long int. If one of the operand is float, the other will be converted into float and the result will be float. If one of the operand is double, the other will be converted to double and the result will be double. If one of the operand is long double, the other will be converted to long double and the result will be long double. 45. What do you mean by RTTI? The RTTI means the information of type of a data is known as run time. it is achieved by typeid( )operator. syntax char*object class=typeid(objected)name( ) ex. #include<iostream.h> #include<typeinfo.h> classx void dis ( ) cout<< ctc ; class y:public x void dis( ) cout<< Soumya Sourabha Patnaik ;

24 ; void main() x*ob; cout<<typeid(ob).name( ); y*obj; cout<<typeid(obj).name( ); Programming in C++ Solution Manuals 46. What do you mean by file handling in C++? C++ provides the following classes to perform output and input of characters to/from files: ofstream: Stream class to write on files ifstream: Stream class to read from files fstream: Stream class to both read and write from/to files. These classes are derived directly or indirectly from the classes istream, and ostream. We have already used objects whose types were these classes: cin is an object of class istream and cout is an object of class ostream. Therfore, we have already been using classes that are related to our file streams. And in fact, we can use our file streams the same way we are already used to use cin and cout, with the only difference that we have to associate these streams with physical files. Let's see an example: Example 14.1: basic file operations. #include <iostream.h> #include <fstream.h> int main () ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0; Output: [file example.txt] Writing this to a file. This code creates a file called example.txt and inserts a sentence into it in the same way we are used to do with cout, but using the file stream myfile instead. 47. What is the different state flags associated with file?

25 bad( ) : Returns true if a reading or writing operation fails. For example in the case that we try to write to a file that is not open for writing or if the device where we try to write has no space left. fail( ) : Returns true in the same cases as bad(), but also in the case that a format error happens, like when an alphabetical character is extracted when we are trying to read an integer number. eof( ) : Returns true if a file open for reading has reached the end. good( ) : It is the most generic state flag: it returns false in the same cases in which calling any of the previous functions would return true. 48. What is the work of set_terminal( )? It is used to transfer the control to specified error handing function. It contains a single argument of function name where control is transferred. Exmp:#include<iostream.h> #include<except.h> class A ; class B ; void skip( ) cout<< error can be handle ; void main( ) set-terminal(skip); try throw(two); catch(one) cout<< exception one is caught ; Here the throw statement throw two but it can not match with any catch block.so skip( )is execute.

26 49. What is the difference between static array and dynamic array. Static array: array. In such case to allocate memory at the time of compilation of program we use static Example: int a[10]; It allocates 20 byte at the time of compilation. Suppose the user input 5 element then it uses 10bytes and does not use 10 bytes. Suppose the user input 11 elements then it can t be accepted because it requires 22 bytes. So this is the disadvantage of static array. Dynamic array: Program: #include<iostream.h> void main( ) int a[10], i, n; cout<< "Enter how many data"; cin>>n; cout<<"enter data"; for(i=0; i<n; i++) cin>> a[i]; for(i=0; i<n; i++) cout<< a[i]; To allocate memory at the time of execution of program is known as dynamic array. It is held by new operator. Program: #include<iostream.h> void main( ) int i, n, *p; clrscr( ); cout<<"enter range"; cin>>n; p = new int[n];

27 cout<<"enter data"; for(i=0; i<n; i++) cin>>p[i]; for(i=0; i<n; i++) cout<<a[i]; 50. Given a 2-dimensional m x n double array A. Declare the variable A, and write the c++ code required to allocate and deallocate the array (assume that m and n are declared and their values are known). ANS: double A[m][n]; #define M 10 #define N 10 void main( ) double A[M][N]; int r,c; cout<<enter data ; for(r=0;r<10;r++) for(c=0;c<10;c++) cin>>a[r][c]; for (r=0;r<10;r++) for(c=0;c<3;c++) cout<<a[r][i]; cout<< \n ; Here the array Á allocate 10 x10x8=800 bytes. #include<iostream.h> #define M 10 #define N 10 void main( ) double *A=new double[m][n]; int r,c; cout<<enter data ; for(r=0;r<m;r++)

28 for(c=0;c<n;c++) cin>>a[r][c]; for(r=0;r<m;r++) for(c=0;c<n;c++) cout<<a[r][c]; cout<, \n ; delete[ ]A; 51. What does the reference operator do? What is the difference between passing an argument by reference and passing it by value? It create an alias name of a variable. Syntax: datatype &var1 = var2; Example: #include<iostream.h> void main( ) int a = s; int &b = a; cout<<a<<b; a++; cout << a << b; b++; cout << a << b; Here a and b variable have same address. Call by Value 1. In such case the value of the variable can pass as the function argument. 2. If any change in formal argument then no change in actual argument. 3. The formal argument allocates separate memory space. 4. The actual and formal argument have separate memory space. 5. Example: Call by reference 1. In such case it creates an alias. 2. If any change in formal argument then automatically change in actual argument. 3. The formal argument does not allocate memory space. 4. The actual argument and formal argument have same memory space. 5. Example:

29 #include<iostream.h> #include<conio.h> void main( ) void ex(int, int); int a, b; cout<< "Enter 2 number"; cin>>a >>b; ex(a,b); cout<<a<<b; void ex(int p, int q) int temp; temp p; p = q; q= temp; cout << p<<q; #include<iostream.h> #include<conio.h> void main( ) void ex(int &, int &); int a, b; cout<< "Enter 2 number"; cin>>a >>b; ex(a,b); cout<<a<<b; void ex(int x, int y) int temp; temp x; x = y; y= temp; cout << x<<y;

30 MODULE 2 1. What do you mean by object oriented programming language? Why C++ is an object oriented language? In object oriented language we have to create a class which is the collection of data members, member functions or methods etc. We have to access the elements inside the class through an object. In C++ we can create a class and define the data members and member functions of that class. We again create an object of that class. Through that object we have to access those elements inside the class. 2. Why Java is a purely object oriented language where as C++ is not a purely object oriented language? In Java we can t create any program without using the class or object. But in C++ it may or may not require creating classes or objects. That means we can write the program in C++ both by creating the class and by not creating the class. Hence C++ is not a purely object oriented language. 3. What are the applications of OOPS? The various applications of OOPS are: 1. Real-time systems. 2. Simulation and modeling. 3. Object-oriented databases. 4. Hypertext, hypermedia and expertext. 5. AI and expert systems. 6. Neural networks and parallel programming. 7. Decision support and office automation systems. 8. CIM/CAM/CAD systems 4. What the basic difference is in between object oriented programming and object based programming? Give one example of each. Object-based programming is the style of programming that primarily supports encapsulation and object identity. Languages that support programming with objects are said to be object-based programming languages. They do not support inheritance and dynamic binding. Ada, Visual BASIC etc. are the examples of object-based programming language. Object-oriented programming incorporates all of object-based programming features along with two additional features, namely, inheritance and dynamic binding. Java, C++, Python, PHP etc are the examples of object oriented programming language. 5. What are the features of OOPS? The various features of OOPS are as follows:

31 Inheritance: Inheritance is the process of forming a new class from an existing class or base class. The base class is also known as parent class or super class, The new class that is formed is called derived class. Derived class is also known as a child class or sub class. Inheritance helps in reducing the overall code size of the program, which is an important concept in object-oriented programming. Multiple Inheritance:The mechanism by which a class is derived from more than one base class is known as multiple inheritance. Instances of classes with multiple inheritance have instance variables for each of the inherited base classes. C++ supports multiple inheritance. Data Abstraction: Data Abstraction increases the power of programming language by creating user defined data types. Data Abstraction also represents the needed information in the program without presenting the details. Data Encapsulation: Data Encapsulation combines data and functions into a single unit called Class. When using Data Encapsulation, data is not accessed directly; it is only accessible through the functions present inside the class. Data Encapsulation enables the important concept of data hiding possible. Polymorphism: Polymorphism is in short the ability to call different functions by just using one type of function call. It is a lot useful since it can group classes and their functions together. Polymorphism means that the same thing can exist in two forms. This is an important characteristic of true object oriented design - which means that one could develop good OO design with data abstraction and inheritance, but the real power of object oriented design seems to surface when polymorphism is used. In C++, polymorphism means that if the same message is sent to different objects, the object s behavior depends on the nature of the object itself. This is sort of obvious for completely different objects, but the concept starts making sense when combined with inheritance. Delegation: Delegation is a way of making object composition as powerful as inheritance. In delegation two objects are involved in handling a request a receiving object delegates operations to its delegate. This is analogous to child class sending requests to the parent class.

32 Reusability: This term refers to the ability for multiple programmers to use the same written and debugged existing class of data. This is a time saving device and adds code efficiency to the language. Additionally, the programmer can incorporate new features to the existing class, further developing the application and allowing users to achieve increased performance. This time saving feature optimizes code, helps in gaining secured applications and facilitates easier maintenance on the application. 6. Why C++ is called as weakly typed language? What do you mean by strong typing? The language which cannot support type casting is called as strong typed language. In C++ it can support typecasting. Type casting is possible in C++. That means we can convert any data type to any data type in C++. Hence C++ is a weakly typed language. 7. What are the advantages of OOPS? Through inheritance, we can eliminate redundant code and extend the use of existing classes. We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity. The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program. It is possible to have multiple instances of an object to co-exist without any interference. It is possible to map objects in the problem domain to those objects in the program. It is easy to partition the work in a project based on objects. The data-centered design approach enables us to capture more details of a model in implementable form. Object-oriented systems can be easily upgraded from small to large systems. Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler. Software complexity can be easily managed. 8. What is a class? How to define a class? A class is a user defined data type which contains some data members, member functions or methods. We can declare a class by using the keyword class. Syntax is: class <class name> Declaration of the class;

33 9. What is an object? Explain how to declare an object? An object is an instance of the class. While accessing any element of a class we need to access through the object. The object can be declared after the class or within the void main( ). Declaration: class <class_name> declaration of the class; <object1, object2, object 3...>; OR class <class_name> declaration of the class; ; void main( ) class_name object1, object2,..., object n; declaration inside void main 10. What is the advantage of class over structure or union? In structure/union we can t specify the data members as private of protected. By default the data elements are public in structure/union. So data hiding may not be possible in structures or unions. Another problem in structure is that it doesnot allow the struct data type to be treated like built in types. Example: struct complex float x; float y; ; struct complex c1, c2, c3; The complex numbers c1, c2 and c3 can easily be assigned values using the dot operator but we cannot add two complex numbers to subtract one from the other. For example: c3 = c1 + c2. Because that will be illegal in C structures.

34 11. What are the different access specifiers? Explain with examples. Access specifiers are used to identify access rights for the data and member functions of the class. There are three main types of access specifiers in C++ programming language: private public protected Private A private member within a class denotes that only members of the same class have accessibility. The private member is inaccessible from outside the class. Example 16.1: class x private: int no; void input( ) cout<<"enter a no"; cin>>no; ; void main( ) x ob; ob.no = 20; //ERROR: Private member can't be accessed ob.input( ); //ERROR: Private member can't be accessed Public Public members are accessible from outside the class. Example 16.2: class x int no; void display( ) cout<<no; ; void main( ) x ob;

35 ob.no=20; ob.display( ); Protected A protected access specifier is a stage between private and public access. If member functions defined in a class are protected, they cannot be accessed from outside the class but can be accessed from the derived class. Example 16.3: class x protected: int no; void input( ) cout<<"enter a no"; cin>>no; ; class y: protected x protected: void display( ) cout<<no; ; void main( ) x ob; ob.no=11; //ERROR: The data member cannot be accessible 12. What do you mean by C++ references? Explain with an example. Reference variables are aliases to other variables. Any changes to the original variable or the alias (reference variable) result in change to the same memory location. Reference variables must always be initialized. When pass by reference is done to functions unlike pass by value a new copy of the variable is not created. This is very useful when big objects are passed as class members.

36 The other alternative is to use call by address using pointers. This involves dereferencing which may not look elegant and clean. References solve this problem. Example: Basic usage of reference variables #include <iostream> using namespace std; int main() int i = 100; int &j = i; cout << "i=" << i << endl; cout << "j=" << j << endl; j += 100; cout << "i=" << i << endl; cout << "j=" << j << endl; cout << "Address of i=" << &i << endl; cout << "Address of j=" << &j << endl; OUTPUT: i=100 j=100 i=200 j=200 Address of i=0012ff88 Address of j=0012ff What do you mean by array of object? Explain with an example. If we declare array of variables for a class then it is called as array of object. Example: class employee char name[30]; float age; void getdata(void); void putdata(void); ; Now for the above class we are defining the array of object. employee manager[10]; employee worker[89];

37 On the above there are two objects manager having size 10 and for object worker having size is 89. Hence on this example there are 99 objects for the class employee. Example: Array of Object. #include<iostream.h> class employee char name[30]; float age; void getdata(void); void putdata(void); ; void employee : : getdata(void) cout<<"enter name:"; cin>>name; cout<<"\n Enter Age"; cin>>age; void employee : : putdata(void) cout<<"name: "<<name<<"\n"; cout<<"age: "<<age<<"\n"; const int size=3; int main( ) employee manager(size); for(int i=0; i<size; i++) cout<<"\n Details of manager"<<i+1<<"\n"; manager[i].getdata( ); cout<<"\n"; for(i=0; i<size; i++) cout<<"\n Manager"<<i+1<<endl; manager[i].putdata( ); return 0;

38 14. What is an constructor? What is an default constructor? What is a parameterized constructor? Constructor is a method whose name is same as class name. The constructor can be always declared in the public section of the area. Constructors are executed when we create any object of the class. Constructors cannot be declared as virtual or we cannot refer to their address. Default Constructor: The constructor that has no argument is called as default constructor. Syntax is: class <class_name> <class_name> ( ) //constructor declaration declaration of constructor; ; Example: #include<iostream.h> class x int no; x( ) void display( ); ; x : : x( ) no = 10; void x : : display( ) cout<<no; void main( ) x ob; ob.display( ); Parameterized Constructor: The constructor having parameters or arguments is called as parameterized constructor.

39 Syntax is: class <class_name> <class_name>(arg1, arg2,..., arg n) declaration; ; Example: #include<iostream.h> class x int no; x( ); x(int); void display( ); ; x : : x( ) no =10; x : : x(int no1) no =no1; void x : : display( ) cout<<no; void main( ) x ob; x ob1=30; //explicit type execution x ob2(40); //implicit type execution ob.display( ); ob1.display( ); ob2.display( ); 15. What is dynamic initialization of object?

40 Dynamic initialization of object means the initial value of an object can be provided during the run time. The main advantage of the dynamic initialization of object is that we can provide the flexibility of different format of data at run time depending upon the situations. Example: dynamic initialisation of objects. #include<iostream.h> #include<conio.h> class fixed_deposit long int p_amount; //principal amount int years; //period of investment float i_rate; //interest rate float r_value; //return amount fixed_deposit( ) fixed_deposit(long int p, int y, float r=0.12); fixed_deposit(long int p, int y, int r); void display( ); ; fixed_deposit : : fixed_deposit(long int p, int y, float r) p_amount = p; years = y; i_rate = r; r_value = p_amount; for(int i=0; i<=y; i++) r_value = r_value*(1.0 + r); fixed_deposit : : fixed_deposit(long int p, int y, int r) p_amount = p; years = y; i_rate = r; r_value = p_amount; for(int i=0; i<=y; i++) r_value = r_value*(1.0 + float(r)/100);

41 fixed_deposit : : display(void) cout<<"\n\nprincipal Amount = "<<p_amount<<"\t"<<"return value="<<r_value<<endl; void main( ) clrscr( ); fixed_deposit fd1, fd2, fd3; long int p; int y; int R; float r; cout<<endl<<endl<<endl<<"enter the principal amount"; cin>>p; cout<<"\nenter the period"; cin>>y; cout<<"\nenter interest rate(in percent)"; cin>>r fd1 = fixed_deposit(p,y,r); cout<<"\nenter the principal amount"; cin>>p; cout<<"\nenter the period"; cin>>y; cout<<"\nenter interest rate(in decimal)"; cin>>r; fd2 = fixed_deposit(p,y,r); cout<<"enter the principal amount"; cin>>p; cout<<"enter the period"; cin>>y; fd3 = fixed_deposit(p,y); cout<<"\n\ndeposit 1:" fd1.display( ); cout<<"\n\ndeposit 2"; fd2.display( ); cout<<"\n\ndeposit 3"; fd3.display( ); getch( ); Output: Enter the principal amount Enter the period 5

42 Enter the interest rate(in percent) 5 Enter the principal amount Enter the period 5 Enter interest rate(in decimal) 0.05 Enter the principal amount Enter the period 5 Deposit 1 Principal amount=10000 Return value= Deposit 2 Principal amount=10000 Return value= Deposit 3 Principal amount=10000 Return value= What are dynamic constructors? While creating any object the constructor is used to allocate memory. This will enable the system to allocate the right amount of memory for each object when the objects are not of the same size, thus resulting in the saving of memory. Allocation of memory to objects at the time of their construction is known as dynamic construction object. The memory can be allocated with the help of new operator. 17. What do you mean by constant objects? We can create any constant objects using const keyword before object declaration. For example, we may create X as a constant object of the class matrix as follows: const matrix X(m,n); //Object X is constant Here matrix is the class name. Any attempt to modify the values of m and n will generate compile-time error. 18. What is a destructor? Why destructor cannot be overloaded? Explain destructor with an example. A destructor is a method that is declare inside a class. Its name is similar to a class. Its declaration is same as that of constructor but it can be defined by a tilde(~) symbol. It is used to destroy the object that is created by the constructor. A destructor never takes any argument not it return a value. new is used to allocate the memory in the constructor and we use delete to free that memory. A destructor cannot be overloaded because it does not have any parameters or arguments.

43 Example: Destructor. #include<iostream.h> #include<conio.h> int count=0; class finish finish( ) count++; cout<<"\n number of object created: "<<count; ~finish( ) cout<<"\n number of object destroyed: "<<count; count--; ; int main( ) clrscr( ); cout<<"\n\n enter main\n"; finish f1, f2, f3, f4; cout<<"\n\n enter block\n"; finish f5; cout<<"\n\n enter block 2\n"; finish f6; cout<<"\n\n re-enter main:"; return 0; Output: enter main number of object created: 1 number of object created: 2 number of object created: 3 number of object created: 4

44 enter block 1 number of object created: 5 number of object destroyed: 5 enter block 2 number of object created: 5 number of object destroyed: 5 number of object destroyed: 4 number of object destroyed: 3 number of object destroyed: 2 number of object destroyed: Consider the following class F00, (for which one constructor is written). Write a destructor, a copy constructor and an assignment operator that would be appropriate for the class. class F00 int *p; F00( ): p = new int[10]; for(int k=0; k<10; k+=1) p[k] = k; #include<iostream.h> class F00 int *p; F00( ) p = new int[10]; for(int k=0; k<10; k++) p[k] = k; F00 (F00 &ob)

45 p = new int[10]; for(int k=0; k<10; k++) p[k] = ob.p[k]; ~F00( ) delete p; ; void main( ) F00 ob1; F00 ob2 = ob1; Programming in C++ Solution Manuals 20. Can we define more than one constructor for a class? Yes, we can define more than one constructor for a class. This is called as multiple constructor declaration of a class. Example: class integer int m, n; integer( ) m=0; n=0; integer(int a, int b) m=a; n=b; integer(int & i) m=i.m; n=i.n; ;

46 This declares the three constructors for an integer object. The first constructor receives no arguments, the two receives two integer arguments and the third receives one integer object as an argument. 21. What is the difference between constructor & destructor? Explain using example. Constructor: A constructor is a special type of member function executes automatically when an object is created. Its syntax is: class<class_name> <class_name>( ) statements;... Destructor: It is a special type of member function execute automatically when an object is destroy. Its syntax is: class<class_name> <class_name>( ) statements; What do you mean by copy constructor? Explain with an example. Copy constructor is used to declare an initialize an object from another object. The process of initializing through a copy constructor is known as copy initialization constructor. A copy constructor takes a reference to an object of the same class as itself as an argument. Example: Copy constructor. #include<iostream.h>

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

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 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

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES CONSTRUCTORS AND DESTRUCTORS

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES CONSTRUCTORS AND DESTRUCTORS CONSTRUCTORS AND DESTRUCTORS Constructors: A constructor is a member function whose name is same as class name and is used to initialize data members and allocate memory dynamically. A constructor is automatically

More information

The C Programming Language course syllabus associate level

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

More information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

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

More information

C++ Language Tutorial

C++ Language Tutorial cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain

More information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

13 Classes & Objects with Constructors/Destructors

13 Classes & Objects with Constructors/Destructors 13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.

More information

Java Interview Questions and Answers

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

More information

Syllabus OBJECT ORIENTED PROGRAMMING C++

Syllabus OBJECT ORIENTED PROGRAMMING C++ 1 Syllabus OBJECT ORIENTED PROGRAMMING C++ 1. Introduction : What is object oriented programming? Why do we need objectoriented. Programming characteristics of object-oriented languages. C and C++. 2.

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

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

More information

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

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

More information

Basics of I/O Streams and File I/O

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

More information

IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction

IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points

More information

Data Structures using OOP C++ Lecture 1

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

More information

Informatica e Sistemi in Tempo Reale

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)

More information

Subtopics - Functions Function Declaration Function Arguments Return Statements and values. By Hardeep Singh

Subtopics - Functions Function Declaration Function Arguments Return Statements and values. By Hardeep Singh Subtopics - Functions Function Declaration Function Arguments Return Statements and values FUNCTIONS Functions are building blocks of the programs. They make the programs more modular and easy to read

More information

El Dorado Union High School District Educational Services

El Dorado Union High School District Educational Services El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.

More information

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies) Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies) Duration of Course: 6 Months Fees: Rs. 25,000/- (including Service Tax) Eligibility: B.E./B.Tech., M.Sc.(IT/ computer

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

More information

Comp151. Definitions & Declarations

Comp151. Definitions & Declarations Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

More information

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive

More information

Subject Name: Object Oriented Programming in C++ Subject Code: 2140705

Subject Name: Object Oriented Programming in C++ Subject Code: 2140705 Faculties: L.J. Institute of Engineering & Technology Semester: IV (2016) Subject Name: Object Oriented Programming in C++ Subject Code: 21405 Sr No UNIT - 1 : CONCEPTS OF OOCP Topics -Introduction OOCP,

More information

www.sahajsolns.com Chapter 4 OOPS WITH C++ Sahaj Computer Solutions

www.sahajsolns.com Chapter 4 OOPS WITH C++ Sahaj Computer Solutions Chapter 4 OOPS WITH C++ Sahaj Computer Solutions 1 Session Objectives Classes and Objects Class Declaration Class Members Data Constructors Destructors Member Functions Class Member Visibility Private,

More information

C++FA 5.1 PRACTICE MID-TERM EXAM

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

More information

C++ Programming Language

C++ Programming Language C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

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

More information

Binary storage of graphs and related data

Binary storage of graphs and related data EÖTVÖS LORÁND UNIVERSITY Faculty of Informatics Department of Algorithms and their Applications Binary storage of graphs and related data BSc thesis Author: Frantisek Csajka full-time student Informatics

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

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

More information

CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing

CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects

More information

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

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

More information

Object Oriented Software Design

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

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

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

More information

A brief introduction to C++ and Interfacing with Excel

A brief introduction to C++ and Interfacing with Excel A brief introduction to C++ and Interfacing with Excel ANDREW L. HAZEL School of Mathematics, The University of Manchester Oxford Road, Manchester, M13 9PL, UK CONTENTS 1 Contents 1 Introduction 3 1.1

More information

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. 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

More information

Moving from CS 61A Scheme to CS 61B Java

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

More information

C++ Outline. cout << "Enter two integers: "; int x, y; cin >> x >> y; cout << "The sum is: " << x + y << \n ;

C++ Outline. cout << Enter two integers: ; int x, y; cin >> x >> y; cout << The sum is:  << x + y << \n ; C++ Outline Notes taken from: - Drake, Caleb. EECS 370 Course Notes, University of Illinois Chicago, Spring 97. Chapters 9, 10, 11, 13.1 & 13.2 - Horstman, Cay S. Mastering Object-Oriented Design in C++.

More information

Sources: On the Web: Slides will be available on:

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,

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

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)

More information

Member Functions of the istream Class

Member Functions of the istream Class Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

More information

Curriculum Map. Discipline: Computer Science Course: C++

Curriculum Map. Discipline: Computer Science Course: C++ Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code

More information

Introduction to Java

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

More information

The programming language C. sws1 1

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

More information

5 Arrays and Pointers

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

More information

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. 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

More information

Stacks. Linear data structures

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

More information

Passing 1D arrays to functions.

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,

More information

C++ Input/Output: Streams

C++ Input/Output: Streams C++ Input/Output: Streams 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: istream

More information

Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example

Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics

More information

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is

More information

While Loop. 6. Iteration

While Loop. 6. Iteration While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true

More information

Chapter One Introduction to Programming

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

More information

Semantic Analysis: Types and Type Checking

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

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1

Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1 Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1 Introduction to Classes Classes as user-defined types We have seen that C++ provides a fairly large set of built-in types. e.g

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Course notes Standard C++ programming

Course notes Standard C++ programming Department of Cybernetics The University of Reading SE2B2 Further Computer Systems Course notes Standard C++ programming by Dr Virginie F. Ruiz November, 03 CREATING AND USING A COPY CONSTRUCTOR... 27

More information

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system. http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral

More information

More C++ Concepts. Operator overloading Friend Function This Operator Inline Function

More C++ Concepts. Operator overloading Friend Function This Operator Inline Function More C++ Concepts Operator overloading Friend Function This Operator Inline Function 1 Review There are different types of member functions in the definition of a class Accessor int Str :: get_length();

More information

Moving from C++ to VBA

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

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer. University of Wyoming MA 5310 An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

More information

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) Subject Description: This subject deals with discrete structures like set theory, mathematical

More information

! " # $ %& %' ( ) ) *%%+, -..*/ *%%+ - 0 ) 1 2 1

!  # $ %& %' ( ) ) *%%+, -..*/ *%%+ - 0 ) 1 2 1 !" #$%&%'())*%%+,-..*/*%%+- 0 )12 1 *!" 34 5 6 * #& ) 7 8 5)# 97&)8 5)# 9 : & ; < 5 11 8 1 5)=19 7 19 : 0 5)=1 ) & & >) ) >) 1? 5)= 19 7 19 : # )! #"&@)1 # )? 1 1#& 5)=19719:# 1 5)=9 7 9 : 11 0 #) 5 A

More information

CORBA Programming with TAOX11. The C++11 CORBA Implementation

CORBA Programming with TAOX11. The C++11 CORBA Implementation CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy

More information

Ch 7-1. Object-Oriented Programming and Classes

Ch 7-1. Object-Oriented Programming and Classes 2014-1 Ch 7-1. Object-Oriented Programming and Classes May 10, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497;

More information

BCS2B02: OOP Concepts and Data Structures Using C++

BCS2B02: OOP Concepts and Data Structures Using C++ SECOND SEMESTER BCS2B02: OOP Concepts and Data Structures Using C++ Course Number: 10 Contact Hours per Week: 4 (2T + 2P) Number of Credits: 2 Number of Contact Hours: 30 Hrs. Course Evaluation: Internal

More information

Functions and Parameter Passing

Functions and Parameter Passing Chapter 5: Functions and Parameter Passing In this chapter, we examine the difference between function calls in C and C++ and the resulting difference in the way functions are defined in the two languages.

More information

Chapter 5 Functions. Introducing Functions

Chapter 5 Functions. Introducing Functions Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name

More information

Laboratory Assignments of OBJECT ORIENTED METHODOLOGY & PROGRAMMING (USING C++) [IT 553]

Laboratory Assignments of OBJECT ORIENTED METHODOLOGY & PROGRAMMING (USING C++) [IT 553] Laboratory Assignments of OBJECT ORIENTED METHODOLOGY & PROGRAMMING (USING C++) [IT 553] Books: Text Book: 1. Bjarne Stroustrup, The C++ Programming Language, Addison Wesley 2. Robert Lafore, Object-Oriented

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

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

More information

Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism

Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism Polymorphism Problems with switch statement Programmer may forget to test all possible cases in a switch. Tracking this down can be time consuming and error prone Solution - use virtual functions (polymorphism)

More information

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything

More information

I PUC - Computer Science. Practical s Syllabus. Contents

I PUC - Computer Science. Practical s Syllabus. Contents I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

Chapter 2: Elements of Java

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

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

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

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II C++ intro Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 26, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February 26,

More information

Chapter 8 Selection 8-1

Chapter 8 Selection 8-1 Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

Pseudo code Tutorial and Exercises Teacher s Version

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

More information

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

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 :

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

Sequential Program Execution

Sequential Program Execution Sequential Program Execution Quick Start Compile step once always g++ -o Realtor1 Realtor1.cpp mkdir labs cd labs Execute step mkdir 1 Realtor1 cd 1 cp../0/realtor.cpp Realtor1.cpp Submit step cp /samples/csc/155/labs/1/*.

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Real Application Design Christian Nastasi http://retis.sssup.it/~lipari http://retis.sssup.it/~chris/cpp Scuola Superiore Sant Anna Pisa April 25, 2012 C. Nastasi (Scuola

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

Compiler Construction

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

More information

PL / SQL Basics. Chapter 3

PL / SQL Basics. Chapter 3 PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand the pass-by-value and passby-reference argument passing mechanisms of C++ Understand the use of C++ arrays Understand how arrays are passed to C++ functions Call-by-value

More information

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)

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

More information

arrays C Programming Language - Arrays

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)

More information