IT Questions and Answers :)

Friday, December 13, 2019

In C Based languages, which boolean operator can be used to simplify nested IF statements of the form IF ConditionA Then If ConditionB Then C

In C Based languages, which boolean operator can be used to simplify nested IF statements of the form IF ConditionA Then If ConditionB Then C

  • And Also
  • And
  • Or Else
  • Or 
In C Based languages, which boolean operator can be used to simplify nested IF statements of the form IF ConditionA Then If ConditionB Then C

EXPLANATION


In a 'C' program are executed sequentially. This happens when there is no condition around the statements. If you put some condition for a block of statements the flow of execution might change based on the result evaluated by the condition. This process is referred to as decision making in 'C.' The decision-making statements are also called as control statements.
In 'C' programming conditional statements are possible with the help of the following two constructs:
1. If statement
2. If-else statement
It is also called as branching as a program decides which statement to execute based on the result of the evaluated condition.

Share:

The GNU "bash" shell is named for:

The GNU "bash" shell is named for:

  • [B]ell Labs and [A]T&T
  • [B]rian Fox
  • [B]rian Kernighan and [A]lfred Aho
  • Stephen [B]ourne 

EXPLANATION

Bash is the shell, or command language interpreter, for the GNU operating system. The name is an acronym for the ‘Bourne-Again SHell’, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix.

Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). It offers functional improvements over sh for both interactive and programming use.

While the GNU operating system provides other shells, including a version of csh, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems - independently-supported ports exist for MS-DOS, OS/2, and Windows platforms.


 





Share:

Which of the following is NOT one of the benefits of High-Level Languages (HLL)?

Which of the following is NOT one of the benefits of High-Level Languages (HLL)?

  • It is simple to debug.
  • It is easy to understand.
  • High level language is less memory efficient.
  • It is programmer friendly language.

EXPLANATION

The main advantage of high-level languages over low-level languages is that they are easier to read, write, and maintain. Ultimately, programs written in a high-level language must be translated into machine language by a compiler or interpreter.
The first high-level programming languages were designed in the 1950s. Now there are dozens of different languages, including Ada, Algol, BASIC, COBOL, C, C++, FORTRAN, LISP, Pascal, and Prolog.


Any human-friendly language is a programmer-friendly language because programmers are human!
A language is friendly because it’s easy to learn and easy to use. This minimizes the cognitive load on the programmer. This allows the programmer to be very productive.
So here are the Top 5 most programmer-friendly languages:
  1. Smalltalk! See Richard Kenneth Eng's answer to Why hasn't anyone made a programming language that has super simple syntax unlike our current programming languages (like Python or Java) which have more complicated syntax?
  2. Go
  3. Elixir
  4. Scheme (or Racket)
  5. Python
Ruby is often-touted as programmer-friendly, but it’s definitely not so human-friendly.
Share:

Which of the following conditions is used to transmit two packets over a medium at the same time?

Which of the following conditions is used to transmit two packets over a medium at the same time?

  • Collision
  • Asynchronous
  • Contention
  • Synchronous 

EXPLANATION

A collision is the event in which two or more bodies exert forces on each other in about a relatively short time. Although the most common use of the word collision refers to incidents in which two or more objects collide with great force, the scientific use of the term implies nothing about the magnitude of the force.
In a half duplex Ethernet network, a collision is the result of two devices on the same Ethernet network attempting to transmit data at exactly the same time. The network detects the "collision" of the two transmitted packets and discards them both. Collisions are a natural occurrence on Ethernets.
Share:

On Linux, in additon to root, which users can read /etc/passwd, the password file? Pick the best answer.

On Linux, in addition to root, which users can read /etc/passwd? Pick the best answer.

  • Each user, but only their own entry in the file.
  • All users in group "shadow".
  • All users in group "wheel".
  • All users.

EXPLANATION

/etc/passwd file stores essential information, which required during login. In other words, it stores user account information. The /etc/passwd is a plain text file. It contains a list of the system’s accounts, giving for each account some useful information like user ID, group ID, home directory, shell, and more. The /etc/passwd file should have general read permission as many command utilities use it to map user IDs to user names. However, write access to the /etc/passwd must only limit for the superuser/root account.



The /etc/passwd File. /etc/passwd is a text file that contains the attributes of (i.e., basic information about) each user or account on a computer running Linux or another Unix-like operating system. Each line in /etc/passwd represents a single user.

 Quoting:  https://linux.die.net/man/5/passwd

"Name
passwd - password file
Description
The /etc/passwd file is a text file that describes user login accounts for the system.  It should have read permission allowed for all users (many utilities, like ls(1) use it to map user IDs to usernames), but write access only for the superuser."
The /etc/shadow file, which stores hashed passwords, can only be read by owner root, (and maybe members of group shadow, in some distributions):
$ ls  -lL /etc/shadow
-rw-r----- 1 root shadow 1266 Dec 19  2017 /etc/shadow
The "passwd" utility allows non-privileged users to run the utility with an effective ID of the file's owner, in this case root.  This means that non-privileged users can read and update the /etc/shadow file, via the "passwd" binary, when they change passwords.
ls -l $(which passwd)
-rwsr-xr-x 1 root shadow 51200 Sep 27  2013 /usr/bin/passwd
   ^
## ^ 
## "s" is the setuid bit. 



The setuid bit allows non-privileged users to run /usr/bin/passwd as the file's owner, root.
Note that in modern versions of Linux and Unix, the password file, /etc/passwd, does not contain passwords.  Rather, the second field of each line will have an "x", indicating that a hashed password is stored in /etc/shadow

SOURCE

https://linux.die.net/man/5/passwd

 


Share:

Popular Posts