Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

August 09, 2020

Top 20 C language Interview Questions & Answers

 

Ques: 01. Why is C language being considered a middle level language?

Ans: This is because C language is rich in features that make it behave like a high level language while at the same time can interact with hardware using low level methods. The use of a well structured approach to programming, coupled with English-like words used in functions, makes it act as a high level language. On the other hand, C can directly access memory structures similar to assembly language routines.


Ques: 02. What are preprocessor directives?

Ans: Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, Explain Which would depend on Explain What functions are to be used in the program. Another use of preprocessor directives is the declaration of constants.Preprocessor directives begin with the # symbol.


Ques: 03. Where does global, static, and local, register variables, free memory and C Program instructions get stored?

Ans: Global: Wherever the linker puts them. Typically the ―BSS segment on many platforms.Static: Again, wherever the linker puts them. Often, they‘re intermixed with the globals. The only difference between globals and statics is whether the linker will resolve the symbols across compilation units.Local: Typically on the stack, unless the variable gets register allocated and never spills.Register: Nowadays, these are equivalent to ―Local variables. They live on the stack unless they get register-allocated.


Ques: 04. What are header files and Explain What are its uses in C programming?

Ans: Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program. Simply put, commands that you use in C programming are actually functions that are defined from within each header files. Each header file contains a set of functions. For example: stdio.h is a header file that contains definition and prototypes of commands like printf and scanf.


Ques: 05. What does the format %10.2 mean when included in a printf statement?

Ans: This format is used for two things: to set the number of spaces allotted for the output number and to set the number of decimal places. The number before the decimal point is for the allotted space, in this case it would allot 10 spaces for the output number. If the number of space occupied by the output number is less than 10, addition space characters will be inserted before the actual output number. The number after the decimal point sets the number of decimal places, in this case, it?s 2 decimal spaces.


Ques: 06. Describe about storage allocation and scope of global, extern, static, local and register variables?

Ans:Globals have application-scope. They‘re available in any compilation unit that includes an appropriate declaration (usually brought from a header file). They‘re stored wherever the link erputs them, usually a place called the ―BSS segment. Extern? This is essentially ―global. 

Static: Stored the same place as globals, typically, but only available to the compilation unit that contains them. If they are block-scope global, only available within that block and its subblocks.

Local: Stored on the stack, typically. Only available in that block and its subblocks.(Although pointers to locals can be passed to functions invoked from within a scope where that local is valid.)

Register: See tirade above on ―local vs. ―register. The only difference is that the C compiler will not let you take the address of something you‘ve declared as ―register.
 

Ques: 07. Describe the order of precedence with regards to operators in C.

Ans: Order of precedence determines Explain Which operation must first take place in an operation statement or conditional statement. On the top most level of precedence are the unary operators !, +, – and &. It is followed by the regular mathematical operators (*, / and modulus % first, followed by + and -). Next in line are the relational operators <, <=, >= and >. This is then followed by the two equality operators == and !=. The logical operators && and || are next evaluated. On the last level is the assignment operator =.


Ques: 08. What is output redirection?

Ans: It is the process of transferring data to an alternative output source other than the display screen. Output redirection allows a program to have its output saved to a file. For example, if you have a program named COMPUTE, typing this on the command line as COMPUTE >DATA can accept input from the user, perform certain computations, then have the output redirected to a file named DATA, instead of s Explain Howing it on the screen.


Ques: 09. What is a far pointer? Where we use it?

Ans: In large data model (compact, large, huge) the address B0008000 is acceptable because in these model all pointers to data are 32bits long. If we use small data model(tiny, small, medium) the above address won‘t work since in these model each pointer is 16bits long. If we are working ina small data model and want to access the address B0008000 then we use far pointer. Far pointer is always treated as a 32bit pointer and contains a segment address and offset address both of16bits each. Thus the address is represented using segment : offset format B000h:8000h. For any given memory address there are many possible far address segment : offset pair. The segment register contains the address where the segment begins and offset register contains the offset of data/code from where segment begins.


Ques: 10. Explain What is the difference between the expression “++a” and “a++”?

Ans: In the first expression, the increment would happen first on variable a, and the resulting value will be the one to be used. This is also known as a prefix increment. In the second expression, the current value of variable a would the one to be used in an operation, before the value of a itself is incremented. This is also known as postfix increment.


Ques: 11. What is the difference between functions getch() and getche()?

Ans: Both functions will accept a character input value from the user. When using getch(), the key that was pressed will not appear on the screen, and is automatically captured and assigned to a variable. When using getche(), the key that was pressed by the user will appear on the screen, while at the same time being assigned to a variable.


Ques: 12. What are macros? What are its advantages and disadvantages?

Ans: Macros are abbreviations for lengthy and frequently used statements. When a macro is called the entire code is substituted by a single line though the macro definition is of several lines.The advantage of macro is that it reduces the time taken for control transfer as in case of function. The disadvantage of it is here the entire code is substituted so the program becomes lengthy if a macro is called several times.


