Found 34494 Articles for Programming

Birthday Reminder Application in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

636 Views

In this section we will see how to create a birthday reminder application using Python. Problem Statement Create an application using Python, which can check whether there is any birthday on the current day or not. If it is the birthday of some listed person, send a notification to the System with the name of that person. We need a file, where we can store the date and month and the name of the person as a lookup file for this application. The file will look like this − Here we will convert this application to a start-up application ... Read More

Unix filename pattern matching in Python

Samual Sam
Updated on 26-Jun-2020 08:57:31

1K+ 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

Initialization of variable sized arrays in C

karthikeya Boyini
Updated on 26-Jun-2020 08:59:10

7K+ Views

Variable sized arrays are data structures whose length is determined at runtime rather than compile time. These arrays are useful in simplifying numerical algorithm programming. The C99 is a C programming standard that allows variable sized arrays.A program that demonstrates variable sized arrays in C is given as follows −Example Live Demo#include int main(){    int n;    printf("Enter the size of the array: ");    scanf("%d", &n);    int arr[n];    for(int i=0; i

Initialization of a multidimensional array in C

Samual Sam
Updated on 26-Jun-2020 08:59:47

328 Views

Array is a collection of same type of elements at contiguous memory location. The lowest address corresponds to the first element while highest corresponds to last element. Array index starts with zero(0) and ends with the size of array minus one(array size - 1). Array size must be integer greater than zero.Let us see an example, If array size = 10 First index of array = 0 Last index of array = array size - 1 = 10-1 = 9Multi-dimensional arrays are arrays of array. The data is stored in tabular form in row major order.The following is the syntax ... Read More

How to print a variable name in C?

karthikeya Boyini
Updated on 26-Jun-2020 09:00:16

1K+ Views

The following is an example to print variable name.Example Live Demo#include #define VariableName(name) #name int main() {    int name;    char ch;    printf("The variable name : %s", VariableName(name));    printf("The variable name : %s", VariableName(ch));    return 0; }OutputThe variable name : name The variable name : chIn the above program, the variable names are printed by defining the method before main()#define VariableName(name) #nameTwo variables of different datatypes are declared. By using the defined function, variable names are printed.int name; char ch; printf("The variable name : %s", VariableName(name)); printf("The variable name : %s", VariableName(ch));

Write a power (pow) function using C++

Samual Sam
Updated on 26-Jun-2020 09:02:50

1K+ Views

The power function is used to find the power given two numbers that are the base and exponent. The result is the base raised to the power of the exponent.An example that demonstrates this is as follows −Base = 2 Exponent = 5 2^5 = 32 Hence, 2 raised to the power 5 is 32.A program that demonstrates the power function in C++ is given as follows −Example Live Demo#include using namespace std; int main(){    int x, y, ans = 1;    cout > x;    cout > y;    for(int i=0; i

The static keyword and its various uses in C++

karthikeya Boyini
Updated on 26-Jun-2020 09:03:47

270 Views

When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static variable can be defined inside or outside the function. They are local to the block. The default value of static variable is zero. The static variables are alive till the execution of the program.The following is the syntax of static keyword.static datatype variable_name = value; // Static variable    static ... Read More

C++ Program to Find Fibonacci Numbers using Iteration

Samual Sam
Updated on 26-Jun-2020 09:04:47

6K+ Views

The following is an example to find fibonacci series using iteration.Example Live Demo#include using namespace std; void fib(int num) {    int x = 0, y = 1, z = 0;    for (int i = 0; i < num; i++) {       cout

C++ Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers

karthikeya Boyini
Updated on 26-Jun-2020 08:38:49

972 Views

The following is an example to check whether a number can be expressed as sum of two prime numbers.Example Live Demo#include using namespace std; int func(int num) {    int i;    int flag = 1;    for(i = 2; i num;    for(i = 2; i

C++ Program to Compute Combinations using Factorials

Samual Sam
Updated on 26-Jun-2020 08:39:33

810 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

Advertisements