0% found this document useful (0 votes)
7 views

8.Computer Language

The document provides an overview of programming languages, categorizing them into low-level (machine and assembly languages) and high-level languages. It details the characteristics, advantages, and disadvantages of each type, focusing on C programming language, its syntax, constants, data types, and flow control statements. Additionally, it explains the process of writing, compiling, and executing a C program, along with the use of operators and control statements.

Uploaded by

Yash Shimpi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
7 views

8.Computer Language

The document provides an overview of programming languages, categorizing them into low-level (machine and assembly languages) and high-level languages. It details the characteristics, advantages, and disadvantages of each type, focusing on C programming language, its syntax, constants, data types, and flow control statements. Additionally, it explains the process of writing, compiling, and executing a C program, along with the use of operators and control statements.

Uploaded by

Yash Shimpi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
Chapter Computer Language Programming Languages A programming language defines a set of instructions that are compiled together or perform a specific task by (PU. Each PL contains a unique set of keyword and syntax, which are used to create a set of instructions. ‘These PLs vary in level of abstraction they provide from the hardware. Based on level of abstraction they can classified in 2 categories : These are Low Level Languages and High Level Languages. Low Level Languages are further divided in to Machine language and Assembly language. Low Level Languages (LLL) The term low level means closeness to the way in which the machine has been built. Low level languages are machine oriented and require extensive knowledge of computer hardware and its configuration, Machine Language Machine language is the only language that is directly understood by the computer. It does not needs any translator program. We also call it machine code and it is written as strings of 1’s (one) and 0's (zero). ‘When this sequence of codes is fed to the computer, it recognises the codes and converts it into electrical signals needed to run it. eg., a program instruction may look like this 1011000111101. Itisnot an easy language for you to learn because of its difficult to understand. Itis efficient for the computer but, very inefficient for programmers. It is considered to the first generation language. It is also difficult to debug the program written in this language. Advantage The only advantage is that program of machine language run very fast because no translation program is required for the CPU. Disadvantages * Itis very difficult to program in machine language. The programmer has to know details of hardware to write program. ‘© The programmer has to remember a lot of codes to write a program which may result in programming, errors. * Itis difficult to debug the program. Assembly Language ‘The problem which we were facing in Machine Level Language is reduced to some extent by the use of human-readable code called Mnuemonics such as mov, add, ete. Translator program is required to translate the assembly language to machine language. This translator program is called ‘Assembler’. Its considered to be a second- generation language. Advantages © The symbolic programming of assembly language is easier to understand and saves a lot of time and effort of the programmer. * It is easier to correct errors and modify program instructions. * Assembly language has the same efficiency of execution as the machine level language. Because this is one-to- fone translator between assembly language program and its corresponding machine language program. Disadvantages ‘One of the major disadvantages is that assembly language is machine dependent. A program written for ‘one computer might not run in other computers with different hardware configuration ie, itis not portable, High Level Language (HLL) In High Level Language, instructions are defined in English words and logic of the problem irrespective of the type of computer you are using. © Itis easy to understand and simple to maintain. Higher level languages are the languages that use English language words and mathematical symbols like +, ~, %, /, ete. for its program construction. High level language has to be converted to machine language for the computer to understand. So, it needs compiler or interpreter for translation. eg. COBOL (Common Business Oriented Language) is mostly suitable for business oriented language where there is very little processing and huge output. FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic Instruction Code) where very large processing is required. C Programming Language Cis a general-purpose, procedural, imperative, high level computer programming language developed at AT and T’s Bell Laboratories of USA in 1972 by Dennis M. Ritchie. C is a reliable, simple and east to use language. It is a widely used programming language. It was developed for the programming of the UNIX OS. The C Character Set A character denotes any alphabet, digit or special symbol ie, Set of all valid characters that we can use in source program for forming words expression and numbers. It includes : * Alphabets A,B, Y,Z (all uppercase) 2 (all lowercase) « Digits 0,1,2,3,4,5,6,7,8,9 *# Special symbols ~1@#% &*()_ e>,.t/ ‘+ White spaces _ Blank space, Carriage return, Tab and New line. C Constants «The constants in C are the read only variables whose value cannot be modified once they are declared in the C program. « We define the constants in C language using the constants keyword. Syntax const data_type var_name = value; =I\00 Types of C Constant C constants can be divided into two major categories (i) Primary constants (ii) Secondary constants - array, pointer, structure, union etc, Prep Guide MAH-MCA CET Primary Constants They areas follows as : Integer Constant ‘# An integer constant must have atleast one digit. # Itmust not have a decimal point. « Itcan be either positive or negative. # Ifno sign precedes an integer constant, itis assumed to be positive. + Nocommas or blanks are allowed within an integer constant. « The allowable range for integer constants is ~ 32768 to 32767. Real Constants ‘ Real constants are often called floating point constants. ‘* The real constants could be written in two forms — Fractional form and exponential form. A real constant must have atleast one digit. Itmust have a decimal point. It could be either positive or negative. Default sign is positive. ‘No commas or blanks are allowed within a real constant, 8 +32534 (Positive real constant) 426.0 (Positive real constant) 32.76 (Negative real constant) ‘© The exponential form is usually used if the value of the constant is either too small or too large. © Inexponential form the real constant is represented in two parts. © The part appearing before ‘e' is called mantissa and following ‘e’is called exponent. e.g, 0.000342 in exponential form can be represented as 3.4204 ‘ Range of real constant in exponential form is ~ 3.4638 to 3.4038 Character Constants A character constant isa single alphabet, a single digit or a single special symbol enclosed within single inverted commas. eg., ‘A’ isa valid character constant whereas A is not. C Keyword Keywords are the words whose meaning has already been explained to the C compiler. The keywords cannot be used as variable names because if we do so, we are Computer Concepts Computer Language trying to assign a new meaning to the keyword, which is not allowed by the computer. £8, auto, break, case, char, const, continue, default, else, exter, float, for, goto, int, long etc, C Tokens Ina C source program, the basic element recognised by the compiler is the token. A token is a source program text that the compiler does not break down into component elements. C tokens includes keywords, identifiers, constants, strings, special symbols and operators. fiers or Symbols are the names you supply for variables, types, functions and labels in your program. Identifier names must differ in spelling and case from any keywords. We cannot use keywords as identifiers; they are reserved for special use. Rules for making identifier name 1. The first character of an identifiers must be an alphabet or an underscore, 2. All characters must be either letters or digits. 3, There is no special characters are allowed except the underscore “_", 4, There is no two underscores are allowed. 5. Don’t use keywords as identifiers. 6. Itis any combination of 1 to 31 characters. Data Types in C Language Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer, character float etc. Each data type requires different amounts of memory and has some specific operations which can be performed over it. The data types in C are class follows as— 1, Primary data types in C They are also known as the fundamental or primitive data types because they are predefined in the C language. All the other data types are derived from these data types. They are-int, char, float and double. 2. Derived data types in C These are derived from the primary data types. They are mainly of three types-ie,, Arrays, Functions and Pointers. 3. User-defined data types in C These are defined by user as per their requirement using the basic primary data types and derived data types. They are classified as structure, union and enumeration. 3 How to Write a First C Program There are certain rules that are applicable to all C programs and they are as follows : 1. InC program, each instruction written as a separate statement. 2. The statement of a program must be written in the sequence in which we want them to execute. 3. All statements should be written in lowercase letters. Blank space are not allowed in the variable name but we can use blank spaces between two words to improve readability of statement. 5, Statements should be in small case letters. 6, Every statement ends with a semicolon (;). 7. Semicolon is called statement terminator. 8, We can put the comment within a program by using /*...*/. 9. Comments are not necessary to use in a program but itis a good habit to use comments in a program. Compilation and Execution of a C Program 1. Write a program using editor. 2. Save the file with C extension. 3. To compile the program, we can select compile from compile menu and press enter or you can press Alt + F9, 4, Itwill check the errors if program has any error it will terminate the program then we can find out the error and we can correct it. After correcting the error we can compile the program again. After compiling successfully it will create a object (.0bj) file. mapas See tes [Remco | {ccna (c) [Object fe] (oo) 5. Once the source program has been converted into an object fle, itis still not in the form that we can trun. The reason behind this is that there may be some references to standard library functions or user- defined functions in other object files, which are compiled separately. Therefore, these object files are to be linked together along with standard library functions that are contained in library files. To link owe object files, select link from the compile menu. © Prep Guide MAH-MCA CET ‘After this the obj file will be compiled withthe one of ‘or more library files. The result of this linking 2. [if expression) process produces an executable file with .exe { ee block of statements; Object Object 1 ee | [3] — o es { ‘block of statements; 1 Taare a Is I 4, if expression) ets { block of statements; 6. .exe file isa stand alone executable file which can direct execute from command prompt. 7. After pressing Alt + F9, it will complete the whole process creating .obj and .exe. 8. To display the output of the program press Alt + F5. C-Flow Control Statements C provides two styles of flow control statements : 1. Branching, 2. Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching Branching is so called because the program chooses to follow one branch or another. Following are the ways to implement branching statements : 1. Using If Statement ‘This is the most simple form of the branching statements. It takes an expression in parenthesis followed by a statement or a block of statements. If the expression is true, then the statement or block of statements gets executed, otherwise these statements are skipped and the statement or block of statements under else gets ‘executed. Expression will be assumed as true if its evaluated value is non-zero. “f' statement can be defined in a program, in the following forms : 1. [if (expression) statement; oF 2. [iF (expression) { block of statements; } else if (expression) block of statements; } else } [block of statements; 2, Conditional or Ternary Operator inc (?:) It is similar to the if-else statement as it follows the algorithm as of if-else statement but it takes less space and helps to write if-else statements in the shortest way. It is also known as the ternary operator in Cas it ‘operates on three operands. ‘Syntax of conditional operator in C Expression 1 ? Expression 2: Expression 3 It means~ If expression is true (ie., Non-zero), then the value returned will be expression 2, otherwise the value returned will be expression 3. Switch Case Statement © The switch statement is like a nested if... else statement. It is mostly a matter of preference we use. It can be slightly more efficient and easier to read. * Syntax is as follows as : switch (expression) t case constant 1: ‘statement 1 ; break; /* optional */ Computer Concepts Computer Language case constant 2 : statement 2; break) /* optional */ case constant n : statement n; break; default : statement; ) Ifa condition is met in switch case then execution will, not continue on the next case due to the usage of ‘break’ keyword. Looping Loops provide a way to repeat commands and control how many times they are repeated. C provides a number of ways to impliement loops. 1. While Loop The most basic loop in C is the while loop. A while ‘statement is like a repeating if statement. Like an if statement, if the test condition is true : the statements get executed. The difference is that after the statements have been executed, the test condition is checked again. Ifitis still true the statements get executed again. This cycle repeats until the test condition evaluates to false. Syntax is as follows as : 7* optional */ ‘while (expression) { single statement; or block of statements; 2, For Loop For loop is similar to while, its just written differently. For statements are often used to process lists such a range of numbers. Syntax: for (expression 1; expression 2; expression 3) { single statement; or block of statements; In the above syntax : Expression 1— Initialise v Expression 2 — Conditional expression as long as this condition is true, loop will keep executing. Expression 3 — Expression 3 is the modifier which may be simple increment/decrement of a variable. 3. Do...while Loop Do....while is just like a while loop except that the text condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed atleast once. Syntax : do { single statement; or block of statements; ) while (expression); Break and Continue Statements C provides two commands to control the loops (i) break - exit from loop or switch and transfers. execution to statement immediately following the loop or switch. (ii) continue causes the loop to skip the remainder of its body and immediately retest its condition prior toreiterating. eg., using continue statement # include main() { inti; int} =6; fot (i=0; i50) indent printf (“a is between 50-55") || Operator (Logical OR) | | operator returns true if either one or both condition evaluates to true eg, if(@==10||a<10) ! Operator (Logical NOT) eg, if (flag) The NOT operator is often used to reverse the logical state of its operand. If condition is true, then it will make it false and vice-versa. if (! flag) equals to if (flag Hierarchy of Operators Type Unary operatars ‘Arithmetic, modulus ‘Arithmetic addition and. ~ Equality operators Bitwise AND, XOR, OR Logical AND ~~ Logical Or Conditional, Assignment, Comma Prep Guide MAH-MCA CET 2. Bitwise Operators Operations on bits at individual levels can be carried out using Bitwise operations in the C programming. language. Bits come together to form a byte which is the lowest form of data that can be accessed in digital hardwares, The whole representation of a number is considered while applying a bitwise operator. ‘The Bitwise operators supported by C language are listed in the following table. Assume variable A hold a 60, and variable B holds 13, then Operator] Description Example ‘& [Binary AND Operator copies |(A & B) will give 12 a bit tothe result if it exists in | which is 0000 1100 both operands. | [Binary OR operator copiesa |(A| B) will give 61 biti it exists in either |which is 0011 1101 loperand. ‘* [Binary XOR Operator copies (AB) will give 49 the bitif it is set in one |which is 0011 0001 loperand but not both. ~ [Binary Ones complement —_|(~A) will give -61 |Operator is unary and has the effect of ‘lipping’ bits Binary Left Shift Operator. [The left operands value is 'moved left by the number of bits specified by the right loperand, Binary Right shift Operator. ‘The left operands value is moved right by the number of bits specified by the right operand. which is 0111101 << [Ac< 2 will give 240 ‘which is 1111 0000 A>> 2will give 15 | which is 0000 1111 C-Variable Types A variable is just a named area of storage that can hold a single value (numeric or character). The C language demands that we declare the name of each variable that we are going to use and its type or class. ‘The programming language C has two main variable types : Local Variables © Local variables scope is confined within the block or function, where it is defined. Local variables must always be defined at the top of a block. © When a local variable is defined, it is not initialised by the system, we must initialise it ourself. © When executing of the block starts, the variable is available and when the block ends, the variable dies. computer Concepts Computer Language F xin() \ inti=4; it if§>0) { printf ("iis % d\n”, i); } if >0) { int i = 100; printf ("iis %d\n", i); } printf ("i is %d\n", i); ) This will generate the following output iis5 iis 100 iisS « Here, ++ is called incremental operator and it increase the value of any integer variable by 1. Thus, i++ is equivalent to i =i + 1; as well as i—be equivalent to i =H; Global Variables © Global variable is defined at the top of the program file and it can be visible and modified by any function that may reference it. * Global variables are initialised automatically by the system when we define them. « Ifsame variable name is being used for global and local variable then local variable takes preference in its scope. eg, inti=4; —_/* Global definition */ main() { int; /* Global variable */ fun(o); printf (“value of i= %d\n",i); inti=l0; —/* Local definition */ itt; /* Local variable */ printf (“value of i=%d \n”, i); ) e This will produce following result value of i=11 value of + iin main function is global and will be incremented to 5. in func is internal and will be incremented to 11. When control returns to main, the internal variable will die and any reference toi will be to the global. Functions * A function is a self-contained block of statements that perform a coherent task of some kind. Every ¢ program can be thought of as a collection of these functions. ‘© Making functions is a way of isolating one block of code from other independent blocks of code. Functions serve two purposes 1. They allow a programmer to say : this piece of code does a specific job which stands by itself and should not be mixed up with anything else. 2. They make a block of code reusable, since a function can be reused in many different contexts without repeating parts of the program text. © A function can take a number of parameters, do required processing and then return a value. There may be a function which does not return any value. ‘© When a function is defined at any place in the program then it is called function definition. At the time of definition of a function actual logic is implemented within the function. * A function declaration is usually declared at the top of, a C source file or in a separate header file. Passing Parameters to a Function There are two ways to pass parameters to a function : Pass by Value This mechanism is used when we don’t want to change the value of passed parameters. © When parameters are passed by value then function in C create copies of the passed variables and processing will be done on these copies variables. ass by Reference © This mechanism is used when we want a function to do the changes in passed parameters and reflect those changes back to the calling function. In this case, only addresses of the variables are passed toa function, so that function can work directly over the addresses, b) Structured Data Types Some structured data types are given below 1. Arrays 2. Structure 3. Union Arrays Anarray is a data structure, process multiple elements with the same data type. ‘+ Bach element of the array is given a number by which we can access that element. * For an array of 100 elements, the first element is 0 (zero) and the last is 99. This indexed access makes it very convenient to loop through each element of the array. eg 4. String #include main() { int af5]; printf (“value in array %d\n", ali); ) ) Output is value inarray0 —valueinarray1 —_value in array 2 value in array 3 value in array 4 Address of each element in an array Array elements occupy consecutive memory locations. #include main () ( int af5]; inti; for =0;i< 5; i++) O;i <5; it+) printf (“value in array %d and address is % lu\n", afi], & ali); } Prep Guide MAH-MCA CET Output is ‘Value in array 0 and address is 631656 value in array 1 and address is 631660 value in array 2 and address is 631664 value in array 3 and address is 631668 value in array 4 and address is 631672 Hence, in array the values are stored like this alo} aft} al2] al) 31656631660 631664 631668 ald] 631672 Multidimensional Array In C language, one can have arrays of any dimensions, To understand the concept of multidimensional arrays, let us consider the following 45 matrix Column number {j] Ocoee oleae Row number [i] | #0 | #1 | 42 | a3 | aos Tmo | a [me [as | ae 2,0 | aaa | 42.2 | 42.3 | ara 0 | aor | a2 [as | ase To access the particular element from the array we have to use two subscripts one for row number and other for column number. The notation is of the form afi]fj], where {stands for row subscripts and j stands for column sub-scripts. Thus, a[0}{0] refers to the first element of the two- dimensional array and so on and a[0]{0] is same as 4,9. Below given are some typical two-dimensional array definitions float table [50] [50]; char line [24] [40]; Alternatively, we can also define and initialise the array as follows int values [3] [4] 11,2,3,4) 5,6,7,8) {9, 10, 11, 12} i Here, the value in first pair of braces are initialised to elements of first row and so on. Pointers Pointers are widely used in programming ; they are used to refer to memory location of another variable without using variable identifier itself. They are mainly used in linked lists and call by reference functions. Computer Concepts Computer Language o Pointer Declaration Declaring pointers variable, we need to used ‘*’ operator (indirection /dereferencing operator) before the variable identifier and after data type. Syntax Datatype * variable; Simple variable is a normal variable that is used to store the value but pointer variable is used to store the address of any variable. eg, include int main( ) { chara char *ptr; printf ("%c\n", a); pir=&a; printf ("%p\n” , ptr); *ptr='d’; printf ("%ec\n”, a); return 0; } Output b 0014FB97 d Address Operator Address operator ({&) is used to get the address of the operand. For example, if variable x is stored at location 100 of memory; & x will return 100. x a if 5 and *a=éx,then 100 100 1000 (Variable x) (Pointer variable) Pointers and Functions Pointers can be used with functions. The main use of pointers is call by reference functions. Call by reference isa type of function that has pointer(s) (reference) as parameters to that function. All calculation of that function will be directly performed on referenced variables. eg, include 1, void doubleit (int *num) { Pointer variable 2.*num*=2; //*num=*num*2 } 3. int main () { 4. int number = 2; 5. doubleit (& number); //pass the address of variable 6, printt ("%d", number); 7. return 0; ) Output 4 Here in line 1, we are declaring ‘doubleit’ function. In line 4, the variable number is declared and initialised to 2. In line 5, the function ‘doubleit is called. Pointer to Arrays Array identifier is a pointer itself. Therefore, & notation should not be used with arrays. When working with arrays and pointers altoays remember the {following : 1, Never use & for pointer variable pointing to an array. 2. When passing array to function, we don’t need * for your declaration. Constant Pointers and Pointers to Constant Consider the following three declarations assuming that char_A has been defined asa type char variable 1. const char * myptr =& char_A; 2. char* const myptr =& char_A; 3. const char * const myptr = & char_A; ‘These are all three valid and correct declarations. Each assigns the address of char_A to a character pointer. Const char * myptr = char_A; This first declaration declares a pointer to a constant character. We cannot use this pointer to change the value being pointer to: eg, charchar_A=‘A’; const char * myptr=é char_A; *myptr="J; // error-can’t change value of 1/ sexypte Char *const myptr = & char_A; ‘The second declaration declares a constant pointer toa character, The location stored in the pointer cannot change, We cannot change, where this pointer points. eg, char char_A='A' char char. char * const myptr = & char_A; ‘myptr = & char_B; //error—can’t change adciress Prep Guide MAH-MCA CET © : Const char * const myptr = & char_A; ‘The third declaration declares a pointer to a character, where both the pointer value and the value being pointer at will not change. Strings In C language, strings are stored in an array of char type along with the null terminating character “\0” at the end. * In other words, to create a string in C, we create an array of chars and set each element in the array to a char value that makes up the string, ‘© When sizing the string array, we need to add plus one to the actual size of the string to make space for the null terminating character, “\0”. Syntax char fname [4]; '* The above statement declares a string called fname that can take upto 3 characters. It can be indexed just as a regular array as well. eg, frame[]=('t,'w, 0h, [Character [| t | w] 0 [ wo [acctcode | 6 [19 | a1 | 0 The last character is the null character having ASCIL value zero. + If we wanted to print a string from a variable, such as our fname string above we can do this. eg., printf (“First Name: %s”, fname); + We can insert more than one variable. Use %s to insert a string and then list the variables that go to each %s in our string, we are printing. Length of String ‘© Use the strlen function to get the length of a string ‘minus the null terminating character. Syntax int strlen (string); * If we had a string and called the strlen function on it we could get its length. eg, char fname [30] = ("Bob"); int length =strlen (fname); + This would set length to 3. Concatenation of Strings © The strcat function appends one string to another. Syntax char’ strcat (string 1, string 2); * The first string gets the second string appended tc for example, to print a full name from a first and last name string we could do the following char fname [30] = ("Bob"); char Iname [30] = |“by”); printf ("%s", strcat (fname, Iname)); ‘© The output to this snippet would be “Bobby”. Compare two Strings + Sometimes we want to determine if two strings are the same. For this we have the stremp function. Syntax int stremp (string 1, string 2); # The return value indicates how the two strings relate to cach other. If they are equal, stremp returns 0. ‘© The value will be negative if string 1 is less than string 2 or positive in the opposite case. Copy Strings To copy one string to another string variable, we use the strepy function. This makes up for not being able to use the “=” operator to set the value of a string variable. Syntax _strepy (string 1, string 2); Converting Uppercase Strings to Lowercase Strings ‘This function is not the part of ANSI standard. Syntax strlwr (string); Structure Structures in C are used to encapsulate or group together different data into one object. We can define a structure as shown below struct object { char id [20]; int xpos; int ypos; i ‘© The variables we declare inside the structure are called data members. Initialising a Structure * Structure members can be initialised when you declarea variable of your structure. Sample code struct object playerl = {“player 1”, 0, 0}; © The above declaration will create a struct object called player 1 with an id equal to “player 1”, xpos equal to 0 and ypos equal to 0. # To access the members of a structure, we use the “.” (scope resolution) operator. Sample code struct object player1; player 1. id = “player”; player 1.xpos =0; player L.ypos =0; EXERCISES = Chapter Challenges 41. A set of rules for telling the computer what operations to perform is called as (@) procedural language — (b) language (©) command language (4) programming language 2. Languages which can easily interact with the hardware are called (@) High level languages (b) Low level languages (c) Middle level languages (d) All of these 3. The use of combination of 1's and 0's is feature of which of the following type of computer language? (@) High level language (&) PASCAL (6) Machine language (@) COBOL 4, The function of an assembler is (a) to convert basic language into machine language (©) to convert high level language into machine language (© to convert assembly language into machine language (@) to convert low language into assembly level language 5. Computer programs when written in a high level programming language, the human readable version of a program is called as. (a) word size (b) Source code (©) instruction set () Application 6. Which of the following contains specific rules and words that express the logical steps of an algorithm? (a) Flow chart (b) Syntax of the programming language (6) Program (d) Logical chart 7. From the following statements choose the correct one {a) use of goto makes the debugging task easier (b) use goto when you want to jump out of a nested loop (©) use of goto enhances the logical clarity of a code (@) never use goto 8. The primary reason for developing C language was to treat it as a (a) system programming language (b) general purpose language (©) data processing language (a) None of the above 9. What is the difference between following declarations? extern int fun( ); (a) Both are identical (b) No difference, except exter int fun( ), is probably in another file (c) int fun( ); is overrided with extern int fun( ); (d) None of the above 2. int fun( ); 10. In the following program fragment, s, b are two +b; s=b-s D=b-s, What does it intend to do? (a) Transfer the contents of s to b (b) Transfer the contents of b tos (©) Exchange (swap) the contents of s and b (@) Negate the contents of s and b 11, From the following, choose the correct statement (@) An identifier may start with an underscore. (b) An identifier may end with an underscore. (© The number of significant characters in an identifier is implementation dependent. (d) All of the above 12, From the following, choose the correct statement (a) Constant expressions are evaluated at compile time (©) String constants can be concatenated at compile time (©) size of array must be known at compile time (d) All of the above 413. If we arrange the operators !,| |,<, =, in an ascending order of precedence, which of the following is the correct choice? @

You might also like