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.



January 28, 2020

Top 20 PowerShell Interview Questions & Answers


Ques: 1. What do you understand by PowerShell?

Ans: With PowerShell, you can control your system operations such as accessing data storage, registry, and file system. PowerShell is a command-line tool built upon the .NET framework to help the windows system administrator. The operations in the command line are executed by cmdlets. Cmdlets are .NET classes to implement operations in the PowerShell.

It also has a good expression parser and a scripting language to control and automate the administration of the windows system. This open-sourced tool was developed by Microsoft and released in 2006.




Ques: 2. What is $null in PowerShell?

Ans: The $null is a variable in the PowerShell that is used to represent NULL as the name suggests. It can be assigned to a variable, use it for comparisons, etc. In PowerShell, $null is an object that holds the value of NULL. To assign $null, use the following command

PS> $null –eq $variable
Here, the $variable holds the value of $null.


Ques: 3. Can you explain String Interpolation in PowerShell?

Ans: The String Interpolation is the way of displaying the value of the variable by surrounding the variable in the double-quotes.
//example

$var = “Nature”
Echo “the value is $var”

The above statement produces the ‘value is Nature’. Here the $var is surrounded by double quotes when used in the echo statement. So, it prints the value of the variable instead of the variable name itself. It is called string interpolation.


Ques: 4. What are cmdlet's in PowerShell?

Ans: The PowerShell cmdlet (Command let) is just a group of commands that are used in the PowerShell to perform a function. It is a lightweight .NET framework class object that is invoked by the PowerShell runtime. Programmers can create and invoke it manually too. You can construct your cmdlet by grouping a few lines of PowerShell code. The cmdlet has a .ps1 extension.


Ques: 5. How to call a function in powershell?

Ans: To call a function in PowerShell, first, you have to declare the function using the function keyword. Then to call the function, just type and enter the function name.
//example

function functionName {
$args[0] - $args[1]
}
PSC:\>functionName 10 5 5
You can also pass arguments to the called function as you see in the example above.


Ques: 6. What are Filters in PowerShell?

Ans: A lot of commands in the PowerShell return values that are not always useful. To get useful return objects from the commands we can use filters. Filters can be created using the Filter parameter or even using the Where-Object. We can use the Filter parameter with the Get-ChildItem to get the items that we specified in the filter.

//example
PS> Get-ChildItem -Path C:\folder\ -Filter '*1*.txt'

The above command filters and returns the files with a prefix as ‘1’. The same result can be achieved using the Where-Object, but generally, the filter is much faster than the Where-Object.


Ques: 7. What are $Home and $PID in PowerShell?

Ans: The $HOME is an automatic variable in the PowerShell. It contains the path of the user’s home directory. It is equivalent to C:\Users\. The $PID is also an automatic variable that contains the process identifier of the process which is hosting the PowerShell’s current session.


Ques: 8. Is PowerShell’s Execution Policy a security layer?

Ans: No. The execution policy in PowerShell is part of the security strategy but merely prevents potentially malicious scripts being executed by accident and, with the ‘ allsigned ‘ policy ensures that scripts cannot be altered without your knowledge. By default, this setting is set to ‘ Restricted ‘, meaning that no PowerShell script file can be run but it will execute PowerShell code within the PowerShell console.


Ques: 9. What is $Error and $ForEach variable?

Ans:

$Error – This variable contains an array of error objects which represents the most recent errors. The most recent error is the first error in the array.

$ForEach – This variable contains the enumerator (should not be confused with the resulting values) of a for each loop. Properties and methods of enumerators can be used on the value of the $ForEach variable. This kind of variable exists only while the for each loop is in running state, and it is deleted once the loop is completed.


Ques: 10. Explain Execution Policies and types of Execution Policy?

Ans: This is the common PowerShell Interview Questions asked in an interview. There are 6 types of execution policies in PowerShell. These are:-
  • Restricted: This is the default type. Under this, PowerShell will not run any script including PowerShell profiles too.
  • RemoteSigned: PowerShell will only run any script that is created locally. Any script that has been coming from the Internet should be digitally signed with a signing certificate code and is trusted by the computer.
  • AllSigned: PowerShell will only run any script that has been digitally signed using a trusted code signing certificate.
  • Unrestricted: PowerShell will run any script. If the script comes from an untrusted source, users are prompted once to execute it.
  • Bypass: This policy will run any script without any question or prompt.
  • Undefined: There is no execution policy set for this in the current scope.

Ques: 11. What is the PowerShell order in which execution policy is evaluated?

Ans: Windows PowerShell has execution policies in the following order of precedence: 
  • Group Policy: Example is Computer Configuration.
  • Group Policy: Example is User Configuration.
  • Execution Policy: Such as Process (or PowerShell.exe -Execution Policy) – which is the CURRENT SCOPE.
  • Execution Policy: Such as Current User – Which is SAVED in the HKCU registry.
  • Execution Policy: Such as Local Machine – which is SAVED in the HKLM registry.

