• C language

    Printing Hello World In C

    Here, the C program prints “Hello World!” in the output window. And, all syntax and commands in C programming are case sensitive. Also, each statement should be ended with semicolon (;) which is a statement terminator. Here, stdio.h is header file that contains all standard libraries for input and output. #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("Hello World!"); getch(); } OutPut : Hello World!  

  • Java

    Find The Area Of Circle And Triangle

    The formula to find area of circle :: 3.14 * radius * radius The formula to find area of triangle :: 0.5 * base * height Here, We are using two classes, one which contains main method and another one which contains the sub code. The area class contains two method one is circle() that is used to find the area of circle. It takes the radius from user using Scanner class, and the find the area as per the formula giver above. It takes value of PI is defined globally as Constant using final keyword. This method is called…

  • Java

    Find Reverse Number

    Here, First we take one number from user and assign it to temporary variable called temp. Now we execute on while loop until number is zero. Inside loop we get the last digit of the number by finding the reminder of the number by performing the modulus by 10, after that we append the digits with the formula rev=(rev*10)+reminder; first time the value of rev is 0. Now we remove last digit which is appended by performing division by 10. Now  when loop completely executed the variable rev gives use reverse number. import java.util.*; public class reverse { public static void…

  • Java

    Find Prime Number From 1 to n

    A Prime Number is a whole number greater than 1 whose only factors are 1 and itself. A factor is a whole numbers that can be divided evenly into another number. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29. Numbers that have more than two factors are called composite numbers. Let’s take the last range for find prime numbers. We start one loop for get numbers from 1 to length entered by user, and one another loop inside this parent loop which is stared from 2. The child loop is used to divide the parent number with all the lesser number…

  • Java

    Check Number Is Palindrome Or Not

    A Palindromic Number is a number that is the same when written forwards or backwards.The first few palindromic numbers are therefore are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, … etc.   Let’s take one number from user. Then assign it to another temporary variable for performing operation purpose. Now take this temporary variable and execute the loop till this temp variable is not zero. Inside this loop take last digit of the number by finding modulus of the number and store to another variable,…

  • Java

    Find Maximum From Three Number By Using Ternary Operator

    The Ternary Operator is an operator that takes three arguments. The first argument is a comparison argument, the second is the result upon a true comparison, and the third is the result upon a false comparison. If it helps you can think of the operator as shortened way of writing an if-else statement.   Let’s take three numbers from user. If the numbers are two then find maximum from that numbers are much easier by using Ternary Operator as formula int max = num1 > num2 ? num1 : num2; But we have three numbers, so that it is a…

  • Java

    Find Fibonacci Series Of 1 to n

    A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8,…. etc. Here first two numbers are 0 and 1 taking by us by default. These two numbers are printed manually as part of series. After that the for loop will be executed until the length entered by user minus two, so that the two numbers that we use manually are subtracted from length. Then it will perform addition of these two numbers and print that number as part of…