Function Argument Variables In C Programming Job Interview Question and Answers
http://ingenuitydias.blogspot.com/2015/11/function-argument-variables-in-c.html
1. What is the purpose of main() function?
Answer:-main() is the user-defined function. main() is the first function in the program, which gets called when the program executes. The startup code contains runmain() function, which calls main() function, we can't change the name of the main() function.
Function Programming In C
Programming Twenty Interview Questions
C Viva Questions for Engineering Freshers
Function And Pointers
2. What is an argument? Differentiate between formal arguments and actual arguments?
Answer:-The actual arguments are the arguments with which the function can be called. The formal arguments are the arguments with which the function can be defined. In simple words, function call contains actual arguments and function definition contains formal arguments.
3. What is the difference between character array and string in C?
Answer:-The major difference between the char array and the string is that the array will not end with the null, whereas string ends with the null.
4. Is it possible to print colors with printf statements?
Answer:-Yes, there are already ready made functions in header file conio.h
textcolor(5) will change the color to the pink. Similarly by changing the value we get different colors.
5. What is the type of the variable b in the following declaration?
#define FLOATPTR float*
FLOATPTR a, b;
a) float
b) float pointer
c) int
d) int pointer
Answer:-float-The statement FLOATPTR a,b; becomes float* a,b; Here "a" is a float pointer, but "b" is just an float variable, so the correct type for "b" is "float", and not "float-pointer". The above problem demonstrate the drawback of using #define constant. To avoid this situation use typedef's in place of #define.
6. How can you determine the maximum value that a numeric variable can hold?
Answer:-The correct way is to include <limits.h> and use the defined macros such as INT_MIN and INT_MAX, which define the minimum and maximum values, which the type can hold.In terms of designing your code, it helps to know that C imposes "minimum maximums" - e.g. a signed char must be able to hold _at least_ the values -127 to 127; a signed int must be able to hold _at least_ the values -32767 to 32767 and so forth.Be wary of assuming that because a type is N bits wide, it can store 2N-1 possible values; there is absolutely no guarantee this is true.
7. Why C is not platform dependent?
Answer:-Let us take example of Linux and Windows to explain this.
We say that C is platform dependent because
1. If you compile and build a C program code in windows, copy that .exe file to a Linux machine, that .exe file will not run there.
2. In the same way if you compile the same program code on Linux, you'll get a .out file which will not run on windows if directly copied there.
8. What is the maximum length of command line arguments including space between adjacent arguments?
Answer:- The C language standard does not impose any maximum on command line length / number of command-line arguments (not that I could find after a cursory search, anyway); the command-line shell is usually the limiting factor in this sort of thing.
9. Which one is correct answer?
10. Is it possible to write a C program without semicolons?
Answer:-
// Program For Finding Squar Of A NUmber
#define Squar(x) (x*x)
void main()
{
while (!printf("Squar Of 2 Is %d", Squar(2))) {
}
}
Answer:-main() is the user-defined function. main() is the first function in the program, which gets called when the program executes. The startup code contains runmain() function, which calls main() function, we can't change the name of the main() function.
Function Programming In C
Programming Twenty Interview Questions
C Viva Questions for Engineering Freshers
Function And Pointers
2. What is an argument? Differentiate between formal arguments and actual arguments?
Answer:-The actual arguments are the arguments with which the function can be called. The formal arguments are the arguments with which the function can be defined. In simple words, function call contains actual arguments and function definition contains formal arguments.
3. What is the difference between character array and string in C?
Answer:-The major difference between the char array and the string is that the array will not end with the null, whereas string ends with the null.
4. Is it possible to print colors with printf statements?
Answer:-Yes, there are already ready made functions in header file conio.h
textcolor(5) will change the color to the pink. Similarly by changing the value we get different colors.
5. What is the type of the variable b in the following declaration?
#define FLOATPTR float*
FLOATPTR a, b;
a) float
b) float pointer
c) int
d) int pointer
Answer:-float-The statement FLOATPTR a,b; becomes float* a,b; Here "a" is a float pointer, but "b" is just an float variable, so the correct type for "b" is "float", and not "float-pointer". The above problem demonstrate the drawback of using #define constant. To avoid this situation use typedef's in place of #define.
6. How can you determine the maximum value that a numeric variable can hold?
Answer:-The correct way is to include <limits.h> and use the defined macros such as INT_MIN and INT_MAX, which define the minimum and maximum values, which the type can hold.In terms of designing your code, it helps to know that C imposes "minimum maximums" - e.g. a signed char must be able to hold _at least_ the values -127 to 127; a signed int must be able to hold _at least_ the values -32767 to 32767 and so forth.Be wary of assuming that because a type is N bits wide, it can store 2N-1 possible values; there is absolutely no guarantee this is true.
7. Why C is not platform dependent?
Answer:-Let us take example of Linux and Windows to explain this.
We say that C is platform dependent because
1. If you compile and build a C program code in windows, copy that .exe file to a Linux machine, that .exe file will not run there.
2. In the same way if you compile the same program code on Linux, you'll get a .out file which will not run on windows if directly copied there.
8. What is the maximum length of command line arguments including space between adjacent arguments?
Answer:- The C language standard does not impose any maximum on command line length / number of command-line arguments (not that I could find after a cursory search, anyway); the command-line shell is usually the limiting factor in this sort of thing.
9. Which one is correct answer?
- C is a low level language
- C is a middle level language
- C is a high level language
10. Is it possible to write a C program without semicolons?
Answer:-
// Program For Finding Squar Of A NUmber
#define Squar(x) (x*x)
void main()
{
while (!printf("Squar Of 2 Is %d", Squar(2))) {
}
}
You have done very good job by creating collection for programming related Q&A.It will really help college going students and their Teachers alike.
ReplyDelete