Skip to main content

Posts

Showing posts from November, 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 ...

Hello World in PYTHON

In this PYTHON program we will print "Hello World !!!" in the screen. input: Null. output: "Hello World !!!" will be printed on the screen. CODE----> print (" Hello World !!!\n ") input (" Press, \"Enter\" to close the window.... ") #this line is used for holding the screen. ##Remove it, if getting an error. Don't just read, write it, run it..... RESULT :

Division in C++ Language(integer division) without and with Class

In this C++ program we will calculate the division between two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,05 etc.) output: Devision between the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,div; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; div=a/b; cout << "\nThe result is : " <<a <<" / " <<b <<" = " << div << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class div { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp (...

Multiplication of two numbers in C++ Language without and with Class

In this C++ program we will calculate the multiplication of two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,05 etc.) output: Multiplication of the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,mul; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; mul=a*b; cout << "\nThe multiplication of the Numbers is : " << mul << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class multi { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { int c ; c = x * y ; cout ...

Calculate the difference(subtraction) between two numbers in C++ Language without and with Class

In this C++ program we will calculate the difference(subtraction) between the two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,65 etc.) output: difference between the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,sub; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; sub=a-b; cout << "\nThe difference between the Numbers is : " << sub << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class differ { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { int c ; c...

Sum of two numbers in C++ Program without and with Class

In this C++ program we will calculate the sum of the two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,65 etc.) output: Sum of the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,sum; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; sum=a+b; cout << "\nThe sum of the Numbers is : " << sum << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class sum { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { int c ; c = x + y ; cout << "\nThe Sum of th...

C++ program to print " Hello world !!! "

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

C-program to Convert the octal number into decimal and Vice-Versa

In this C -program we will Convert the Octal Number into Decimal number and Decimal Number into Octal Number. The number will be taken from the user. input: The number.(i.e : 5,6,9[Decimal Number] or 12,57,567[Octal Number] etc.) output: Octal number will be converted into Decimal number OR Decimal number will be converted into Octal number. CODE----> #include<stdio.h> #include<conio.h> #include<math.h> main() { int oct_num,oct,dec_num,dec,remainder,i,n; printf(" ***************Welcome to Converter*************** "); printf(" \n\n\n1.Octal to Decimal\n\n2.Decimal to Octal\n\n Enter Your choice : "); scanf(" %d ",&n); switch( n ) { case 1 : printf(" \nPlease, Enter the Octal number : "); scanf(" %d ",&oct_num); oct=oct_num; i=0; dec=0; while( oct_num!=0 ) { remainder=oct_num%10; dec=dec+remainder*pow( 8 , i ); i++; oct_num=oct_num/10; } printf(" \nThe decimal of...

C-program to find Prime numbers between a range

In this C -program we will find Prime numbers between a range. The range will be taken from the user. input: The lower range and the upper range . output: We will print the Prime numbers between the range . CODE----> #include<stdio.h> #include<conio.h> main() { int range1,range2,change,i,j,flag; printf(" \n\n Enter the range 1 : " ); scanf(" %d ",&range1); printf(" \n Enter the range 2 : "); scanf(" %d ",&range2); if( range1 > range2 ) { change=range1; range1=range2; range2=change; } //if user enter the higher range first. if ( range1==1 ) range1++; //because 1 is not a prime number. printf(" \n\n The prime numbers between %d and %d are : ",range1,range2); while ( range1 ) { i=range1; flag=0; for ( j=2 ; j<=(i-1) ; j++ ) { if ( i%j==0 ) flag=flag+1; } if ( flag==0 ) printf(" %d ",i); range1++; } getch(); } Don...