Ques: 13. What is an endless loop?

Ans: An endless loop can mean two things. One is that it was designed to loop continuously until the condition within the loop is met, after Explain Which a break function would cause the program to step out of the loop. Another idea of an endless loop is when an incorrect loop condition was written, causing the loop to run erroneously forever. Endless loops are oftentimes referred to as infinite loops.


Ques: 14. Why is it that not all header files are declared in every C program?

Ans: The choice of declaring a header file at the top of each C program would depend on Explain 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.


Ques: 15. Difference between pass by reference and pass by value?

Ans: Pass by reference passes a pointer to the value. This allows the callee to modify the variable directly.Pass by value gives a copy of the value to the callee. This allows the callee to modify the value without modifying the variable. (In other words, the callee simply cannot modify the variable, since it lacks a reference to it.)


Ques: 16. What is dynamic data structure?

Ans: Dynamic data structure provides a means for storing data more efficiently into memory. Using dynamic memory allocation, your program will access memory spaces as needed. This is in contrast to static data structure, wherein the programmer has to indicate a fix number of memory space to be used in the program.


Ques: 17. What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

Ans: The most probable reason behind this error is that the header file for that function was not indicated at the top of the program. Header files contain the definition and prototype for functions and commands used in a C program. In the case of ?tolower()?, the code ?#include ? must be present at the beginning of the program.


Ques: 18. What will be the outcome of the following conditional statement if the value of variable s is 10?

Ans: s >=10 && s < 25 && s!=12 The outcome will be TRUE. Since the value of s is 10, s >= 10 evaluates to TRUE because s is not greater than 10 but is still equal to 10. s< 25 is also TRUE since 10 is less then 25. Just the same, s!=12, Explain Which means s is not equal to 12, evaluates to TRUE. The && is the AND operator, and follows the rule that if all individual conditions are TRUE, the entire statement is TRUE.


Ques: 19. What is FIFO?

Ans: In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using FIFO format, or First-In-First-Out. A queue represents a line wherein the first data that was stored will be the first one that is accessible as well.


Ques: 20. What are enumerated types?

Ans: Enumerated types allow the programmer to use more meaningful words as values to a variable. Each item in the enumerated type variable is actually associated with a numeric code. For example, one can create an enumerated type variable named DAYS whose values are Monday, Tuesday… Sunday.



December 02, 2019

Top 20 PHP Interview Questions and Answers



Ques: 1) What is CAPTCHA?

Answer: 

CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent spammers from using bots to automatically fill out forms, CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it.

 

BlockChain interview Questions and Answers

 

Ques: 2) What is meant by urlencode() and urldecode()?

Answer:

string urlencode(str)

When str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normally used to append data for GET like someurl.com?var=hello%world

string urldocode(str)

This will simple decode the GET variable’s value. Example: echo (urldecode($_GET_VARS[var])) will output “hello world”

 

C language Interview Questions and Answers

 

Ques: 3) What is difference between mysql_fetch_array(), mysql_fetch_row() and mysql_fetch_object()?

Answer:

mysql_fetch_array - Fetch the all matching records of results.

mysql_fetch_object - Fetch the first single matching record of results.

mysql_fetch_row - fetches a result row as array.

 

C++ language Interview Questions and Answers

 

Ques: 4) What is difference between srand & shuffle?

Answer:

The srand function seeds the random number generator with seed and shuffle is used for shuffling the array values.

shuffle - This function shuffles (randomizes the order of the elements in) an array. This function assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys.

srand - Seed the random number generator

 

Machine Learning Interview Questions and Answers

 

Ques: 5) How do you capture audio/video in PHP?

Answer:

You need a module installed - FFMPEG. FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed under Linux, but it can be compiled under most operating systems, including Windows.

 

MySQL Interview Questions and Answers

 

Ques: 6) What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading?

Answer:

Move: This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.

Copy: Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise.

 

PowerShell Interview Questions and Answers

 

Ques: 7) What is the difference between echo and print?

Answer:

Main difference between echo() and print() is that echo is just an statement not a function and doesn't return's value or it just prints a value whereas print() is an function which prints a value and also it returns value.

We cannot pass arguments to echo since it is just a statement whereas print is a function and we can pass arguments to it and it returns true or false. print can be used as part of a more complex expression whereas echo cannot. echo is marginally faster since it doesn't set a return value.

 

Python Interview Questions and Answers

 

Ques: 8) What is the difference between require() and include()?

Answer:

Both of these constructs includes and evaluates the specific file. The two functions are identical in every way except how they handle failure. If filepath not found, require() terminates the program and gives fatal error, but include() does not terminate the program; It gives warning message and continues to program.

include() produces a Warning while require() results in a Fatal Error if the filepath is not correct.

 

