Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Keep entering numbers till user enters a multiple of 10, simple Java programming Code by Naymul Islam PCIU CSE 18

 import java.util.Scanner;


public class KeepEnteringNumbersTillUserEntersMultipleOf {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        do {

            System.out.println("Enter your Number : ");

            int num = sc.nextInt();


            if (num % 10 == 0) {

                break;

            }

            System.out.println(num);

        } while (true);


    }

}

import java.util.Scanner;

public class KeepEnteringNumbersTillUserEntersMultipleOf {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        do {
            System.out.println("Enter your Number : ");
            int num = sc.nextInt();

            if (num % 10 == 0) {
                break;
            }
            System.out.println(num);
        } while (true);

    }
}

Reverse the given number simple Java programming Code by Naymul Islam PCIU CSE 18

 import java.util.Scanner;


public class ReverseTheGivennNumber {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();


        int rev = 0;

        while (num > 0) {

            int lastDigit = num % 10;

            rev = (rev * 10) + lastDigit;

            num /= 10;

        }

        System.out.println(rev);

    }

}


import java.util.Scanner;

public class ReverseTheGivennNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        int rev = 0;
        while (num > 0) {
            int lastDigit = num % 10;
            rev = (rev * 10) + lastDigit;
            num /= 10;
        }
        System.out.println(rev);
    }
}

Print reverse of a number simple Java programming Code by Naymul Islam PCIU CSE 18

 import java.util.Scanner;


public class ReverseOfNumber {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in); // use for input from user

        int num = sc.nextInt();

        // int num = 10899;


        while (num > 0) {

            int lastDigit = num % 10;

            System.out.print(lastDigit);

            num = num / 10; // n/10;

        }

        System.out.println();

    }

}

import java.util.Scanner;

public class ReverseOfNumber {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in); // use for input from user
        int num = sc.nextInt();
        // int num = 10899;

        while (num > 0) {
            int lastDigit = num % 10;
            System.out.print(lastDigit);
            num = num / 10; // n/10;
        }
        System.out.println();
    }
}


Flag of Norway on C or C++ .cpp programming language by using c graphics library functions

 Write a C program to Draw the Flag of Norway.

Function Name :  Draw the Flag of Norway

Purpose :  In this Program we will learn how to draw the Norway flag on the output screen in c programming language by using c graphics library functions.

Code : 


#include<graphics.h> #include<conio.h> main() { int driver,mode; driver=DETECT; mode=0; initgraph(&driver,&mode,"c:\\tc\\bgi"); initgraph(&driver,&mode,""); setbkcolor(WHITE); setcolor(WHITE); rectangle(150,40,430,180); setfillstyle(1,RED); floodfill(160,50,WHITE); setfillstyle(1,WHITE); bar(150,90,430,130); setfillstyle(1,WHITE); bar(230,40,270,180); setfillstyle(1,BLUE); bar(150,100,430,120); setfillstyle(1,BLUE); bar(240,40,260,180); getch(); }



Output:

Max Sub Array Sum: Kadane's Algorithm

Code of: Max Sub Array Sum: Kadane's Algorithm. public class MaxSubArraySumKadanesALgorithm {     public static void Kadane ( int ...