InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Find the bitwise complement of A=00001001, exclusive ORing of A=00101010 and B=10101100. |
|
Answer» Bitwise complement of A=00001001 is 11110110 and exclusive OR of 00101010 and 10101100 is 10000110. |
|
| 2. |
Write the range of values for a keyword int. |
|
Answer» Range for int is from (-2-16) to (216-1) i.e. -32768 to 32767. |
|
| 3. |
Briefly explain #define directive. |
|
Answer» #define directive is a compiler directive and not a statement. If this statement is included in the program at the beginning, then the pre-processor replaces every occurrence of the identifier in the source code by the constant/string. For example if the statement is #define rate 20 then in the program whenever variable rate is considered then it is always assigned with constant 20. |
|
| 4. |
Write the syntax for continue statement. |
|
Answer» The syntax for continue statement is |
|
| 5. |
What is C function? |
|
Answer» C function is a set of instructions to carry out a particular task. (sqrt(), sin(), pow()). |
|
| 6. |
What is a string constant? Give an example. |
|
Answer» String constant is a sequence of characters enclosed within a pair of double quotes. “Hello”, “Pre-University”, “IIPUC ELECTRONICS”, “2014”, “ASCII”. |
|
| 7. |
What is the use of a function conio.h? |
|
Answer» “conio.h” is a C header file used mostly by MS-DOS compilers to provide console input/ output. |
|
| 8. |
What are variables? Give an example. |
|
Answer» The quantity that changes during the execution of a program is a variable. Variables are the names given to identify the specific program elements. Variables are also called identifiers. Sum, height, mass, total, time etc. |
|
| 9. |
What does #include directive specify? |
|
Answer» #include directive specifies an external file containing functions or macro definitions which can be included as a part of a program. #include<stdio.h> includes standard function to perform input and output operations. |
|
| 10. |
Write the commonly used directive. |
|
Answer» # include<stdio.h> and #define pi 3.1415. |
|
| 11. |
Give an example each for valid variables and invalid variables. |
|
Answer» Valid variables: total, area_triangle, net_salary etc. For invalid variables: 2total, area-triangle, net salary etc. |
|
| 12. |
Briefly explain #include directive. |
|
Answer» #include directive specifies an external file containing functions or macro definitions which can be included as a part of a program. #include<stdio.h> includes standard function to perform input and output operations. |
|
| 13. |
Write the syntax for assigning values to variables. |
|
Answer» The syntax for assigning value to a variable is variable_name = value; (a = 5;) |
|
| 14. |
What are backslash constants? |
|
Answer» Backslash constants are combination of two characters in which first character is always a back slash (\) and the second can be any one of the characters a,b,f,n,r,t,v, “, \, 0. These are also called escape sequences. |
|
| 15. |
Name any six operations. |
|
Answer» Arithmetic, relational, logical, assignment, increment/decrement, conditional, bitwise, special operators. |
|
| 16. |
Write the steps involved in executing a C program. |
|
Answer» Steps involved in executing a C program are: (i) creating a program (ii) compiling the program (iii) linking the program with functions needed from C library and finally (iv) executing the program. |
|
| 17. |
Briefly explain syntax error. |
|
Answer» Syntax error is the result of violating the grammar of C programming language. When these errors occur, computer display an error message specifying the line number where the error has occurred. In the program segment a = 20, b = c; computer will indicate semicolon is missing. |
|
| 18. |
What is a syntax error? |
|
Answer» The syntax errors are due to the violation of syntax (grammar rules of programming language). |
|
| 19. |
What is a logical error? |
|
Answer» Logical errors occur during the coding process, when the type of the data is wrongly selected and is used for computation. [int a,b,sum; printf(“\n enter the two numbers”); scanf(“%d%d”,&a,&b); sum = a + b; printf(“\nsum is%d”,b);] |
|
| 20. |
What is debugging a C program? |
|
Answer» The process of detecting and correcting errors in the program is debugging. |
|
| 21. |
What is a statement? |
|
Answer» Statement is an instruction to a computer to perform a specific operation. |
|
| 22. |
What is a C pre-processor? |
|
Answer» C pre-processor is a program that processes the source code before it passes through the compiler. |
|
| 23. |
If a=3, b=5 and c=6, find a && b || c || (!b) && (!c). |
|
Answer» a=3, b=5 and c=6, a= 011, b=101 , c=110. a && b || c ||(!b) && (!c): (011&&101)||(110)||(010)& &(001) = 0011| 110||000 = 111= 7. |
|
| 24. |
What is a Function? |
|
Answer» A Function is a subroutine that may include one or more statements designed to perform a specific task. |
|
| 25. |
Write the arithmetic operator used to represent remainder obtained in integer division. |
|
Answer» % (modulus) operator is used to represent the remainder obtained in integer division. |
|
| 26. |
What is the meaning of a%b? Find the value of 21%4. |
|
Answer» a%b always results in the remainder of division a/b. The value of 21%4 is 1. |
|
| 27. |
Write the C equivalent expression for (2x+1)(3y+2z) |
|
Answer» (2*x+1)*(3*y+2*z) |
|
| 28. |
What is the use of logical operator? |
|
Answer» Logical operators are used to make decisions The results of these operations are either true or false. |
|
| 29. |
What is an operator? |
|
Answer» Operator is a symbol that tells the computer to perform certain arithmetic or logical operations. |
|
| 30. |
Write ten basic structure of C programming (overview). |
||||||
|
Answer» C program may contain one or more sections. Overview of a C program.
|
|||||||
| 31. |
If A = 1, and B = 0, what is the value of A Λ B? |
|
Answer» 1 Λ 0 = 1 (1 XOR 0 = 1). |
|
| 32. |
Why is C programming language suitable for both systems and applications programming? |
|
Answer» C programming combines the features of high level language with the elements of assembler, hence it is suitable for both systems and applications programming. |
|
| 33. |
What is C programming language? |
|
Answer» C is a powerful, flexible, portable and structured programming language. |
|
| 34. |
If a = 25 and b = 6, find(i) a+b(ii) a - b(iii) a * b(iv) a/b(v) a%b(vi) -a%b(vii) a%-b |
|
Answer» a = 25 and b = 6. |
|
| 35. |
How does the monitor display 28.689 for statementi) printf (“%5.3f”,p);ii) printf(“%e”,y); |
|
Answer» i) 28.689 ii) 2.8689e+01 |
|
| 36. |
What is the difference between “=” and “= =”? |
|
Answer» “=” is an assignment operator whereas “= =” is an arithmetic operator. |
|
| 37. |
Write the features of C. |
|
Answer» C is a powerful, flexible language that has gained worldwide acceptance in recent years. C is concise, yet powerful in its scope. It is a high-level language that also incorporates features of low-level languages. It is becoming the standard for program development on small machines and microcomputers. It is possible to apply C to nearly all application areas. Modularity (process of dividing problems into sub-problems) makes C ideal for projects involving several programmers. C permits nearly every programming technique. C is widely available for most brands and type of computers. It is portable. With all the features C is not a difficult language, it is one of the easiest languages to learn and implement. C programming can be used to write any complex program because of its rich set of built-in functions and operations. C compiler combines the capabilities of an assembly language with the feature of high-level language and therefore it is very much suited for uniting both system software and business packages. Because of its variety of data types, powerful operator programs in C are efficient and fast. C has the ability to extend, it means user-defined functions can also be added to C library. |
|
| 38. |
Briefly explain loop control statement. |
|
Answer» Program loop consists of two segments (i) Body of the loop and (ii) Control statement. The test condition should be carefully stated in order to perform the desired number of loop execution. Test condition should transfer the control out of the loop as the condition false other wise control sets up an infinite loop. A looping process would include Setting & initialization of a counter, Execution of the statement in the loop, Test for the specified condition for execution of the loop and Updating the counter. The C language provides three loop constructs for performing loop operation The While statement, The do-while statement and The for statement. |
|
| 39. |
Write the syntax for multi dimensional arrays. |
|
Answer» Type array name [size1] [size2] [size3]…………. [size n]. |
|
| 40. |
Write the syntax of for statement. |
|
Answer» The syntax of for statement is |
|
| 41. |
Mention different conditional control statements. |
|
Answer» Different conditional statements are if statement, if-else, nested if-else and switch statement. |
|
| 42. |
What is the description of the following operator “Λ=”? |
|
Answer» “Λ=” represents bitwise XOR assignment operator. ( c = c Λ b or c Λ = b;) |
|
| 43. |
How will the number x=:286 displayed on the monitor? |
|
Answer» If the statement is printf(“% d”,x); then it displays 998, instead if the statement is printf(“% f’,x); then it displays 9.98286e02. |
|
| 44. |
What is use of break statement? Write its syntax. |
|
Answer» Break statement is used to terminate the loop and exit from a particular switch case label. Syntax for break is ——————— |
|
| 45. |
Write the rules for forming a variable name. |
|
Answer» (i) Variable name consists of Setters, digits & underscore (_) (ii) Must begin with a letter. Some systems permit an underscore as the first character. (iii) ANSI standard recognizes a length of 31 characters. However, the length should not be normally more than 8 characters, since only the first eight characters are treated significant by the compiler. (iv) Uppercase and lowercase are significant, ie TOTAL is not same as total or (v) Variable name should not be a keyword. (vi) White space is not allowed. Example: Valid: temp, avg, sum1 ,total, ph value, T_raise, mark, i, j Invalid: 123,25th 5times, (area) abc$ char, int, group one abc-5 |
|
| 46. |
Write the syntax of do while statement. |
|
Answer» The syntax of do while statement is |
|
| 47. |
Where is a conditional operator used? |
|
Answer» Conditional operator is used to test the relation between two variables. |
|
| 48. |
What does the following sign represent? |
|
Answer» ‘- -‘ represent decrement operator. |
|
| 49. |
What are the rules used while writing subscripts? |
|
Answer» Rules for subscripts are: (i) each subscript must be an unsigned positive integer constant or an expression (ii) subscript of a subscript is not permitted (iii) maximum subscript appearing in a program for a subscripted variable should not exceed the declared one (iv) subscript value ranges from 0 to one less than the maximum size. If an array has three elements then subscript can be 0,1,2. |
|
| 50. |
Mention the different sections that appear in C programming. |
|
Answer» Documentation section, link section, definition section, Global declaration section, Function section, subgroup Section are the different sections that appear in C programming. |
|