Ques: 12. Can you explain the differences between the concept of WMI between old and new?

Ans:
Old WMI
  • Uses old-style native code providers and a repository for itself.
  • Available only on Windows as mentioned.
  • It has been more or less deprecated which means it’s is not focused on further improvement or development.
New WMI
  • Supports old-style native code providers and a repository, as well as new-style MI providers as discussed.
  • Available only on Windows as mentioned.
  • This is the way forward. It has an essentially stateless relationship with the remote machine.

Ques: 13. What are the various Differences between OMI and CIM.?

Ans:
OMI
  • It uses WS-MAN where OMI code includes the protocol stack od WS-MAN. It supports only new-style MI providers.
  • It is available on any implementing platform. If something can talk to OMI, it will be able to talk to NEW WMI as well.
CIM
  • It defines the standard. It is created by DMTF.
  • In this case, early versions were implemented as OLD WMI actually by Microsoft, but the newest version implemented both in NEW WMI and OMI by Microsoft as well as others.

Ques: 14. What are the differences among WinRM and WSMan and DCOM?

Ans:
 
WSMan: 
  • WS-Management abbreviated as WSMAN or Web Services-Management is basically a Distributed Management task force.
  • It is an open standard which defines a SOAP-based (full form Simple Object Access Protocol) protocol for the management of its servers, devices, applications and also various Web services.
WinRM:
  • WinRM is a feature which came from Windows Vista and it allows administrators to remotely run management scripts.
  • It can handle remote connections using the WS-Management Protocol.
DCOM:
  • DCOM means Distributed COM.
  • It is used to connect LIVE objects which are on the remote machine.
  • The RPC protocol that it uses was designed for continuous back-and-forth messaging.
  • It is network and memory inefficient.

Ques: 15. What are Scriptblocks?

Ans: Scriptblocks are one of most Powerful concept of PowerShell. By definition, is a collection of statements or expressions between “{” and “}” that can be used as a single unit. It can be stored in a variable, can be passed to function and can be executed remotely by the operator “&”

