Tag: tutorials

Arithmetic Operators in C#

The following Arithmetic Operators are supported in C# + (Addition) – (Subtraction) / (Division) * (Multiplication) ++ (Increment) — (Decrement) % (Modulus) Below is a sample code snippet demonstrating the usage of Arithmetic operators in C#

Building a ASP.NET Web API in Visual Studio 2015

This blog post will explain on how to create a Simple ASP.NET Web API using Microsoft Visual Studio 2015 and return an expose a List (Eg: List<Students>) over HTTP. This includes creating action methods and using them for get all students and get a particular student by id. How to create a Web API in Visual Studio 2015 and return a List over HTTP? Follow…

Converting an Enum to Integer in C#

If you need to convert an enum to its numeric equivalent , you can simply cast the values to integer . Below is a sample code snippet that demonstrates how to do it. Converting an Enum to Integer in C#

How to convert Array to List in Java ?

This article will explain how to convert a simple array to list in Java . How to convert Array to List in Java ? The Java’s array class provides necessary methods to convert the array to the List using the asList method. Below is a sample code snippet demonstrating the usage of the Arrays.asList method to convert array to List.

Python Program to add two integers

Problem Write a program in Python to add two integers and display the result on the screen. Python Program to add two integers Output Enter first number: 1                                                                                                                                                         Enter second number: 2                                                                                                                                                                   1 + 2 = 3.0

Java – How to Read Integers from the Console for calculation ?

Problem Statement You need to read integers from the console window and use it for calculation within your java program. Solution If you want to know how to read integer value from a console and use it for calculation , you can use the Scanner class as shown below. The output of the above program is Please enter the first number for abundantcode 10 Please…

Java – How to create BigDecimal from string value ?

Problem Statement You want to create a BigDecimal value from a string type in Java. Solution Use the BigDecimal class and pass the string value in the constructor to create the BigDecimal value as shown below. The output of the above program is Abundantcode.com Java Tutorials 198654586.297292792

C Program to display the characters from A to Z

Problem Write a program in C to display all the characters from A to Z using Loop constructs. How to display Characters from A to Z using C Programming Language ? Output Abundantcode.com programming sample A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

For Each loop in Java

Java 5 brought in the support in the support for foreach loop that lets the developers to iterate over collections pretty easily. The syntax for the foreach loop in java looks like the one shown below. for (<datatype> item: collection) { // Process the item } For Each loop in Java Below is an example that demonstrates foreach loop in java. package com.abundantcode; import java.util.ArrayList;…

C Program to compute Quotient and Remainder

Problem Write a program in C to calculate the quotient and remainder and display it on the screen. How to compute quotient and remainder in C ? Output Enter dividend: 8                                      Enter divisor: 3                                   Quotient = 2                                          Remainder = 2

C Program to display Prime Numbers between two numbers

Problem Write a program in C to display all the prime numbers between a range of 2 numbers. How to display prime numbers between a range of 2 numbers in C ? Output Abundantcode.com coding sample   Enter Lower limit :5 Enter Upper limit :20       Prime numbers between 5 and 20 : 5 7 11 13 17 19

Java – How to convert String to Double in Java ?

Problem Statement You want to convert a string value to double in Java. Solution You can use one of the three approaches to convert a string to double in Java. 1. Assigning the string to the constructor of the Double class 2. Using Double.valueOf 3. Using Double.parseDouble The output of the above program is Abundantcode.com Java Tutorials 76.2 String to double using valueOf 76.2 string…

Java – How to read a valid Integer number from Console ?

Problem Statement You need to read a valid integer number from the Console in your java program. If the number is invalid , show appropriate message. Solution To read a valid integer from a console program , you can use the Scanner class and pass the System.in as the parameter to its constructor. The scanner class exposes a method called nextInt() which can be used…

Java – How to convert Long to other primitive numeric data types ?

Problem Statement You need convert a long value to other numeric data types in java. Solution Use the Long wrapper class which exposes methods like byteValue , shortValue , intValue etc. Below is a sample code snipper demonstrating the usage of the same. The output for the above program is Abundantcode.com Java Tutorials 76 76 76.0

Java – How to convert a double value to string ?

Problem Statement You need to convert a double value to string in your java program. Solution Use the toString() method defined in the Double class to convert a double value to string in java. The output of the above program is Abundantcode.com Java Tutorials 25.0