C Interview Questions
Untitled Document
Ques-1 : What is output of printf("%d")?
- Ans - 1 : printf("%d",x) prints the value of x whereas printf("%d") will print any garbage value on output screen.
Ques-2 : What is difference between sprintf() & printf()?
- Ans - 2 : sprintf() writes data to character array whereas printf() writes data to standard ouput.
Ques-3 : how can u tell whether linked list is linked or nested?
- Ans - 3 : If last node of linked list points to the first node of same linked list then linked lis is said to be circular.
Ques-4 : What is the difference between call by value & call by reference?
- Ans - 4 : Duuring call by value, the value of variable as parameter is sent to function whereas call by reference sends address of variable.So, changes made to variable inside the called function will not bring any change to original variable in call by alue but it changes the value of origianal variable in call by reference mode.
Ques-5 : what is the use of '\0' character?
- Ans - 5 : It means terminating null character & used to show the end of string value.
Ques-6 : What is nested loop?
- Ans - 6 : Loop that runs inside another loop is said to be nested loop.
Ques-7 : What is the difference between = & == operators?
- Ans - 7 : Operator = is used in mathematical operations whereas operator == is a relational operator which is used for verifying relations.
Ques-8 : Compare compiler 7 interpreter?
- Ans - 8 : Interpreters often deal with executing of program codes one line at a time while compilerb takes the program as a whole & convert it into object code before executing.
Ques-9 : What is the advantage of array over individual characters?
- Ans - 9 : When storing multiple related data, it is good idea to use arrays as they will be declared using 1 word only rather than using different variables for different values.
Ques-10 : What's wrong with this statement
scanf("%d",marks)?
- Ans - 10 : An ampersand symbol ( &) must be placed before variable name marks so that value entered by user is stored at the right address.
Ques-11 : What are logical & syntax errors?
- Ans - 11 : Programs containing logical errors tend to pass compilation process but resulting output may not be expected one. This happens when wrong formula is inserted into code whereas Syntax errors deal with incorrect commands that are mispelled or not recognized by compiler.
Ques-12 : Can if function be used to compare strings?
- Ans - 12 : No, if commands can only be used to compare numerical values & single characters but not strings.
Ques-13 : Why is C a middle level language?
- Ans - 13 : C is a middle level language because it is rich in features that make it bhave like high level language but at same time it can interact with hardware using low level methods.
Ques-14 : What are preprocessor directives?
- Ans - 14 : These preprocessor directives are placed at beginning of every program where library files are specifired . They start with # symbol & also used for declaration of constants.
Ques-15 : What's wrong with
myname = "deepanshu"?
- Ans - 15 : We cannot assign strings or names with help of = operator whereas
strcpy(myname,"deepanshu")
should be used to serve this purpose.
No comments:
Post a Comment
Guys if you think something is wrong or should be edit than please do comment.