Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 29 of 151

Unix filename pattern matching in Python

Samual Sam
Samual Sam
Updated on 26-Jun-2020 2K+ Views

Here we will see how we can get the UNIX shell style pattern matching techniques using Python. There is a module called fnmatch, which is used to do the work. This module is used to compare file name against a pattern, then returns True or False according to the matches.To use it at first we need to import it the fnmatch standard library module.import fnmatchIn the Unix terminal, there are some wildcards to match the patterns. These are like below −‘*’ The asterisk is used to match everything.‘?’ Question Mark is for matching a single character.[seq] Sequences are used to ...

Read More

C function to Swap strings

Samual Sam
Samual Sam
Updated on 26-Jun-2020 808 Views

The following is an example to swap strings.Example Live Demo#include #include int main() {    char st1[] = "My 1st string";    char st2[] = "My 2nd string";    char swap;    int i = 0;    while(st1[i] != '\0') {       swap = st1[i];       st1[i] = st2[i];       st2[i] = swap;       i++;    }    printf("After swapping s1 : %s", st1);    printf("After swapping s2 : %s", st2);    return 0; }OutputAfter swapping s1 : My 2nd string After swapping s2 : My 1st stringIn the above program, two ...

Read More

C++ Program to Compute Combinations using Factorials

Samual Sam
Samual Sam
Updated on 26-Jun-2020 1K+ Views

The following is an example to compute combinations using factorials.Example Live Demo#include using namespace std; int fact(int n) {    if (n == 0 || n == 1)    return 1;    else    return n * fact(n - 1); } int main() {    int n, r, result;    coutn;    coutr;    result = fact(n) / (fact(r) * fact(n-r));    cout

Read More

Determine day of week in month from Gregorian Calendar in Java

Samual Sam
Samual Sam
Updated on 26-Jun-2020 350 Views

To work with the GregorianCalendar class, import the following package −import java.util.GregorianCalendar;To get the day of week in month, use the following field −cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)Above, cal is the GregorianCalendar object we created before −GregorianCalendar cal = new GregorianCalendar();The following is an example −Example Live Demoimport java.util.GregorianCalendar; import java.util.Calendar; import java.util.Date; public class Demo {    public static void main(String[] args) {       GregorianCalendar cal = new GregorianCalendar();       // date information       System.out.println("Date Information..........");       System.out.println("Year = " + cal.get(Calendar.YEAR));       System.out.println("Month = " + (cal.get(Calendar.MONTH) + 1));       System.out.println("Date ...

Read More

Static functions in C

Samual Sam
Samual Sam
Updated on 26-Jun-2020 21K+ Views

A static function in C is a function that has a scope that is limited to its object file. This means that the static function is only visible in its object file. A function can be declared as static function by placing the static keyword before the function name.An example that demonstrates this is given as follows −There are two files first_file.c and second_file.c. The contents of these files are given as follows −Contents of first_file.cstatic void staticFunc(void) {    printf("Inside the static function staticFunc() "); }Contents of second_file.cint main() {    staticFunc();    return 0; }Now, if the above ...

Read More

Return values of printf() and scanf() in C

Samual Sam
Samual Sam
Updated on 26-Jun-2020 13K+ Views

The printf() and scanf() functions are required for output and input respectively in C. Both of these functions are library functions and are defined in the stdio.h header file.Details about the return values of the printf() and scanf() functions are given as follows −The printf() functionThe printf() function is used for printing the output. It returns the number of characters that are printed. If there is some error then it returns a negative value.A program that demonstrates this is as follows −Example Live Demo#include int main(){    char str[] = "THE SKY IS BLUE";    printf("The value returned ...

Read More

Java Program to return a Date set to the first possible millisecond of the day after midnight

Samual Sam
Samual Sam
Updated on 26-Jun-2020 157 Views

Let us first set the calendar object.Calendar calendar = Calendar.getInstance();Use the getMinimum() method in Java to return the minimum value for the given calendar field. We will use it to set the minute, hours second and milliseconds.For hour and minute.calendar.set(Calendar.HOUR_OF_DAY, calendar.getMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMinimum(Calendar.MINUTE));For second and milliseconds.// second calendar.set(Calendar.SECOND, calendar.getMinimum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMinimum(Calendar.MILLISECOND));The following is an example that returns a Date set to the first possible millisecond of the day after midnight.Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo {    public static void main(String[] argv) throws Exception {       Calendar calendar = Calendar.getInstance();       // ...

Read More

Display the day in week using SimpleDateFormat('E') in Java

Samual Sam
Samual Sam
Updated on 26-Jun-2020 717 Views

To display the day in week, use the SimpleDateFormat(“E”) as shown below −Format f = new SimpleDateFormat("E"); String strDayinWeek = f.format(new Date()); System.out.println("Day in week = "+strDayinWeek);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date.import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo {    public static void main(String[] args) throws Exception {       // displaying current date and time       Calendar cal = Calendar.getInstance();       SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s"); ...

Read More

Bounce In Right Animation Effect with CSS

Samual Sam
Samual Sam
Updated on 26-Jun-2020 213 Views

To implement Bounce In Right Animation Effect with CSS, you can try to run the following code −ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;             background-position: left top;             padding-top:95px;             margin-bottom:60px;             -webkit-animation-duration: 10s;             animation-duration: 10s;             -webkit-animation-fill-mode: both;             animation-fill-mode: both;          }          @-webkit-keyframes bounceInRight {             0% {                opacity: 0;                -webkit-transform: translateX(2000px);             }             60% {                opacity: 1;                -webkit-transform: translateX(-30px);             }             80% {                -webkit-transform: translateX(10px);             }             100% {                -webkit-transform: translateX(0);             }          }          @keyframes bounceInRight {             0% {                opacity: 0;                transform: translateX(2000px);             }             60% {                opacity: 1;                transform: translateX(-30px);             }             80% {                transform: translateX(10px);             }             100% {                transform: translateX(0);             }          }          .bounceInRight {             -webkit-animation-name: bounceInRight;             animation-name: bounceInRight;          }                           Reload page                function myFunction() {             location.reload();          }          

Read More

Set all the background image properties in one section with CSS

Samual Sam
Samual Sam
Updated on 26-Jun-2020 199 Views

The CSS background property is used to set all the background image properties in one section.ExampleYou can try to run the following code to implement the background property:Live Demo                    #demo {             background: lightblue url("https://www.tutorialspoint.com/css/images/css-mini-logo.jpg") no-repeat fixed top;          }                              www.tutorialspoint.com          Tutorials Point originated from the idea that there exists a             class of readers ...

Read More
Showing 281–290 of 1,507 articles
« Prev 1 27 28 29 30 31 151 Next »
Advertisements