Function Overloading using C++

/*/* * inlines.cpp * *  Created on: Jul 16, 2017 *      Author: asharda */
#include<iostream>using namespace std;inline int mul(int x,int y=10){ return x*y;}
double mul(double x,double y){ return x*y;}
int main(){ cout<<mul(5)<<“\n”; cout<<“Mul using Double”<<mul(5.50,10.0);}

Posted in C++, Uncategorized | Leave a comment

Print Numbers between 5 and 50 in intervals of 2

import numpy as np
print np.arange(5,50,2)

Posted in Python, Uncategorized | Leave a comment

Using Filters Java 8

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.testng.annotations.Test;

/**
* Using Filters Java 8
* @author asharda
*
*/
public class TestFilter {

@Test
public void testFilter() {
List<String> list1 = Arrays.asList(“Sai”, “Hari”, “Govind”, “Ashish”);
List<String> list = list1.stream().filter(output -> !”Ashish”.equals(output)).collect(Collectors.toList());
list.forEach(System.out::println);

}
}

Posted in Java, Uncategorized | Leave a comment

Using Friend Function C++

/*/* * sample.cpp * *  Created on: Jul 9, 2017 *      Author: asharda */
#include<iostream>using namespace std;
class sample{public: int a; int b; friend float mean(sample s);
}; float mean(sample s){ return float  (s.a+s.b)/2.0;}
int main(){ sample s; s.a=10; s.b=20; cout<<“Value seen is “<<mean(s);
}

Posted in C++, Uncategorized | Leave a comment

In in Python

”’
Created on Jul 9, 2017

@author: asharda
”’

miles=11
milestone=[1,2,3,4,5,6,7,8,9,10]
if miles in milestone:
print(“Miles is there in milestone”)
else:
print(“Miles is not there in milestone”)

Posted in Python, Uncategorized | Leave a comment

Celsius to Fahrenheit Python

”’
Created on Jul 7, 2017

@author: asharda
”’
import numpy as np
cvalues=[22,18,23,30]
C=np.array(cvalues)
F=C*1.8+32
print F

Posted in Python, Uncategorized | Leave a comment

Print random 10 Integers Java

 

import java.util.Random;

import org.testng.annotations.Test;

public class TestRandomInt {
@Test
public void testRandomInt()
{
Random random=new Random();
random.ints().limit(10).forEach(System.out::println);
}
}

Posted in Java, Uncategorized | Leave a comment