Python Pandas Interview Questions and Answers


Ques: 9) How do we know properties of the browser?

Answer:

You can gather a lot of information about a person's computer by using $_SERVER['HTTP_USER_AGENT']. This can tell us more about the user's operating system, as well as their browser. For example I am revealed to be Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3 when visiting a PHP page.

This can be useful to programmers if they are using special features that may not work for everyone, or if they want to get an idea of their target audience. This also is important when using the get_browser() function for finding out more information about the browser's capabilities. By having this information the user can be directed to a version of your site best suited to their browser.

get_browser() attempts to determine the capabilities of the user's browser. This is done by looking up the browser's information in the browscap.ini file.

echo $_SERVER['HTTP_USER_AGENT'] . "<hr />\n";

$browser = get_browser();

foreach ($browser as $name => $value)  { echo "<b>$name</b> $value <br />\n";

 }

 

SQL Server Interview Questions and Answers

 

Ques: 10) What is difference between require_once(), require(), include(). Because all these function are used to call a file in another file.

Answer:

Difference between require() and require_once(): require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).

So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.

There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().

 

Unix interview Questions and Answers

 

Ques: 11) What are the different types of errors in PHP?

Answer:

1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although you can change this default behavior.

2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.

 

C# Language Interview Questions and Answers

 

Ques: 12) How to Create a Cookie & destroy it in PHP?

Answer:

setcookie(”variable”,”value”,”time”);

variable - name of the cookie variable variable - value of the cookie variable time - expiry time

Example: setcookie(”test”,$i,time()+3600);

Test - cookie variable name

$i - value of the variable ‘Test’ time()+3600 - denotes that the cookie will expire after an one hour.

Destroy a cookie by specifying expiry time

Example: setcookie(”test”,$i,time()-3600); // already expired time

Reset a cookie by specifying its name only

setcookie(”test”);

 

CSS (Cascading Style Sheets ) Interview Questions and Answers

 

Ques: 13) What is the difference between the functions unlink and unset?

Answer:

unlink is a function for file system handling. It will simply delete the file in context. unset will set UNSET the specified variable.

unlink is used to delete a file. unset is used to destroy an earlier declared variable.

 

Robotic Process Automation(RPA) Interview Questions and Answers

 

Ques: 14) How do you know (status) whether the recipient of your mail had opened the mail i.e. read the mail?

Answer:

Embed an URL in a say 0-byte image tag may be the better way to go. In other word, you embed an invisible image on you html email and when the src URL is being rendered by the server, you can track whether your recipients have view the emails or not.

 

UX Design Interview Questions and Answers

 

Ques: 15) What is difference between mysql_connect and mysql_pconnect?

Answer:

mysql_connect opens up a database connection every time a page is loaded. mysql_pconnect opens up a connection, and keeps it open across multiple requests.

mysql_pconnect uses less resources, because it does not need to establish a database connection every time a page is loaded.

 

Docker Interview Questions and Answers

 

Ques: 16) What do you need to do to improve the performance (speedy execution) for the script you have written?

Answer:

If your script is to retrieve data from Database, you should use "Limit" syntax. Break down the non dynamic sections of website which need not be repeated over a period of time as include files.

 

Google Cloud Computing Interview Questions and Answers

 

Ques: 17) How do you insert single & double quotes in MySQL db without using PHP?

Answer: 

By using &amp; / &quote;

Alternately, escape single quote using forward slash \' . In double quote you don't need to escape quotes. Insert double quotes as "".

 

Azure Interview Questions and Answers

 

Ques: 18) What is the difference between strstr & stristr?

Answer:

For strstr, the syntax is: string strstr(string $string,string $str ); The function strstr will search $str in $string. If it finds the string means it will return string from where it finds the $str upto end of $string.

For Example:

$string = "http://yahoomail.com"; $str="yahoomail";

The output is "yahoomail.com". The main difference between strstr and stristr is of case sensitivity. The former consider the case difference and later ignore the case difference.

 

Linux Interview Questions and Answers

 

Ques: 19) What is the difference between explode and split?

Answer:

Split function splits string into array by regular expression. Explode splits a string into array by string.

For Example:

explode(" and", "India and Pakistan and Srilanka"); split(" :", "India : Pakistan : Srilanka");

Both of these functions will return an array that contains India, Pakistan, and Srilanka.

 

Data Science Interview Questions and Answers

 

Ques: 20) How can you avoid execution time out error while fetching record from MySQL?

Answer:

set_time_limit -- Limits the maximum execution time

For Example:

set_time_limit(0);

If you set to 0 you say that there is not limit.

 

Edge Computing Interview Questions and Answers

 


More Interview Questions and Answers:


Hadoop Technical Interview Questions and Answers

 

Hyperion Technical Interview Questions and Answers

 

Internet of Things (IOT) Interview Questions and Answers

 

C# Language Interview Questions and Answers