Skip to main content

Posts

Showing posts from July, 2017

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 ...

Basic float division in C language

In this C -program we will take two floats(decimal number) as input from user and print the result(division). input: Two numbers(i.e : 5.7,6.8,3.5 etc.) output: Division of the two numbers CODE----> #include<stdio.h> int main () { float a , b , div ; printf ( "Enter two numbers: " ); scanf ( "%f%f" ,& a ,& b ); div = a / b ; printf ( "The result is = %f" , div ); return 0 ; } Download the C-Program file of this Program. Don't just read, run on your pc !!! RESULT : Enter two numbers: 100 12.8 The result is = 7.812500 -------------------------------- Process exited after 5.158 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic float multiplication in C language

In this C -program we will take two floats(decimal number) as input from user and print the result(multiplication). input: Two numbers(i.e : 5.7,6.8,3.5 etc.) output: Multiplication of the two numbers CODE----> #include<stdio.h> int main () { float a , b , mul ; printf ( "Enter two numbers: " ); scanf ( "%f%f" ,& a ,& b ); mul = a * b ; printf ( "The result is = %f" , mul ); return 0 ; } Download the C-Program file of this Program. Don't just read, run on your pc !!! RESULT : Enter two numbers: 7.8 4.5 The result is = 35.100002 -------------------------------- Process exited after 6.321 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic float subtraction in C language

In this C -program we will take two floats(decimal number) as input from user and print the result(subtraction). input: Two numbers(i.e : 5.7,6.8,3.5 etc.) output: Subtraction of the two numbers CODE----> #include<stdio.h> int main () { float a , b , sub ; printf ( "Enter two numbers: " ); scanf ( "%f%f" ,& a ,& b ); sub = a - b ; printf ( "The result is = %f" , sub ); return 0 ; } Download the C-Program file of this Program. Don't just read, run on your pc !!! RESULT : Enter two numbers: 145.5 45.5 The result is = 100.000000 -------------------------------- Process exited after 8.129 seconds with return value 0 Press any key to continue . . . Images for better understanding : 7

Basic float addition in C language

In this C -program we will take two floats(decimal number) as input from user and print the result(sum). input: Two numbers(i.e : 5.7,6.8,3.5 etc.) output: Sum of the two numbers CODE----> #include<stdio.h> int main () { float a , b , sum ; printf ( "Enter two numbers: " ); scanf ( "%f%f" ,& a ,& b ); sum = a + b ; printf ( "The result is = %f" , sum ); return 0 ; } Download the C-Program file of this Program. Don't just read, run on your pc !!! RESULT : Enter two numbers: 14.5 16.5 The result is = 31.000000 -------------------------------- Process exited after 10.05 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic integer division in C language

In this C -program we will take two integers(decimal number) as input from user and print the result(division). input: Two numbers. output: Division of the two numbers(integers). CODE----> #include<stdio.h> int main () { int a , b , div ; printf ( " Enter two numbers (dividend first) : " ); scanf ( "%d%d" ,& a ,& b ); div = a / b ; printf ( "\n The result is = %d" , div ); return 0 ; } Download the C-Program file of this Program. Don't just read, write it, run it..... RESULT : Enter two numbers (dividend first) : 45 5 The result is = 9 -------------------------------- Process exited after 26.88 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic integer multiplication in C language

In this C -program we will take two integers(decimal number) as input from user and print the result(multiplication). input: Two Numbers. output: Multiplication of the two numbers(integers). CODE----> #include<stdio.h> int main () { int a , b , mul ; printf ( " Enter two numbers : " ); scanf ( "%d%d" ,& a ,& b ); mul = a * b ; printf ( "\n The result is = %d" , mul ); return 0 ; } Download the C-Program file of this Program. Don't just read, write it, run it..... RESULT : Enter two numbers : 10 7 The result is = 70 -------------------------------- Process exited after 34.79 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic integer subtraction in C language

In this C -program we will take two integers(decimal number) as input from user and print the result(difference). input: Two Numbers(integers). output: Difference of the two numbers. CODE----> #include<stdio.h> int main () { int a , b , sub ; printf ( " Enter two numbers : " ); scanf ( "%d%d" ,& a ,& b ); sub = a - b ; printf ( " The result is = %d" , sub ); return 0 ; } Download the C-Program file of this Program. Don't just read, write it, run it..... RESULT : Enter two numbers : 1000 500 The result is = 500 -------------------------------- Process exited after 41.11 seconds with return value 0 Press any key to continue . . . Images for better understanding :

Basic Integer Addition in C language

In this C -program we will take two integers(decimal number) as input from user and print the result(sum). input: Two numbers(integers). output: Sum of the two numbers. CODE----> #include<stdio.h> int main () { int a , b , sum ; printf ( " Enter two numbers : " ); scanf ( "%d%d" ,& a ,& b ); sum = a + b ; printf ( "\n The result is = %d" , sum ); return 0 ; } Download the C-Program file of this Program. Don't just read, write it, run it..... RESULT : Enter two numbers : 45 100 The result is = 145 -------------------------------- Process exited after 31.76 seconds with return value 0 Press any key to continue . . . Images for better understanding :

"Hello world !" in c language

In this C-program we will print " Hello world !!! " on the screen. input: NULL. output: " Hello World !!! " will be printed on the screen. CODE----> #include<stdio.h> int main () { printf ( " Hello world !!! " ); return 0 ; } Download the C-Program file of this Program. Don't just read, run on your pc !!! RESULT : Hello world !!! -------------------------------- Process exited after 0.1719 seconds with return value 0 Press any key to continue . . . Images for better understanding : Also on Youtube :