Syntax :
{<statement list>}
Like functions, a scriptblock can include parameters :
              {
            param ([type]$parameter1 [,[type]$parameter2])
           

And script blocks can include the DynamicParam, Begin, Process, and End keywords.

 
Ques: 16. What is Variable Interpolation?

Ans: When you add a variable to a double-quoted string, PowerShell replaces the variable name by its value. This feature is called variable interpolation.
              $HighOne = "Love"
"The most powerful Emotion is $HighOne" 

Output:

PS C:\Users\Administrator>
$HighOne = "Love"
"The most powerful Emotion is $HighOne"
"The most powerful Emotion is Love
PS C:\Users\Administrator>


Ques: 17. What is the {0} -f that I saw in some string codes?

Ans: This is string formatting using the PowerShell format operator. In PowerShell, you do not need to use “+” operator to concatenate strings. Actually is more in-tune with PowerShell syntax if you use interpolation or the -f (from format)

It is simple. You add the placeholder {N} and then type a command-separated list of values in order to be replaced. {0} represents the first value in the command-separated list, {1} the second and so on.


Ques: 18. What is a hash table in PowerShell?

Ans: Hash table is a data structure which used the mechanism of value/key pair. The professionals who create PowerShell scripts use variables to store data. For the storage of data in a highly secure environment hash table is used.


Ques: 19. How is Windows Powershell different from Stsadm ?
Ans: Unlike stsadm, which accept and return text, Windows PowerShell is built on the Microsoft .NET Framework and accepts and returns .NET Framework objects. In addition to that it also gives you access to the file system on the computer so that you can access registry,digital signature certificate etc.


Ques: 20. How Do You Comment Out Code In Powershell?
Ans: Like other languages powershell also supports single/Inline comments line and multi line comments.

Starting with PowerShell V1 there’s only # to make the text after it a comment.

In PowerShell V2 “<# #>” can be used for block comments (multi-line) and more specifically for SYNOPSIS, DESCRIPTION, NOTES, LINK help comments.

Example: Sinlgle/Inline comments
 # This is a single or inline comment starts with hash in Powershell

Example: Block comments (multi-line)
<# this is a first line of comment
 this is a second line of comment
this is a third line of comment
.
.
this is a last line of comment
#>


Top 20 Internet of Things (IOT) Interview Questions & Answers


Ques: 1. Why does the need of Internet of Things (IoT) arises?

Ans: The real value of the IoT is not about making the lights turn on or off when the vehicle reaches its parking bay, rather the data that the connected devices gather about its users. The data collected later can allow the consumers, businesses, and connected cities to work in a more efficient manner. 

Internet of Things (IoT) is a network of interconnected objects that uses embedded technology to sense and communicate with their internal states or the external environments. IoT is all about connecting the objects (devices) over the Internet and enabling them to interact with us and other objects.


Ques: 2. What are the main components of the Internet of Things (IoT) system?

Ans: IoT has three main components are as follows:

  • Devices embedded with sensors. 
  • Network connectivity 
  • Data storage application/system


Ques: 3. How does IoT differ from the IIoT?

Ans: 
Internet of Things(IOT): In this system, the connection is between devices and gadgets that are used by average consumers in their day-to-day life. Examples could be washing machines, refrigerators, electrical bulbs, etc. These devices are connected to the Internet and work according to the way they are programmed to and prompted to.

Industrial Internet of Things (IIoT): With IIoT, massive industrial items and systems are connected via the Internet to carry out functions without human intervention. The alarm systems in hospitals or the automatic shutting off of switches in industrial plants are examples of IIoT.


Ques: 4. Do you have any relatable examples of the way in which IoT impacts our everyday lives?

Ans: Since IoT’s primary aim is to connect devices and make them function intuitively according to the needs of the situation; they are used in a variety of devices that we use in our daily lives, which help us coordinate functions better. We no longer have to spend extra time to manually handle these devices, which means a lot of time saved.

Since connectivity with other devices is at the heart of the concept of IoT. IoT - enabled devices not only carry out their function in isolation, but also coordinate with others in the network to make work a lot more efficient than earlier devices could. For instance, while a standalone alarm clock can only wake you up, in an IoT ecosystem, based on your early morning traits, IoT could also heat the coffee decoction for you or put the geyser on.


Ques: 15. What importance does cybersecurity have for IoT?

Ans: Cybersecurity is a matter of serious concern wherever the Net is involved. So, with its heavy reliance on the Internet, the IoT is sure to make cybersecurity a very crucial area of its work. 

Corporations and governments will have to be on their toes in anticipating and preventing cyber attacks on the IoT. This calls for a very strongly coordinated, robust response from all the players involved because a disruption in any link in the chain can throw the whole ecosystem out of gear.


Ques: 16. Assess the impact the IoT will have on the healthcare sector

Ans: The IoT is extremely well-suited for the healthcare sector. With its ability to coordinate large volumes of data seamlessly and across devices; the IoT can be a great facilitator for the healthcare industry. At a micro level, it will help to generate a lot of data from the health-conscious user, such as pulse, blood pressure, calorie count, etc. from individual users. At the macro level, it will make tele-medicine a lot more efficient by being able to coordinate data across devices in far-flung locations.


Ques: 17. What do you understand by the Internet of Everything and what are the elements that go into it?

Ans: The Internet of Everything (IoE) can be understood as an extension of the IoT. While the IoT connects devices with one another, IoE aims at connecting devices with people and help them take smart decisions by coordinating with them. These are some of the elements that go into IoE:

Human beings: The IoE facilitates higher and smoother coordination between humans and devices such as social networks, computers, healthcare gadgets, teaching aids, etc.

Procedure: This aspect of the IoE seeks to automate processes that go into most things managed by humans, ranging from handheld devices to large industrial manufacturing processes.

Things: This is the set of devices or things used by humans that connect to the Net and help share information. sensors, actuators, certain types of medical devices or meters can be examples of things in IoE.

Information: Obviously, this is at the center of the IoE, as much as it is in the IoT. Algorithms function smartly to help make sense of the huge loads of data that devices and other things generate.


Ques: 18. What influences will the internet of things (IoT) have on monetary growth?

Ans: Several monetary analyses have anticipated that the IoT will make contributions extensively to monetary growth over the following decade, however, the predictions range substantially in magnitude. The modern-day international iot market has been valued at approximately $2 trillion, with estimates of its predicted fee over the following five to ten years varying from $4 trillion to $11 trillion.


Ques: 19. What are the elements of the Internet of Everything?
Ans: 
Human beings: People will continue to attach through gadgets, like smartphones, computers, and drugs, in addition to social networks, which includes FaceBook and LinkedIn.

Procedure: This includes evolving era, business, organizational and different tactics in order to be wished in an effort to control and, to a massive extent, automate the explosive growth in connections and the resultant accumulation, analysis and conversation of information with a view to be inevitable inside the internet of the entirety.

Things: It consists of many physical objects like sensors, meters, actuators, and other styles of gadgets that can be connected to any item, that are or can be capable of connecting to the community and sharing statistics. These items will sense and supply more facts, respond to manipulate inputs, and provide more statistics to assist human beings and machines make choices.

Information: Today, devices commonly accumulate statistics and circulate it over the internet to a valuable source, in which it is analyzed and processed. Such statistics is predicted to surpass today’s biggest social media data set by means of every other order of importance.


Ques: 20. What is Bluetooth Low Energy (BLE) Protocol for an Internet of Things (IoT)?
Ans: Nokia originally introduced this protocol as wibree in 2006. Additionally known as Bluetooth smart this protocol presents the same range coverage with a good deal of decreased strength intake because of the unique Bluetooth. It has comparable bandwidth with narrow spacing as utilized by Zigbee. Low electricity latency and decrease complexity makeable greater appropriate to include into low-cost microcontrollers.