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 ...
In this C program we will copy the contents of a string into another without strcpy()fuction. The String will be given by the User.
Learn about different string functions and their use: Different String Functions
input:
The String.output:
The input string and the copied string will be printed on the screen.
CODE---->
#include<stdio.h>
#include<string.h>
int main()
{
int n=0;
char source_str[100],target_str[100];
printf("Please, Enter a string: ");
gets(source_str);
while(source_str[n]!='\0')
{
target_str[n]=source_str[n];
n++;
}
target_str[n]='\0';
printf("\nThe source string is: ");
puts(source_str);
printf("\nThe copied string is: ");
puts(target_str);
return 0;
}
Download the C-Program file of this Program.
RESULT :
Please, Enter a string: Please, Follow Us too... ProgramJoy Loves You. The source string is: Please, Follow Us too... ProgramJoy Loves You. The copied string is: Please, Follow Us too... ProgramJoy Loves You. -------------------------------- Process exited after 32.89 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Using Function :
#include<stdio.h>
#include<string.h>
void STRCPY(char *t,char *s)
{
while(*s!='\0')
{
*t=*s;
s++;
t++;
}
*t='\0';
}
int main()
{
char source_str[100],target_str[100];
printf("Please, Enter a string: ");
gets(source_str);
STRCPY(target_str,source_str);
printf("\nThe source string is: ");
puts(source_str);
printf("\nThe copied string is: ");
puts(target_str);
return 0;
}
Download the C-Program file of this Program.
RESULT :
Please, Enter a string: Please, SUBSCRIBE to ProgramJoy The source string is: Please, SUBSCRIBE to ProgramJoy The copied string is: Please, SUBSCRIBE to ProgramJoy -------------------------------- Process exited after 30.45 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Hard Rock Casino & Resort in Scottsdale, AZ - Dr.MCD
ReplyDeleteA 양산 출장마사지 place to experience the Hard 순천 출장샵 Rock Experience. 청주 출장안마 Experience the thrills and excitement of 구리 출장안마 Rockin' Rockin' Rockin' 밀양 출장샵 Rockin' Casino!