October 13, 2018

Sreekanth B

Brocade Communications Most Frequently Asked C Language Interview Questions Answers

What is syntax error?

Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.

What are variables and it what way is it different from constants?

Variables and constants may at first look similar in a sense that both are identifiers made up of one character or more characters (letters, numbers and a few allowable symbols). Both will also hold a particular value.  Values held by a variable can be altered throughout the program, and can be used in most operations and computations. Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can assigned a constant named PI and give it a value 3.1415  .  You can then use it as PI in the program, instead of having to write 3.1415 each time you need it.

How do you construct an increment statement or decrement statement in C?

There are actually two ways you can do this. One is to use the increment operator ++ and decrement operator –. For example, the statement “x++” means to increment the value of x by 1. Likewise, the statement “x –” means to decrement the value of x by 1. Another way of writing increment statements is to use the conventional + plus sign or – minus sign. In the case of “x++”, another way to write it is “x = x +1″.
Brocade Communications Most Frequently Asked C Language Interview Questions Answers
Brocade Communications Most Frequently Asked C Language Interview Questions Answers

What is the difference between Call by Value and Call by Reference?

When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.

Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

Placing comment symbols /* */ around a code, also referred to as “commenting out”, is a way of isolating some codes that you think maybe causing errors in the program, without deleting the code. The idea is that if the code is in fact correct, you simply remove the comment symbols and continue on. It also saves you time and effort on having to retype the codes if you have deleted it in the first place.

What is the equivalent code of the following statement in WHILE LOOP format?

for (a=1; a<=100; a++)

printf ("%d\n", a * a);



while (a<=100) {

printf ("%d\n", a * a);



How do you access the values within an array?

Arrays contain a number of elements, depending on the size you gave it during variable declaration. Each element is assigned a number from 0 to number of elements-1. To assign or retrieve the value of a particular element, refer to the element number. For example: if you have a declaration that says “intscores[5];”, then you have 5 accessible elements, namely: scores[0], scores[1], scores[2], scores[3] and scores[4].

Can I use  “int” data type to store the value 32768? Why?

No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.

Can two or more operators such as \n and \t be combined in a single line of program code?

Yes, it’s perfectly valid to combine operators, especially if the need arises. For example: you can have a code like ” printf (“Hello\n\n\’World\'”) ” to output the text “Hello” on the first line and “World” enclosed in single quotes to appear on the next two lines.

Why is it that not all header files are declared in every C program?

The choice of declaring a header file at the top of each C program would depend on what commands/functions you will be using in that program. Since each header file contains different function definitions and prototype, you would be using only those header files that would contain the functions you will need. Declaring all header files in every program would only increase the overall file size and load of the program, and is not considered a good programming style.

When is the “void” keyword used in a function?

When declaring functions, you will decide whether that function would be returning a value or not. If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then “void” is to be placed at the leftmost part of the function header. When a return value is expected after the function execution, the data type of the return value is placed instead of “void”.

What are compound statements?

Compound statements are made up of two or more program statements that are executed together. This usually occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is evaluated. Compound statements can also be executed within a loop. Curly brackets { } are placed before and after compound statements.

Write a program to check Armstrong number in C?

int n,r,sum=0,temp;    //declaration of variables.
clrscr(); //It clears the screen.
printf("enter the number=");
printf("armstrong  number ");
printf("not armstrong number");
getch();  //It reads a character from the keyword.

Subscribe to get more Posts :