Differences Between Pure Aloha and Slotted Aloha

Kiran Kumar Panigrahi
Updated on 02-Sep-2023 15:32:54

57K+ Views

The Aloha Protocol allows several stations to send data frames over the same communication channel at the same time. This protocol is a straightforward communication method in which each network station is given equal priority and works independently.Aloha is a medium access control (MAC) protocol for transmission of data via a shared network channel. Using this protocol, several data streams originating from multiple nodes are transferred through a multi-point transmission channel.There are two types of Aloha protocols − Pure Aloha and Slotted Aloha.In Pure Aloha, the time of transmission is continuous. Whenever a station has an available frame, it sends ... Read More

Determine if a Number is Odd or Even in JavaScript

Shubham Vora
Updated on 02-Sep-2023 15:30:06

44K+ Views

In this tutorial, let’s see how to determine whether a number is odd or even using JavaScript. The first step is understanding the logic. What are even numbers? Even numbers will be exactly divisible by 2. The remainder will be zero. What are odd numbers? Odd numbers will carry a remainder when divided by 2. Using the if-else Condition and Modulo Operator "if" will check a condition, and the if block code will be executed if the condition is true. If the condition is false, else block code will be executed. The modulo operator in JavaScript returns the remainder. Syntax ... Read More

Convert Integer to String in C#

karthikeya Boyini
Updated on 02-Sep-2023 15:26:43

45K+ Views

To convert an integer to string in C#, use the ToString() method.Set the integer for which you want the string −int num = 299;Use the ToString() method to convert Integer to String −String s; int num = 299; s = num.ToString();ExampleYou can try to run the following code to convert an integer to string in C# −Live Demousing System; class MyApplication {    static void Main(string[] args) {       String s;       int num = 299;       s = num.ToString();       Console.WriteLine("String = "+s);       Console.ReadLine();    } }OutputString = 299

Calculate Transpose of a Matrix Using C Program

Mandalika
Updated on 02-Sep-2023 15:21:37

53K+ Views

Transpose of a matrixThe transpose of a matrix is the one whose rows are columns of the original matrix, i.e. if A and B are two matrices such that the rows of the matrix B are the columns of the matrix A then Matrix B is said to be the transpose of Matrix A.The logic used to change m(i, j) matrix to m(j, i) is as follows −for (i = 0;i < m;i++)    for (j = 0; j < n; j++)       transpose[j][i] = matrix[i][j];Program 1In this example, we shall print the transpose of a matrix using for ... Read More

Measure Execution Time for a Java Method

Maruthi Krishna
Updated on 02-Sep-2023 15:19:24

62K+ Views

In general, the elapsed time is the time from the starting point to ending point of an event. Following are various ways to find elapsed time in Java −The currentTimeMillis() method returns the current time in milliseconds. To find the elapsed time for a method you can get the difference between time values before and after the execution of the desired method.The nanoTime() method returns the current time in nano seconds. To find the elapsed time for a method you can get the difference between time values before and after the execution of the desired method.The now() method of the ... Read More

Get the Full Path of a File in Linux

Kunal Verma
Updated on 02-Sep-2023 15:16:41

43K+ Views

Abstract Every file and folder in Linux has a path that directs the user to it. This path is required for programs and scripts to locate and access files. There are various ways to locate the path to a file or folder if you need to. We can get a full file path with different commands on a Linux machine. In other words, if its arguments were supplied, this command would return the pathnames of the files that would be run in the current context. In this tutorial, we'll show you how to obtain a file's complete path in Linux. ... Read More

Find 2nd Largest Number in an Array in Java

Samual Sam
Updated on 02-Sep-2023 15:09:09

83K+ Views

To find the second largest element of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the second element from the end of the array.ExampleLive Demopublic class ThirdLargestNumberInAnArray {    public static void main(String args[]){       int temp, size;       int array[] = {10, 20, 25, 63, 96, 57};       size = array.length;       for(int i = 0; i

Convert StringBuilder to String in Java

Maruthi Krishna
Updated on 02-Sep-2023 15:06:14

59K+ Views

The toString() method of the StringBuilder class reruns String value of the current object. To convert a StringBuilder to String value simple invoke the toString() method on it.Instantiate the StringBuilder class.Append data to it using the append() method.Convert the StringBuilder to string using the toString() method.ExampleIn the following Java program we are converting an array of Strings to a single String using the toString() method of the StringBuilder. Live Demopublic class StringToStringBuilder {    public static void main(String args[]) {       String strs[] = {"Arshad", "Althamas", "Johar", "Javed", "Raju", "Krishna" };       StringBuilder sb = new StringBuilder(); ... Read More

C# int.TryParse Method

karthikeya Boyini
Updated on 02-Sep-2023 14:17:10

75K+ Views

Convert a string representation of number to an integer, using the int.TryParse() method in C#. If the string cannot be converted, then the int.TryParse() method returns false i.e. a Boolean value.Let’s say you have a string representation of a number.string myStr = "12";Now to convert it to an integer, use the int.TryParse(). It will get converted and will return True.int.TryParse(myStr, out a);Example Live Demousing System.IO; using System; class Program {    static void Main() {       bool res;       int a;       string myStr = "12";       res = int.TryParse(myStr, out a);   ... Read More

Float and Double in C

karthikeya Boyini
Updated on 02-Sep-2023 14:14:10

56K+ Views

FloatFloat is a datatype which is used to represent the floating point numbers. It is a 32-bit IEEE 754 single precision floating point number (1-bit for the sign, 8-bit for exponent, 23*-bit for the value. It has 6 decimal digits of precision.Here is the syntax of float in C language, float variable_name;Here is an example of float in C language, Example Live Demo#include #include int main() {    float x = 10.327;    int y = 28;    printf("The float value : %f", x);    printf("The sum of float and int variable : %f", (x+y));    return 0; }OutputThe float value ... Read More

Advertisements