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. |
History of C Language |
|
Answer» History of C LANGUAGE |
|
| 2. |
Constants C |
|
Answer» Constants C List of Constants in C![]() Different ways to define Constants in CThere are mainly 2 ways to define constant in C programming. (1)CONST keyword (2)#define preprocessor (1)const keywordThe const keyword is used to define constant in C programming. const float PI=3.14; Now below example is the use of const variable PI ![]() Output:- The value of PI is: 3.140000 Another example which use to change contsant value ![]() Output:- COMPILE Time Error: Cannot modify a const object (2)#define preprocessorThe #define preprocessor is also used to define constant. Syntax:- #define token value ![]() Output:- 3.140000 |
|
| 3. |
Install C Language |
|
Answer» Install C Language |
|
| 4. |
Escape Sequence C |
|
Answer» ESCAPE Sequence C Escape Sequence is composed of two or more characters which starts with backslash (" "). Escape sequence in C is a sequence of characters that which doesn't REPRESENT itself when USED inside string literal or character. Below image helps you to get LIST of all Escape Sequence:- ![]() Escape Sequences Example![]() Output:-
|
|
| 5. |
Format Specifier part2 |
|
Answer» Format Specifier part2 |
|
| 6. |
Format Specifier C |
|
Answer» Format Specifier C EXAMPLE for Format Specifier(1)Use of %d in C program In above example we use %d to print integer value of x and y Output:- Value of x is:2 Value of y is:4 (2)Use of %u in C program In above program we use %u to display value of x and y by USING unsigned format specifier. Here value of x is positive and for negative value it not print value of c and will change the value of -10.Output:- Value of x is:10 Value of y is:4294967286 (3)Use of %o in C program In above program we will get value of octal and integer for a specific common value.Output:- Octal Value of x is:100 Integer Value of x is:64 (4)Use of %X and %x in C program In above code y contains the hexadecimal value "A" and it is shown in two format ONE is "a" and another is "A" which is smaller and capital X. ANd when we use %d then it is shown in integer values.Output:- Hexadecimal Value of y is:a Hexadecimal Value of y is:A Integer Value of y is:10 (5)Use of %f in C program In above code will print value of y as floating upto 6 charactersOutput:- Floating point value of y is: 3.400000 (6)Use of %e in C program In above code output will be exponent part will be printOutput:- Exponential value of y is: 3.000000e+00 |
|
| 7. |
C Keyword |
|
Answer» C KEYWORD |
|
| 8. |
C Data Types |
|
Answer» C Data Types |
|
| 9. |
printf() and scanf() |
|
Answer» printf() and scanf() printf() functionWe used printf() function for output. And it will prints the given statement to the console. And below is the syntax of printf() function is given below:- ![]() The above formatstring can be %d, %c, %s and %f. Here we use %d for integer %c for character %s for string and %f for floats. scanf() functionWe used scanf() function for input in C language. It basically reads the DATA input from the console. ![]() Program to print square of any NUMBERHere in below example we gets input from user by scanf() function and after that we do square of number is print on console by printf() function ![]() Output:-input your number: 10 square of number is: 100 The scanf("%d",&number) statement reads integer number from the console and stores the given value in number variable. The printf("square of number is:%d ",number*number) statement prints the square of number on the console. Program to print sum of two numberHere in below example we have intialize 3 integer variable as int and in 2 we take input and 3rd one is store the result then we will print the 3rd variable with printf function ![]() Output:-Input FIRST number: 8 Input second number: 9 Sum of 2 number is: 17 |
|
| 10. |
Compilation in c |
|
Answer» Compilation in c |
|
| 11. |
Start C Program |
|
Answer» Start C Program |
|
| 12. |
C Comments |
|
Answer» C COMMENTS (1)Single Line CommentsHere in Single Line Comments which is REPRESENTED by double slash . In below EXAMPLE we have given example for single line comments.![]() Output:- Hello Welcome Here in above code we can also add comments in single line with code too as given below ![]() (2)Multi Line CommentsHere we will write multi line comments which is represented by slash asterisk * ..... * . Here this will occupy many lines of code. But it will not have nested syntax.![]() Output:- Hello Welcome |
|
| 13. |
Features of C |
|
Answer» Features of C |
|
| 14. |
ASCII Value C |
|
Answer» ASCII Value C Example for ASCII Character Input and Output![]() In above example PROGRAM will display ascii value of the charcter variable that we have input in the screen. First user will give the character input then values of that value get stored in the "ch" variable. Then after that it will print value of "ch" variable by USING %c format specifier and it will display "A" because we have given the charcter input as "A". If we use %d as format specifier then ascii value will be displayed as 65. Output Enter a characterA The ascii value of the ch variable is : 65 Example for ASCII Character from 0-255 value of all characters![]() In above program this will print ascii value of all characters from 0 to 255 through the for loop. Example for ASCII Character for Given input![]() In above code we will TAKE input from user and then convert all character from input to ASCII values. And this will also provide the sum of all character of string in "sum" variable. |
|
| 15. |
C Variables |
|
Answer» C Variables Rules to define variablesBelow are 4 most important rules when defining variables in C language:- (1)We can use alphabets, digits and underscore. (2)We can start variable with alphabet and underscore only. But it cannot start with a digit. (3)We cannot use WHITESPACE in variable name. (4)we cannot use variable name that is reserved WORD or keyword like int,float, char etc. valid variable names:- int a; int _xyz; int x20; Invalid variable names:- int 2; int a b; int long; |
|
| 16. |
Variables Types in C |
|
Answer» Variables Types in C (1)Local VariableWhen we declared variable inside the function or block is called a local variable. And we usually declared at the start of the block. ![]() We must have to initialize the local variable before it is used. (2)Global VariableWhen we declared variable outside function or block is called global variable. And any of function can change value of global variable. And it is available to all the functions. And we usually define at the start of the block. ![]() (3)Static VariableWhen we declare variable with static keyword is called static variable. It retains its value between multiple function calls. ![]() If we call function many times the local variable will print the same value for each and every function. In above EXAMPLE local variable alwasy remains 11. But when we declare static variable then it will be incremented in each function call 11,12,13 and so on. (4)Automatic VariableAll variables in C that are declared inside the block, are automatic variables by default. We can explicitly declare an automatic variable using auto keyword. ![]() (5)External VariableWhen we need to share a variable in multiple C source file then we need to use exteranl keyword. Below is the example to declare the EXTERN variable. Below we have define two file ONE to declare external variable. and in 2nd file we use external variable .
|
|
| 17. |
C Identifiers |
|
Answer» C Identifiers Rules for create C identifiersBelow are the mainly 7 rules for creating a c identifier these are given below:-(1)First character of an identifier should be either an ALPHABET or an underscore and then it is followed by any of the character, digit or underscore. (2)We cannot use numerical digit as first character or we cannot we cannot start this from alphanumeric. (3)We cannot use commas or blank spaces within an identifiers. (4)We cannot use keywords as an identifier. (5)There is LIMIT on identifiers and should not be more than 31 characters. (6)When we ask about identifiers both uppercase and lowercase are distinct. So we can say that identfiers are case sensitive. (7)We must write identifiers in such way that it is meaningful , short and easy to read and view. Valid identifiers Example totalval,sum,_a_,sum_1,average,view_1_d etc. Invalid identifiers Example 2sum (cannot start with numerical digit) int (Its a reserved word) char (Its a reserved word) m+n (Invalid character used "+") Types of identifiers(1)Internal Identifier(2)External Identifier (1)Internal Identifier:-As i have define above identifier that is not used in external linkage is known as internal identifier. And internal identifiers can be a local variables. (2)External Identifier:-This is ALSO define above when identifier is used in the external linkage then its known as an external identifier. Example of external identifiers can be a function name or we can say a global variables. Keyword and Identifier DifferenceThere are mainly 5 main differences between keyword and identifier are given below:- (1)Keyword is pre-defined word and identifier is user-define word. (2)Keyword must be written in lowercase letter and identifier can be written in both lowercase and in uppercase letters. (3)Keyword cannot contain the underscore character but identifiers can contain underscore. (4)Keyword meaning is pre-define in C compiler but identifier cannot be define in the c compiler. (5)Keyword is combination of alphabetical characters and identifier is combination of alphanumeric characters. Example of Identifier are case sensitive![]() Output of above code:- Value of a is : 10 Value of A is :20 In above example and output we have shows that value of both variable "a" and "A" are different that shows that identifiers are case sensitive. |
|
| 18. |
C Operators |
|
Answer» C Operators Precedence of Operators in CPrecedence of operator species that which operator will be evaluated first and next. Here associativity specifies the operator direction to be evaluated and it may be left to RIGHT or right to left. Below is the example which help us to understand the Precedence of Operators int value=10+30*10; The value variable will contain 310 here because (multiplicative operator) is evaluated before + (additive operator). The precedence and associativity of C operators is given below:
|
|
| 19. |
Introduction to C |
|
Answer» Introduction to C |
|