Skip to main content

Posts

Showing posts from April, 2018

Get Even Numbers Using Java Stream API

Java Stream API — Even Numbers (Full Screen) Java Stream API — Get Even Numbers Example 1 — Filter even numbers from a list Creates a list, uses Stream to filter evens, and prints them. Copy import java.util.*; import java.util.stream.*; public class EvenNumbersStream { public static void main(String[] args) { // Create a list of numbers List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // Use Stream API to filter even numbers List<Integer> evenNumbers = numbers.stream() .filter(n -> n % 2 == 0) .collect(Collectors.toList()); // Print the even numbers System.out.println( "Even numbers: " + evenNumbers); } } Example 2 — Use IntStream.rangeClosed ...

Calculate Gross Salary

input: Basic Salary,DA and HRA (i.e. 6000,250,500 etc.) output: The Gross Salary will be printed on the screen. CODE----> #include<stdio.h> #include<conio.h> main() {        float basic, hra, da, pf, gross;        printf (" Enter Basic Salary : ");        scanf (" %f ",&basic);        printf (" \nEnter HRA : ");        scanf (" %f ",&hra);        printf (" \nEnter D.A. : ");        scanf (" %f ",&da);        /*pf = 10%*/        pf= (basic*10)/100;        printf ("\nPF = %f ",pf);        gross=basic+da+hra+pf;        printf ("\n\nGross Salary : %f ",gr...

Sum of two Integer numbers using function

In this C program we will calculate the summation of two numbers(int) using "Function" and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers(int). (i.e. 15,23 etc.) output: Summation of the given numbers(int) will be printed on the screen. CODE----> #include<stdio.h> #include<conio.h> #include<stdlib.h> int sum();     /* function declaration */ main()     /* main function */ {       int choice;       printf (" **********WELCOME**********\n\n ");       printf (" Please, select your choice.\n ");       printf (" 1.Addition(press 1, for addition)\n2.Exit(press 2,for quit)\n\n ");       printf (" Please, Enter your choice : ");       scanf (" %d ",&choice);       if( cho...