text:
Evaluate expressions with significant figures
Given an expression, your task is to evaluate it. However, your answer cannot show more digits than necessary, as this gives the impression of having more precise measurements than reality.
The number of significant figures that a number has is how many digits it has when written in scientific notation, including zeros at the end if a decimal point is present. For example, 1200 has 2 significant figures because it is 1.2*10^3 but 1200. has 4 significant figures and 1200.0 has 5 significant figures.
When adding two numbers, the result should be rounded to the same number of places as the number whose least significant digit is furthest to the left. For example, 1200 + 3 = 1200 (rounded to the hundreds place since 1200 is rounded to the hundreds place), 1200.01 + 3 = 1203, and 4.59 + 2.3 = 6.9. Note that 5 rounds up. This same rule applies to subtraction. 0 is rounded to the ones place. Note that adding and subtracting do not depend on the number of significant digits. For example, 999 + 2.00 = 1001 because 999 is rounded to the ones place and 2.00 is rounded to the hundredths place; the one rounded to fewer places is 999, so the result, 1001.00, should be rounded to the ones place as well. Similarly, 300 + 1 - 300 is exactly equal to 1, but 300 is rounded to the hundreds place, so the final result should also be rounded to the hundreds place, giving 0. 300. + 1 - 300. would equal 1 on the other hand.
When multiplying or dividing two numbers, round to the number of significant digits of the number with the least significant digits. For example, 3.839*4=20 because the exact value, 15.356, rounds to 20 since 4 has only one significant figure. Similarly, 100/4=30 since both numbers have one significant figure, but 100./4.00=25.0 since both numbers have 3 significant figures. 0 is defined to have 1 significant figure.
Expressions will only contain *, /, +, and -, (and parentheses). Order of operations should be followed and results should be rounded after every operation. If parentheses are left out in a string of additions or subtractions or a string of multiplications and divisions, then round after all operations are completed. For example, 6*0.4*2 = 5 (one significant figure), while 0.4*(2*6)=0.4*10=4 and (6*0.4)*2=2*2=4.
Input: A string, with an expression containing ()*/+- and digits. To simplify things, - will only be used as a subtraction operator, not to signify negative numbers; answers, however, could still be negative and would require - as a prefix.
Output: The result of the expression, evaluated and rounded to the correct number of digits. Note that 25 is incorrect for 25.0.
Test cases:
3 + 0.5 --> 4
25.01 - 0.01 --> 25.00
4*7*3 --> 80
(4*7)*3 --> 90
(8.0 + 0.5)/(2.36 - 0.8 - 0.02) --> 5.7
6.0 + 4.0 --> 10.0
5.0 * 2.0 --> 10.0
1/(2.0 * (3.0 + 5.0)) --> 0.06
0.0020 * 129 --> 0.26
300 + 1 - 300 --> 0
0 - 8.8 --> -9
3*5/2*2 --> 20

Edge case: Consider the problem of 501*2.0. The exact value is 1002. Printing 1002 gives too many significant figures (4, when we need 2) but 1000 gives too few (1, when we need 2). In this case, your program should print 1000 anyway.
This source explains significant digits as well: http://www.purplemath.com/modules/rounding2.htm

What do you mean by "the same number of places"? Is that the same as "the same number of significant figures"? If you want an edge case for addition, 999 + 2.00.

Surely 300 + 1 - 300 is a string of additions and subtractions, so doesn't need to be rounded until the end. (300 + 1) - 300 would be zero.

Java 11, 1325 1379 1356 1336 1290 bytes
import java.math.*;String c(String s)throws Exception{String r="",T=r,a[],b[],z="\\.";int i=0,l,A[],M=0,m=s.length(),j,f=0,q=m;if(s.contains("(")){for(;i<m;){var c=s.charAt(i++);if(f<1){if(c==40){f=1;continue;}r+=c;}else{if(c==41&T.replaceAll("[^(]","").length()==T.replaceAll("[^)]","").length()){r+="x"+s.substring(i);break;}T+=c;}}return c(r.replace("x",c(T)));}else{for(a=s.split("[\\+\\-\\*/]"),A=new int[l=a.length];i<l;f=b.length>1&&(j=b[1].length())>f?j:f)M=(j=(b=a[i++].split(z))[0].length())>M?j:M;for(b=a.clone(),i=0;i<l;A[i]=b[i].contains(".")?j=b[i].length()-1:b[i].replaceAll("0*$","").length(),i++)for(q=(j=b[i].replace(".","").length())<q?j:q,j=a[i].split(z)[0].length();j++<M;)b[i]=0+b[i];double R=new Double(new javax.script.ScriptEngineManager().getEngineByName("JS").eval(s)+""),p;for(int x:A)m=x<m?x:m;m=m==M&R%1==0&(int)R/10%10<1&(j=(r=R+"").split(z)[0].length())>m?j-q>1?q:j:R>99?m:R%10==0?r.length()-1:m<1?1:m;R=new BigDecimal(R).round(new MathContext((R<0?-R:R)<1?m-1:m)).doubleValue();r=(m<M&(p=Math.pow(10,M-m))/10>R?(int)(R/p)*p:R)+"";l=r.length()-2;r=(r=f<1?r.replaceAll(z+"0$",""):r+"0".repeat(f)).substring(0,(j=r.length())<m?j:r.contains(".")?(j=r.replaceAll("^0\\.0+","").length())<m?m-~j:m+1:m);for(i=r.length();i++<l;)r+=0;return r.replaceAll(z+"$","");}}

+54 bytes to fix the edge case 501*2.0 (gave result 1002 before, but now correct 1000).
I now understand why this challenge was unanswered for almost two years.. >.> This challenge has more special cases than the Dutch language, which is saying something..
Java is certainly not the right language for these kind of challenges (or any codegolf challenge for that matter.. ;p), but it's the only language I know good enough to even attempt a difficult challenge like this.
Input format as String without spaces (if that is not allowed, you can add s=s.replace(" ","") (+19 bytes) at the top of the method).
Try it online.
Explanation:
Sorry for the long post.
if(s.contains("(")){
  for(;i<m;){
    var c=s.charAt(i++);
    if(f<1){
      if(c==40){
        f=1;
        continue;}
      r+=c;}
    else{
      if(c==41&T.replaceAll("[^(]","").length()==T.replaceAll("[^)]","").length()){
        r+="x"+s.substring(i);
        break;}
      T+=c;}}
  return c(r.replace("x",c(T)));}

This part is used for input containing parenthesis. It will get the separated parts and use recursive-calls.

0.4*(2*6) becomes 0.4*A, where A is a recursive call to c(2*6)
(8.3*0.02)+(1.*(9*4)+2.2) becomes A+B, where A is a recursive call to c(8.3*0.02) and B a recursive call to c(1.*(9*4)+2.2) → which in turn becomes 1.*C+2.2, where C is a recursive call to c(9*4)

for(a=s.split("[\\+\\-\\*/]"),A=new int[l=a.length];
    i<l;
    f=b.length>1&&(j=b[1].length())>f?j:f)
  M=(j=(b=a[i++].split(z))[0].length())>M?j:M;

This first loop is used to fill the values M and k, where M is the largest integer-length regarding significant figures and k the largest decimals-length.

1200+3.0 becomes M=2, k=1 (12, .0)
999+2.00 becomes M=3, k=2 (999, .00)
300.+1-300. becomes M=3, k=0 (300, .)

for(b=a.clone(),i=0;
    i<l;
    A[i]=b[i].contains(".")?j=b[i].length()-1:b[i].replaceAll("0*$","").length(),i++)
  for(q=(j=b[i].replace(".","").length())<q?j:q,
      j=a[i].split(z)[0].length();
      j++<M;)
    b[i]=0+b[i];

This second loop is used to fill the arrays A and b as well as value q, where A is the amount of significant figures, b hold the integers with leading zeroes to match M, and q is the lowest length disregarding dots.

1200+3.0 becomes A=[2, 5] (12, 00030), b=[1200, 0003.0], and q=2 (30)
999+2.00 becomes A=[3, 5] (999, 00200), b=[999, 002.00], and q=3 (both 999 and 200)
300.+1-300. becomes A=[3, 3, 3] (300, 001, 300), b=[300., 001, 300.], and q=1 (1)
501*2.0 becomes A=[3, 4] (501, 0020), b=[501, 002.0], and q=2 (20)

double R=new Double(new javax.script.ScriptEngineManager().getEngineByName("JS").eval(s)+"")

Uses a JavaScript engine to eval the input, which will be saved in R as double.

1200+3.0 becomes R=1203.0
999+2.00 becomes R=1001.0
300.+1-300. becomes R=1.0

for(int x:A)
  m=x<m?x:m;

This sets m to the smallest value in the array A.

A=[2, 5] becomes m=2
A=[3, 5] becomes m=3
A=[3, 3, 3] becomes m=3

 m=m==M                // If `m` equals `M`
   &R%1==0             // and `R` has no decimal values (apart from 0)
   &(int)R/10%10<1     // and floor(int(R)/10) modulo-10 is 0
   &(j=(r=R+"").split(z)[0].length())>m?
                       // and the integer-length of R is larger than `m`:
    j-q>1?             //  If this integer-length of `R` minus `q` is 2 or larger:
     q                 //   Set `m` to `q` instead
    :                  //  Else:
     j                 //  Set `m` to this integer-length of `R`
   :R>99?              // Else-if `R` is 100 or larger:
    m                  //  Leave `m` the same
   :R%10==0?           // Else-if `R` modulo-10 is exactly 0:
    r.length()-1       //  Set `m` to the total length of `R` (minus the dot)
   :m<1?               // Else-if `m` is 0:
    1                  //  Set `m` to 1
   :                   // Else:
    m;                 //  Leave `m` the same

This modifies m based on multiple factors.

999+2.00 = 1001.0 & m=3,q=3 becomes m=4 (because m==M (both 3) → R%1==0 (1001.0 has no decimal values) → (int)R/10%10<1 ((int)1001.0/10 becomes 100 → 100%10<1) → "1001".length()>m (4>3) → "1001".length()-q<=1 (4-3<=1) → so m becomes the length of the integer-part "1001" (4))
3.839*4 = 15.356 & m=1,q=1 stays m=1 (because m==M (both 1) → R%1!=0 (15.356 has decimal values) → R<=99 → R%10!=0 (15.356%10==5.356) → m!=0 → so m stays the same (1))
4*7*3 = 84.0 & m=1,q=1 stays m=1 (because m==M (both 1) → R%1==0 (84.0 has no decimal values) → (int)R/10%10>=1 ((int)84/10 becomes 8 → 8%10>=1) → R<=99 → R%10!=0 (84%10==4) → m!=0 → so m stays the same (1))
6.0+4.0 = 10.0 & m=2,q=2 becomes m=3 (because m!=M (m=2, M=1) → R<=99 → R%10==0 (10%10==0) → so m becomes the length of the total R (minus the dot) "10.0".length()-1 (3))
0-8.8 = -8.8 & m=0,q=1 becomes m=1 (because m!=M (m=0, M=1) → R<=99 → R%10!=0 (-8.8%10==-8.8) → m<1 → so m becomes 1)
501*2.0 = 1001.0 & m=3,q=2 becomes m=2 (because m==M (both 3) → R%1==0 (1001.0 has no decimal values) → (int)R/10%10<1 ((int)1001.0/10 becomes 100 → 100%10<1) → "1001".length()>m (4>3) → "1001".length()-q>1 (4-2>1) → so m becomes q (2))

R=new BigDecimal(R).round(new MathContext((R<0?-R:R)<1?m-1:m)).doubleValue();

Now R is rounded based on m.

1001.0 & m=4 becomes 1001.0
0.258 & m=3 becomes 0.26 (because abs(R)<1, m-1 (2) instead of m=3 is used inside MathContext)
-8.8 & m=1 becomes -9.0
1002.0 & m=2 becomes 1000.0

m<M&(p=Math.pow(10,M-m))/10>R?(int)(R/p)*p:R;

This modifies the integer part of R if necessary.

300.+1-300. = 1.0 & m=3,M=3 stays 1.0 (because m>=M → so R stays the same (1.0))
0.4*10 = 4.0 & m=1,M=2 stays 4.0 (because m<M → (10^(M-m))/10<=R ((10^1)/10<=4.0 → 10/10<=4.0 → 1<=4.0) → so R stays the same (4.0))
300+1-300 = 1.0 & m=1,M=3 becomes 0.0 (because m<M → (10^(M-m))/10>R ((10^2)/10>1.0 → 100/10>1.0 → 10>1.0) → so R becomes 0.0 because of  int(R/(10^(M-m)))*(10^(M-m)) (int(1.0/(10^2))*(10^2) → int(1.0/100)*100 → 0*100 → 0)

r=(...)+"";                  // Set `R` to `r` as String (... is the part explained above)
l=r.length()-2;              // Set `l` to the length of `R` minus 2
r=(r=k<1?                    // If `k` is 0 (no decimal values in any of the input-numbers)
      r.replaceAll(z+"0$","")
                             //  Remove the `.0` at the end
     :                       // Else:
      r+"0".repeat(f)
                             //  Append `k` zeroes after the current `r`
  ).substring(0,             // Then take the substring from index `0` to:
     (j=r.length())<m?       //  If the total length of `r` is below `m`:
       j                     //   Leave `r` the same
     :r.contains(".")?       //  Else-if `r` contains a dot
       (j=r.replaceAll("^0\\.0+","").length())<m?
                             //   And `R` is a decimal below 1,
                             //   and its rightmost decimal length is smaller than `m`
        m-~j                 //    Take the substring from index 0 to `m+j+1`
                             //    where `j` is this rightmost decimal length
       :                     //   Else:
        m+1                  //    Take the substring from index 0 to `m+1`
     :                       //  Else:
      m);                    //   Take the substring from index 0 to `m`

This sets R to r as String, and modifies it based on multiple factors.

1203.0 & m=4,k=2 becomes 1203. (because k>=1 → so r becomes 1001.000; r.length()>=m (8>=4) → r.contains(".") → r.length()>=m (8>=4) → substring from index 0 to m+1 (5))
6.9 & m=2,k=2 stays 6.9 (because k>=1 → so r becomes 6.900; r.length()>=m (5>=2) → r.contains(".") → r.length()>=m (5>=2) → substring from index 0 to m+1 (3))
1.0 & m=3,k=0 becomes 1 (because k<1 → so r becomes 1; r.length()<m (1<3) → substring from index 0 to r.length() (1))
25.0 & m=4,k=4 becomes 25.00 (because k>=1 → so r becomes 25.00000; r.length()>=m (8>=4) → r.contains(".") → r.length()>+m (8>=4) → substring from index 0 to m+1 (5))
0 & m=1,k=0 stays 0 (because k<1 → so r stays 0; r.length()>=m (1>=1) → !r.contains(".") → substring from index 0 to m (1))

for(i=r.length();i++<l;)
  r+=0;

This puts trailing zeroes back again to the integer part if necessary.

r="12" & R=1200.0 becomes r="1200"
r="1" & R=10.0 becomes r="10"
r="8" & R=80.0 becomes r="80"

return r.replaceAll(z+"$","");

And finally we return the result, after we've removed any trailing dots.

1203. becomes 1203
5. becomes 5

Can definitely be golfed by a couple hundred bytes, but I'm just glad it's working now. It already took a while to understand each of the cases and what was being asked in the challenge. And then it took a lot of trial-and-error, testing and retesting to get to the result above. And while writing this explanation above I was able to remove another ±50 bytes of unused code..

Upvoted. But the spec seems to require that 501*2.0 to output 1000 (you should output 1000 anyway, which I interpret as "still", not either way). Magnificent work anyway.

@WeijunZhou Thanks for the feedback! I've given it some thought again and was able to fix the edge-case without breaking any other cases. :)


text:
Smallest palindrome divisible by the input
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.
The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.
The input will never be a multiple of 10, because of the previous reason.
Your program may take as much time as necessary, even if in practice it would be way too long to output the answer.
Inputs and outputs

You may take the input through STDIN, as a function argument, or anything similar.
You may print the output to STDOUT, return it from a function, or anything similar.
Inputs and outputs must be in the decimal base.

Test cases
N        Output
1        1
2        2
16       272
17       272
42       252
111      111
302      87278
1234     28382

Scoring
This is code-golf, so the shortest answer in bytes wins.

Will the input be divisible by 10?

@LeakyNun No, because then there is no solution since the palindrome must not need a leading zero. I will make that explicit.

Will the input be positive?

@WheatWizard Yes: Given a positive integer N

@Fatalize sorry.  I don't know how I missed it.

Base 10 is mandatory?

@corsiKa Yes, unless your language does not support base 10 (which I highly doubt)

2sable / 05AB1E, 6 / 7 bytes
2sable
[DÂQ#+

Explanation
[         # infinite loop
 D        # duplicate current number
  Â       # bifurcate
   Q#     # if the number is equal to its reverse, break loop
     +    # add input
          # implicitly print

Try it online
05AB1E
[DÂQ#¹+

The difference to the 2sable code is that input is only implicit once in 05AB1E, so here we need ¹ to get the first input again.
Try it online
Saved 1 byte with 2sable as suggested by Adnan

@Fatalize I was just writing it up :)

If you switch to 2sable, you can save a byte by doing this: [DÂQ#+.

@Adnan: Right! The repeated implicit input saves a byte :)

Haskell, 45 37 34 bytes
(+)>>=until((reverse>>=(==)).show)

Pyth, 7 bytes
*f_I`*Q

Try it online: Demonstration
Explanation
*f_I`*QT)Q   implicit endings, Q=input number
 f      )    find the first number T >= 1, which satisfies:
     *QT        product of Q and T
    `           as string
  _I            is invariant under inversion (=palindrom)
*        Q   multiply this number with Q and print

After reading so many codegold questions I'm starting to think that Pyth will be next JS/Java/Ruby/Python...

@agilob oh dear god pls no.

Java, 164 159 126 108 94 bytes
Golfed version:
int c(int a){int x=a;while(!(x+"").equals(new StringBuffer(x+"").reverse()+""))x+=a;return x;}

Ungolfed version:
int c(int a)
{
    int x = a;
    while (!(x + "").equals(new StringBuffer(x + "").reverse() + ""))
        x += a;
    return x;
}

Shoutout to Emigna and Kevin Cruijssen for contributing improvements and cutting the bytes almost in half :)

Isn't x % a == 0 kind of redundant when you initialize x as a and only increase it by a? Also, can the comparison with the reversal of the string be done in the while conditional?

You can remove import org.apache.commons.lang.StringUtils; and use org.apache.commons.lang.StringUtils.reverse directly. for(;;) is shorter than while(1>0). No need for a full program, just int c(int a){...} would do as a valid answer, since the question has the following rule: "You may take the input as a function argument. You may return the output from a function." @Emigna is indeed right that the modulo check isn't necessary.

Oh, and welcome of course! You might like this post: Tips for golfing in Java.

@Emigna: you're absolutely right, did that.

@KevinCruijssen: since I only iterate through numbers which are divisible by a (by x += a). I don't have to check for divisibility :) and thanks for the golfing tips!

Also, why did you use StringUtils.reverse? Because of the required org.apache.commons.lang. it's actually longer than new StringBuffer(x+"").reverse()+""..

@peech Yeah, I noticed the smart x+=a after I made that last comment. I removed that part before the 5 minutes had past and I wouldn't have been able to edit my comment.  (I also deleted my own Java answer, since it was pretty bad..)

You can remove {} from the while-loop as there's only 1 statement inside, can't you?

Oh, also, since you're new: It's nice to add a link with your test-code so others can verify it works. I personally use ideone.com for this, but there are other online compilers available. Here is your code with a test-ideone. Feel free to fork it and make changes if you need/want to.

Interesting: converting to an empty for loop produces a function of the exact same size. Usually for is slightly smaller in terms of code byte size.

Yes I tried that but kept the while loop for easier reading.

C#, 103 80 Bytes
int f(int p){int x=p;while(x+""!=string.Concat((x+"").Reverse()))x+=p;return x;}

Ungolfed
int f(int p)
{
   int x = p;
   while (x + "" != string.Concat((x + "").Reverse()))
      x += p;
   return x;
}

You might save some bytes by removing i, and incrementing via x+=p.

replacing x.ToString() with 'x+""` will save a bunch of chars.

Brachylog, 8 bytes
:L#>*.r=

Try it online! (around 5 seconds for 1234)
Verify all testcases. (around 20 seconds)
:L#>*.r=
?:L#>*.r=.   Implicitly filling Input and Output:
             Input is prepended to every predicate,
             Output is appended to every predicate.

?:L  *.      Input*L is Output,
  L#>        L is positive,
      .r .   Output reversed is Output,
        =.   Assign a value to Output.

Python 2, 46 bytes
f=lambda x,c=0:`c`[::-1]==`c`and c or f(x,c+x)

Ideone it!
Recursive solution with c as counter.
The case for 0 is interesting, because although c=0 satisfies the palindrome condition, it would not be returned, because ccc and 0 or xxx always returns xxx.

It's a bit shorter to do c*(`c`[::-1]==`c`)or.

Javascript (ES6), 55 51 bytes
4 bytes thanks to Neil.

f=(x,c=x)=>c==[...c+""].reverse().join``?c:f(x,x+c)
<input type=number min=1 oninput=o.textContent=this.value%10&&f(+this.value)><pre id=o>

From playing around while creating your code snippet for you, the first + seems unnecessary.

Would (x,c=x) allow you to avoid the &&c?

I think you can do c^[...c+""].reverse().join``?f(x,x+c):c to save one more byte.

c- would work for slightly higher numbers than c^, if necessary.

PHP, 39 bytes
while(strrev($i+=$argv[1])!=$i);echo$i;

Takes number N as argument $argv[1];
; after while to do nothing
strrev return string backward

Same length with for-loop
for(;strrev($i+=$argv[1])!=$i;);echo$i;

Actually, 15 14 bytes
Asked to answer by Leaky Nun. Golfing suggestions welcome. Try it online!
╖2`╜*$;R=`╓N╜*

Ungolfing
          Implicit input n.
╖         Save n in register 0.
2`...`╓   Push first 2 values where f(x) is truthy, starting with f(0).
  ╜*$       Push register 0, multiply by x, and str().
  ;R        Duplicate str(n*x) and reverse.
  =         Check if str(n*x) == reverse(str(n*x)).
          The map will always result in [0, the x we want].
N         Grab the last (second) value of the resulting list.
╜*        Push n and multiply x by n again.
          Implicit return.

C, 217 189 bytes
Standalone version :
int a(char*b){int c=strlen(b);for(int i=0;i<c/2;i++)if(b[i]!=b[c-i-1])return 0;}int main(int e,char **f){int b,c;char d[9];b=atoi(f[1]);c=b;while(1){sprintf(d,"%d",c);if(a(d)&&(c/b)*b==c)return printf("%d",c);c++;}}

Call to a function version :
int s(char*a){int b=strlen(a);for(int i=0;i<b/2;i++)if(a[i]!=a[b-i-1])return 0;}int f(int a){int b;char c[9];b=a;while(1){sprintf(c,"%d",b);if(s(c)&&(b/a)*a==b)return printf("%d",b);b++;}}

Ungolfed :
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int check_palindrome(char *str) {
  int length = strlen(str);

  for (int i = 0; i < length / 2; i++) {
    if (str[i] != str[length - i - 1])
      return 0;
  }
  return 1;
}

int main(int argc, char **argv) {
  int number;
  int pal;
  char string[15];

  number = atoi(argv[1]);
  pal = number;
  while (1) {
    sprintf(string, "%d", pal);
    if (check_palindrome(string) && (pal / number) * number == pal)
      {
        printf("%d\n", pal);
        return 1;
      }
    pal++;
  }
  return 0;
}

Call to a function ungolfed :
int s(char *a) {
  int b = strlen(a);

  for (int i = 0; i < b / 2; i++) {
    if (a[i] != a[b - i - 1])
      return 0;
  }
  return 1; //We can remove it, it leads to a undefined behaviour but it works
}

int f(int a) {
  int b;
  char c[9];

  b = a;
  while (1) {
    sprintf(c, "%d", b);
    if (s(c) && (b / a) * a == b)
      {
        printf("%d\n", b); //no need for the \n
        return 1; //just return whatever printf returns, who cares anyway ?
      }
    b++;
  }
  return 0; //no need for that
}

I included the standalone version for historicity.
This is my first codegolf, any comment is welcome !

I recommend making a separate function for the challenge, and not counting main() regardless of your preferences. You wouldn't play baseball by running twelve loops around first before tagging "because I prefer it," you will never reach safely. This is a competition, and the primary rule is to use any means necessary and legal to reduce byte count.

@Snowman fair enouth, I edited my answer to include a 'call to a function' version. This allows me to take an int as parameter and gold away a few more bytes.

do your function compile without "include <string.h>"? if the answer is not than i can use #define F for  or #define R return without make it in count...

@RosLuP yeah, I get a few warnings but gcc is able to compile it.

Hi!, I would like drop some Hints!

C has implicit int so you can change the code like this int f(int a) -> f(a)
if you have to declare some ints you can use the function parameters: int f(int a){int b; -> f(a,b){
sprintf will never return 0 so you ca use in the while: while(1){sprintf(c,"%d",b); -> while(sprintf(c,"%d",b)){
use the K&R C for define a Function so tou can combo with my 2nd hint: int s(char*a){int b=strlen(a);for(int i=0 -> s(a,b,i)char*a;{b=strlen(a);for(i=0;

@GiacomoGarabello Thanks for the tips, I didn't know about the default type, that's a pretty neat trick !

Pyke, 11 9 bytes
.f*`D_q)*

Try it here!

R, 117 113 109 101 bytes
D=charToRaw;P=paste;S=strtoi;a=P(i<-scan()+1);while(!all(D(a)==rev(D(a))&&S(a)%%i==0)){a=P(S(a)+1)};a

Ungolfed
i<-scan()        #Takes the input

D=charToRaw      #Some aliases
P=paste
S=strtoi
a=P(i+1)         #Initializes the output

while(!(all(D(a)==rev(D(a)))&&(S(a)%%i==0))) #While the output isn't a palindrom and isn't
                                             #divisible by the output...
    a=P(S(a)+1)

a

all(charToRaw(a)==rev(charToRaw(a))) checks if at each position of a the value of a and its reverse are the same (i.e., if a is palindromic).
It might be possible to golf out some bytes by messing around with the types.

Perl, 25 bytes
Includes +2 for -ap
Run with the input on STDIN:
palidiv.pl <<< 16

palidiv.pl:
#!/usr/bin/perl -ap
$_+="@F"while$_-reverse

Haskell, 64 63 56 bytes
x!n|mod x n==0,s<-show x,reverse s==s=x|y<-x+1=y!n
(1!)

Call with (1!)16 or simply 1!16. Try it on Ideone.

VBSCRIPT, 47 bytes
do:i=i+1:a=n*i:loop until a=eval(strreverse(a))

ungolfed
do                     #starts the loop
i=i+1                  #increments i, we do it first to start at 1 instead of 0
a=                     #a is the output
n*i                    #multiply our input n by i
loop until
a=eval(strreverse(a))  #end the loop when our output is equal to its reverse

S.I.L.O.S, 109 bytes
readIO
n = 0
lbla
n + i
a = n
r = 0
lblb
m = a
m % 10
r * 10
r + m
a / 10
if a b
r - n
r |
if r a
printInt n

Try it online!

Japt, 14 bytes
V±U s w ¥V?V:ß

Try it online!
Thank you ETHproductions for the help! :)

Python 2, 66 65 bytes
i is input and x is (eventually) output
def f(i,x):
    y=x if x%i==0&&`x`==`x`[::-1]else f(i,x+1)
    return y

After scrolling through other answers I found a shorter Python 2 answer but I put the effort into my solution so might as well throw it here. ¯\_(ツ)_/¯

You can remove the space in [::-1] else.

can't you remove the assignment of y, and just put the expression on the end of the return? return x if x%i==0&&x==x[::-1]else f(i,x+1), which then means you can make it a lambda, and golf more bytes?

PowerShell v2+, 72 bytes
for($i=$n=$args[0];;$i+=$n){if($i-eq-join"$i"["$i".Length..0]){$i;exit}}

Long because of how reversing is handled in PowerShell -- not very well. ;-)
Takes input $args[0], stores into $i (our loop variable) and $n (our input). Loops infinitely, incrementing $i by $n each time (to guarantee divisibility).
Each iteration, we check whether $i is a palindrome. There's some trickery happening here, so let me explain. We first take $i and stringify it with "$i". That's then array-indexed in reverse order ["$i".length..0] before being -joined back into a string. That's fed into the right-hand side of the -equality operator, which implicitly casts the string back into an [int], since that's the left-hand operand. Note: this casting does strip any leading zeros from the palindrome, but since we're guaranteed the input isn't divisible by 10, that's OK.
Then, if it is a palindrome, we simply place $i onto the pipeline and exit. Output is implicit at the end of execution.
Test Cases
PS C:\Tools\Scripts\golfing> 1,2,16,17,42,111,302,1234|%{"$_ -> "+(.\smallest-palindrome-divisible-by-input.ps1 $_)}
1 -> 1
2 -> 2
16 -> 272
17 -> 272
42 -> 252
111 -> 111
302 -> 87278
1234 -> 28382

Mathematica, 49 bytes
(c=#;Not[PalindromeQ@c&&c~Mod~#==0]~While~c++;c)&

Starts the search at c = N, and increments c if not a palindrome and not divisible by N. When conditions are met, outputs c.

Jelly, 12 bytes
¹µ+³ßµDU⁼Dµ?

Try it online!
Explanation:
This link takes 1 argument. The µs split it into 4 parts. Starting from the last and moving left:
           ? The three parts in front of this are the if, else, and
             condition of a ternary expression.
      DU⁼D  This condition takes a number n as an argument. It converts
            n to an array of decimal digits, reverses that array, and
            then compares the reversed array to the decimalization of
            n (ie is n palindromic in decimal?)
  +³ß  This is the else. It adds the original input argument to n
       and then repeats the link with the new value of n.
¹  This is the if. It returns the value passed to it.

11 bytes

MATL, 10 bytes
0`G+tVtP<a

Try it online!
0      % Push 0
`      % Do...while
  G+   %   Add the input. This generates the next multiple of the input
  tV   %   Duplicate, convert to string
  tP   %   Duplicate, reverse
  <a   %   Is any digit lower than the one in the reverse string? This is the
       %   loop condition: if true, the loop proceeds with the next iteration
       % End do...while
       % Implicitly display

MATLAB, 76 bytes
function s=p(n)
f=1;s='01';while(any(s~=fliplr(s))) s=num2str(n*f);f=f+1;end

Call format is p(302) result is a string.
Nothing clever here. It does a linear search, using the num2str() and fliplr() functions.
This ugly arrangement is a touch shorter than using a while(1) ... if ... break end pattern.
Ungolfed
function s = findFirstPalindromeFactor(n)
  f = 1;                        % factor
  s = '01';                     % non-palindromic string for first try
  while( all(s ~= fliplr(s)) )  % test s not palindrome
    s = num2str( n * f );       % factor of input as string
    f = f + 1;                  % next factor
  end

Elixir, 75 bytes
def f(p,a\\0),do: if'#{a+p}'|>Enum.reverse=='#{a+p}',do: a+p,else: f(p,a+p)

REXX, 46 bytes
arg a
do n=a by a until reverse(n)=n
end
say n

QBIC, 29 bytes
:{c=a*q~!c$=_f!c$||_Xc\q=q+1

Explanation:
:      Get cmd line param as number 'a'
{      DO
c=a*q  multiply 'a' by 'q' (which is 1 at the start of a QBIC program) and assign to 'c'
~      IF
!c$    'c' cast to string
=      equals
_f!c$| 'c' cast to string, the reversed
|      THEN
_Xc    Quit, printing 'c'
\q=q+1 ELSE increment q and rerun
       DO Loop is auto-closed by QBIC, as is the IF

Python 2, 44 bytes
x=lambda n,m=0:m*(`m`==`m`[::-1])or x(n,m+n)

Try it online!
I know that the question was posted over six months ago, but this was shorter than any other Python submission.

Perl 6, 35 bytes
->\N{first {$_%%N&&$_==.flip},N..*}

->\N{first {$_==.flip},(N,N*2...*)}

->\N{(N,N*2...*).first:{$_==.flip}}

Explanation:
-> \N {
  # from a list of all multiples of the input
  # ( deduced sequence )
  ( N, N * 2 ... * )

  # find the first
  .first:

  # that is a palindrome
  { $_ == .flip }
}

Perl 6, 39 bytes
my &f={first {.flip==$_},($_,2*$_...*)}

(33 not including the my &f=)

Mathematica, 34 28 bytes
#//.x_/;!PalindromeQ@x:>x+#&

Unnamed function taking a positive integer input and returning a positive integer. To be read as: "Starting with the function argument #, repeatedly replace any x we see that is not a palindrome with x+#." Yes, Virginia, there is a PalindromeQ! It only works in base 10 though.
Original submission:
(i=1;While@!PalindromeQ[++i#];i#)&

I count 34, but here's 33: (i=0;While@!PalindromeQ[i+=#];i)& or (For[i=0,!PalindromeQ[i+=#],];i)& or (For[i=#,!PalindromeQ@i,i+=#];i)&.

Revisiting this answer, I see that I've learned some tricks since August! Down to 28 :)

Good thing that duplicate answers have been allowed since August. ;)

#$%^&%#$&^%!@... ;)

C, not 83, 80 bytes
f(n,b,k,z){for(b=1;;){for(z=0,k=b*n;z+=k%10,k/=10;z*=10);if(b++*n==z)return z;}}

For say the true i had seen in one other puzzle one programmer use the same algo number=swapped(number) => number is palindrome. How is possible to edit barred
text?
#include <stdio.h>
main()
{unsigned  a[]={0,1,2,3,16,17,42,111,302,1234}, i;
 for(i=0;i<10;++i)
   printf("f(a[%u])=f(%u)=%u\n", i, a[i], f(a[i], 0, 0, 0));
 return 0;
}

/*
 f(a[0])=f(0)=0
 f(a[1])=f(1)=1
 f(a[2])=f(2)=2
 f(a[3])=f(3)=3
 f(a[4])=f(16)=272
 f(a[5])=f(17)=272
 f(a[6])=f(42)=252
 f(a[7])=f(111)=111
 f(a[8])=f(302)=87278
 f(a[9])=f(1234)=28382
 */

dc, 85 78 76 bytes
[pq]sq?ddsI[dddZ0sR[1-dsD10r^rdsN10%*lR+sRlN10/lDd0<@]ds@xlR++=q+lIrlLx]dsLx

Run:
dc -f program.dc <<< "16"

Output:
272

Previously submitted code and explanation:
    # loads register 'q' with an exit function
[pq]sq
    # register '@' contains an iterative function to reverse a number (312 to 213),
#by calculating one coefficient at a time of the new base 10 polynomial
[1-dsD10r^rdsN10%*lR+sRlN10/lDd0<@]s@
    # register 'L' implements the logic. It iteratively compares the current value
#with the generated reversed one, exiting if equal, otherwise increments the value
#by N and repeats.
[dddZ0sRl@xlR++=q+lIrlLx]sL
    # the "main". It reads the input, then calls the solver function from 'L'.
?ddsIlLx

RProgN, 31 Bytes
►x=01¿1+]x*]''.S.\''.≡!}x*

Explained
►x=01¿1+]x*]''.S.\''.≡!}x*  # ► Defines spaceless segment.
 x=                         # Define the input as x
   01                       # Push 0, 1 to the stack. 1 is used as a truthy for the while, 0 is our incrementing product.
     ¿                 }    # While the value on top of the stack (popped) is truthy.
      1+                    # Increment the product by one.
        ]x*                 # Duplicate the producter, multiply by the input.
           ]''.S.\''.≡!     # Check to see if the result is a palindrome.
           ]''.             # Push a duplicate of the multiplied number, convert to a string.
               S.           # Convert it to a stack and re-concatinate it. This reverses the string.
                 \''.≡!     # Flip the top two values, exposing the original product. Conver it to a string and test inverse equality.
                        x*  # Once the loop ends, the last number times the input will be a palindrome. Thus, do that.

The equality sugar was only added after the discovery of this challenge, as was the bugfix that allowed strings to be used in spaceless segments.
Try it Online!

Racket 174 bytes
(let((p?(λ(m)(equal? m(string->number(list->string(reverse(string->list(number->string m)))))))))
(let loop((N n))(cond[(and(p? N)(= 0(modulo N n)))N][else(loop(add1 N))])))

Ungolfed:
(define (f1 n)
  (let ((p? (λ (m)(equal? m
                          (string->number
                           (list->string
                            (reverse
                             (string->list
                              (number->string m)))))))))
    (let loop ((N n))
      (cond
        [(and (p? N) (= 0 (modulo N n))) N]
        [else (loop (add1 N))]
        ))))

Testing:
(f 1)
(f 2)
(f 16)
(f 17)
(f 42)
(f 111)
(f 302)
(f 1234)

Output:
1
2
272
272
252
111
87278
28382

Ruby, 50 bytes
->n{a=n;while(s=a.to_s;s!=s.reverse)do a+=n;end;a}

It's horrible, I know.

Clojure, 71 bytes
#(first(for[i(rest(range))i[(str(* % i))]:when(=(seq i)(reverse i))]i))

Just one long for with a two-step generation of i.

Mathematica, 28 bytes
#//.x_/;!PalindromeQ@x:>x+#&

Explanation
#//....

Repeatedly apply the following substitution to the input.
x_/;!PalindromeQ@x

Match a value which is not a palindrome.
...:>x+#

And replace that value with itself plus the input. This repeated substitution therefore searches through consecutive multiples of the input until it finds a palindrome.

Japt, 12 bytes
_s ê¬©ZvU}a1

Try it

Alternative
_¥sw «ZuU}aÄ

Try it

Vyxal, 6 bytes
{:Ḃ≠|+

Try it Online!
Same as my Thunno 2 answer.
Explanation
{:Ḃ≠|+  # Implicit input
{       # While loop
 :      # (condition)  duplicate current number
   ≠    #              not equal to
  Ḃ     #              its reverse
    |+  # (body)  add the input
        # Implicit output

Thunno 2, 5 bytes
(ḲQ;+

Try it online!
Explanation
(ḲQ;+  # Implicit input
(      # While loop
  Q    # (condition)  not equal to
 Ḳ     #              its reverse
   ;+  # (body)  add the input
       # Implicit output

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Variable Prime "Twins"
I am 2/3 twins with my brother, i.e. born on the same day of the same month but twelve years later. When I was 5, he was 17, both primes; the last pair of ages we can reasonably count on is [71, 83] with both of us being alive and able to celebrate this coincidental jubilee.
Task
Create a code that

takes two integers as input: the difference between the counter and the "twin" as a positive integer k (well yes, I'm the younger) and the upper bound as a positive integer u (runtime consideration)
and gives output as an array or list of all i numbers lower than or equal u for which both i and i+k are primes. The output does not need to be sorted.

Test Cases
12, 1000 -> [5, 7, 11, 17, 19, 29, 31, 41, 47, 59, 61, 67, 71, 89, 97, 101, 127, 137, 139, 151, 167, 179, 181, 199, 211, 227, 229, 239, 251, 257, 269, 271, 281, 337, 347, 367, 389, 397, 409, 419, 421, 431, 449, 467, 479, 487, 491, 509, 557, 587, 601, 607, 619, 631, 641, 647, 661, 727, 739, 757, 761, 797, 809, 811, 827, 907, 929, 941, 971, 997]
2, 999 -> [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881]
3, 1500 -> [2]
30, 1500 -> [7, 11, 13, 17, 23, 29, 31, 37, 41, 43, 53, 59, 67, 71, 73, 79, 83, 97, 101, 107, 109, 127, 137, 149, 151, 163, 167, 181, 193, 197, 199, 211, 227, 233, 239, 241, 251, 263, 277, 281, 283, 307, 317, 337, 349, 353, 359, 367, 379, 389, 401, 409, 419, 431, 433, 449, 457, 461, 479, 491, 541, 547, 557, 563, 569, 571, 577, 587, 601, 613, 617, 631, 643, 647, 653, 661, 709, 727, 739, 743, 757, 797, 809, 823, 827, 829, 853, 857, 877, 881, 907, 911, 937, 941, 947, 953, 967, 983, 991, 1009, 1019, 1021, 1031, 1033, 1039, 1061, 1063, 1087, 1093, 1123, 1151, 1163, 1171, 1187, 1193, 1201, 1229, 1249, 1259, 1277, 1289, 1291, 1297, 1399, 1409, 1423, 1429, 1451, 1453, 1459, 1481, 1493]

Edit
Since I failed to specify the upper bound, both inclusive and exclusive solutions are welcome.
Edit No. 2
The challenge ends on 1st September, one week from the start.
Looks like we have a winner but in case of a tie popularity is the tie-breaker; in this case the "second" will be compensated via bounty.

Related.

Jelly, 8 7 bytes
+ÆR©_f®

Try it online!
Explanation
+          add the upper bound and the difference
 ÆR        find all primes up to that number
   ©       save that in the register
    _      subtract the difference from each
     f®    remove anything not in the original prime list

Congratulations @Pietu1998 !

Brachylog, 27 23 bytes
:1f
hS,?tye.:S+:.L*$pL,

Try it online!
Verify all testcases.
Predicate 0 (main predicate)
:1f                     Find all solutions of predicate 1
                        given Input as Input,
                        Unify Output with the set of all solutions.

Predicate 1 (auxiliary predicate)
hS,?tye.:S+:.L*$pL,

hS                      the first element of Input is S,
   ?tye.                Output is an element between 0 and
                        the last element of Input,
       .:S+:.L          The list [Output+S,Output] is L,
             L*$pL      The product of L, prime-factorized, is still L

05AB1E, 9 bytes
Code:
LDpÏDI+pÏ

Uses the CP-1252 encoding. Try it online!.

Python 3, 114 92 90 bytes
Thanks to @Dennis for -2 bytes
def f(k,u):
 i=P=1;l={0}
 while i<u+k:l|={P%i*i};P*=i*i;i+=1
 return{i-k for i in l}&l-{0}

A function that takes input via argument and returns an unsorted set. This is exclusive with respect to the upper bound.
This uses the method in @xnor's answer here to find primes.
Try it on Ideone
How it works
Prime finding
We first initialise a test value i and a product P as 1, and a list of primes l as the set containing 0. Then, a while loop that tests all values of i in the range [1, u+k-1] for primality is executed. The idea is that by multiplying P by i^2 at the end of each iteration, P takes the value (i-1)!^2 while testing i, i.e the product of the integers [1, i+1] squared. The actual primality test is then performed by calculating P mod i; if this returns zero, then i cannot be prime since this implies that i is divisible by at least one of the values that make up the product. If this returns 1, then i must be prime since it is not divisible by any of the values in the product. If i is prime, it is appended to l, and if not, 0 is appended. The squaring of the product prevents false identification of 4 as prime, and is useful here since it guarantees that only 0 or 1 will be returned, allowing the choice of the value to be appended to be made by simply multiplying the result by i.
Identification of 'twin' primes
We now create a furter set, containing all the elements of l-k, element-wise. The intersection of this set and l is then found using &, which leaves a set containing only the elements common to both sets. A number i is only in both sets if both i and i+k are prime, meaning that this leaves the desired output. However, if k is prime, 0 will be present in both sets, meaning that this must be removed before returning.

k,u=input();i=P=1;l={0};exec'l|={P%i*i};P*=i*i;i+=1;'*(u+k);print{i-k for i in l}&l works for 83 bytes in Python 2. Even in 3, constructing a set this way should save some bytes.

@Dennis Thanks - this does save a few bytes in Python 3. However, I did have to remove 0 from the final set, since if k is prime, this mistakenly gets returned.

Pyke, 10 bytes
S#_PiQ+_P&

Try it here!
S#         - filter(range(input_2), V) as i
  _P       -   is_prime(i)
         & -  ^ & V
    iQ+    -    i + input_1
       _P  -   is_prime(^)

Also 10 bytes:
S#_DP.IQ-P

Try it here!

Another 10-byte.

@LeakyNum that's actually really clever!

Octave, 34 33 bytes
@(k,u)(a=primes(u))(isprime(a+k))

Great approach! It allowed me to reduce frrom 11 to 8 bytes in my answer

MATL, 8 bytes
Credit to @alephalpha for his approach, which helped me save 3 bytes
Zqti+Zp)

Try it online!
Zq    % Take input implicitly. Vector of primes up to that. Call this vector A
ti+   % Duplicate, take second input, add element-wise. Call this vector B
Zp    % Vector containing true for prime numbers in B
)     % Use as an index into A. Display implicitly

R, 98 bytes
function(k,u){v=c();for(i in 1:u)if(sum(i%%(1:i)==0)==2&&sum((i+k)%%(1:(i+k))==0)==2){v=c(v,i)};v}

Ungolfed :
function(k,u)
v=c()                                                    #Empty vector

for(i in 1:u)
    if(sum(i%%(1:i)==0)==2&&sum((i+k)%%(1:(i+k))==0)==2) #If both i and i+k only have
                                                         #2 divisors such as the rest of the
                                                         #euclidian division is 0
                                                         #(i.e., they're both prime) :
        v=c(v,i)
v

CJam, 17 bytes
Either as a full program:
q~{_mp\W$+mp&},p;

Try it online!
Or as an unnamed block:
{:X;{_mp\X+mp&},}

Try it online!

Mathematica, 43 bytes
(Prime@Range@PrimePi@#2+#)~Select~PrimeQ-#&

Generate all primes less than or equal to the upper bound. Add the difference of ages to the result. Select prime numbers among them. Subtract the difference of ages to the result.

Swift, 142 bytes
func f(a:Int,b:Int)->Array<Int>{let p={(n:Int)->Int in([Int]()+(2..<n)).filter{n%$0<1}.count}
return([Int]()+(2...b)).filter{p($0)+p($0+a)<1}}

Perl 6,  39  37 bytes
->\k,\u{grep {($_&$_+k).is-prime},2..u}

->\k,\u{grep {($_&$_+k).is-prime},^u}

Explanation:
-> \k, \u {

  # find all the values
  grep

  # where
  {
    # ｢all｣ junction of the two values
    ( $_   &   $_ + k ) # ｢ all( $_, $_ + k ) ｣

    # autothread a method call against the junction
    .is-prime
  },

  # from the values up to (and excluding) ｢u｣
  ^ u # short for ｢ 0 ..^ u ｣
  # for inclusive use ｢ 2 .. u ｣

}

Java 7, 185 175 bytes
import java.util.*;List c(int k,int u){List l=new ArrayList();for(int i=1;++i<u;)if(p(i)&p(i+k))l.add(i);return l;}boolean p(int n){for(int i=2;i<n;)n=n%i++<1?0:n;return n>1;}

Ungolfed & test code:
Try it here.
import java.util.*;
class M{
  static List c(int k, int u){
    List l = new ArrayList();
    for(int i = 1; ++i < u; ){
      if(p(i) & p(i+k)){
        l.add(i);
      }
    }
    return l;
  }

  static boolean p(int n){
    for(int i = 2; i < n; ){
      n = n % i++ < 1
           ? 0
           : n;
    }
    return n>1;
  }

  public static void main(String[] a){
    System.out.println(c(12, 1000));
    System.out.println(c(2, 999));
    System.out.println(c(3, 1500));
    System.out.println(c(30, 1500));
  }
}

Output:
[5, 7, 11, 17, 19, 29, 31, 41, 47, 59, 61, 67, 71, 89, 97, 101, 127, 137, 139, 151, 167, 179, 181, 199, 211, 227, 229, 239, 251, 257, 269, 271, 281, 337, 347, 367, 389, 397, 409, 419, 421, 431, 449, 467, 479, 487, 491, 509, 557, 587, 601, 607, 619, 631, 641, 647, 661, 727, 739, 757, 761, 797, 809, 811, 827, 907, 929, 941, 971, 997]
[3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881]
[2]
[7, 11, 13, 17, 23, 29, 31, 37, 41, 43, 53, 59, 67, 71, 73, 79, 83, 97, 101, 107, 109, 127, 137, 149, 151, 163, 167, 181, 193, 197, 199, 211, 227, 233, 239, 241, 251, 263, 277, 281, 283, 307, 317, 337, 349, 353, 359, 367, 379, 389, 401, 409, 419, 431, 433, 449, 457, 461, 479, 491, 541, 547, 557, 563, 569, 571, 577, 587, 601, 613, 617, 631, 643, 647, 653, 661, 709, 727, 739, 743, 757, 797, 809, 823, 827, 829, 853, 857, 877, 881, 907, 911, 937, 941, 947, 953, 967, 983, 991, 1009, 1019, 1021, 1031, 1033, 1039, 1061, 1063, 1087, 1093, 1123, 1151, 1163, 1171, 1187, 1193, 1201, 1229, 1249, 1259, 1277, 1289, 1291, 1297, 1399, 1409, 1423, 1429, 1451, 1453, 1459, 1481, 1493]

PARI/GP, 39 bytes
k->u->[x|x<-primes([1,u]),isprime(x+k)]

S.I.L.O.S, 205 bytes
GOTO b
funce
n = p
p - 1
f = 1
lbla
f * p
f % n
p - 1
if p a
return
lblb
readIO
s = i
readIO
i - 2
lblc
i + 1
p = i
GOSUB e
F = f
p = i
p + s
GOSUB e
F * f
if F g
GOTO h
lblg
printInt i
lblh
i - 2
if i c

Try it online!
Primalty test by Wilson's theorem.

Javascript (ES6), 90 83 80 75 bytes
(k,u)=>(r=n=>n++<u+k?r(P[P.every(i=>n%i)*n]=n):P.filter(n=>P[n+k]))(1,P=[])

Example:

let F =
(k,u)=>(r=n=>n++<u+k?r(P[P.every(i=>n%i)*n]=n):P.filter(n=>P[n+k]))(1,P=[])

console.log(F(2, 999))

Actually, 12 bytes
Input is u then k. Golfing suggestions welcome. Try it online!
╖R`;p@╜+p*`░

Ungolfing:
╖              Store k in register 0.
 R             Range [1..u]
  `       `░   Start a function f and push values i of the range where f(i) is truthy.
   ;p@         Duplicate i, check if i is prime, and swap with the other i.
      ╜+p      Push k, add to i, check if i+k is prime.
         *     Multiply the two if results together.
                 Similar to logical AND. 1 if both are true, else 0.

R, 104 bytes
Unlike the other R solution posted, this one takes input from stdin.
s=scan();sapply(1:s[2],function(i){j=i+s[1];if((all(i%%(3:i-1)!=0)|i==2)&all(j%%(3:j-1)!=0))cat(i," ")})

Ungolfed:
s=scan();        # Read from stdin
sapply(1:s[2],   # For i from 1 to u,
    function(i){     # apply this function:
        j=i+s[1];                # Define i+k
        if((all(i%%(3:i-1)!=0)   # Test if i is prime
           | i==2)               # (i is prime if i==2)
           & all(j%%(3:j-1)!=0)) # Test if i+k is prime
        cat(i," ")               # If i and i+k are prime, print i
    }
)

Pyth, 13 bytes
f&P_TP_+ThQSe

A program that takes input of a list of the form [k, u] and prints a list.
Try it online
How it works
f&P_TP_+ThQSe  Program. Input: Q
           Se  1-indexed range up to Q[1], yielding [1, 2, 3, ..., u]
f              Filter that, using variable T, by:
  P_T           T is prime
 &              and
     P_+ThQ     T+Q[0], i.e. T+k, is prime
               Implicitly print

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Highlight the Bounding Box, Part I: Cartesian Grid
You're given a rectangular grid of the characters . and #, like this:
..........
..#.......
....#..#..
...#......
..........

Your task is to fill the entire axis-aligned bounding box of the # with further #:
..........
..######..
..######..
..######..
..........

The axis-aligned bounding box is the smallest rectangle which contains all the #.
Want more? Try Part II!
Rules
You may use any two distinct printable ASCII characters (0x20 to 0x7E, inclusive), in place of # and .. I'll continue referring to them as # and . for the remainder of the specification though.
Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.
You may assume that the input contains at least one # and all lines are the same length.
You may write a program or a function and use any of the our standard methods of receiving input and providing output.
You may use any programming language, but note that these loopholes are forbidden by default.
This is code-golf, so the shortest valid answer – measured in bytes – wins.
Test Cases
Each test case has input and output next to each other.
#    #

...    ...
#..    #..
...    ...

...    ...
#..    ###
..#    ###

.#.    ###
#..    ###
..#    ###

.....    .....
.#.#.    .###.
.....    .....

...    ...
.#.    .#.
...    .#.
.#.    .#.
...    ...

..........    ..........
..........    ..........
....#.....    ....#.....
..........    ..........

..........    ..........
..........    ..........
....#.....    ...##.....
...#......    ...##.....

..........    ..........
..#.......    ..###.....
....#.....    ..###.....
...#......    ..###.....

..........    ..........
..#.......    ..######..
....#..#..    ..######..
...#......    ..######..

.........#    ..########
..#.......    ..########
....#..#..    ..########
...#......    ..########

What do you mean by "the format has to be consistent"? Does the input format need to be consistent with the output format or does it mean that the input format need to be consistent and the output format also need to be consistent?

@Emigna the input and output formats need to be the same.

@MartinEnder My program inputs a 2D char array and processes it. The outcome is still a 2D char array, but that is displayed by default as the array's contents, i.e. strings separated by newlines. Is that acceptable? Or should the displayed output be a string representation of that 2D array?

@LuisMendo I'd expect a string representation of the type. Whether the linefeed-separated strings are the natural string representation of the nested array in your language I can't say. (Although, since that doesn't appear to be a "reversible" representation, since your input format is different, probably not.)

is graphical output allowed?

@12Me21 No, I think ASCII art and graphical output shouldn't be mixed.

VBA Excel, 150 bytes 146 bytes
Instruction:
Create a workbook with two blank worksheets: Sheet1 and Sheet2. Set the input in Sheet1 and then put the following code in the Sheet1 code module
Sub A:For Each C In UsedRange:If C.Value="#"Then Sheet2.Range(C.Address)="#"
Next:For Each C In Sheet2.UsedRange:Range(C.Address)="#":Next:End Sub

Ungolfed the code:
Sub A()

For Each C In UsedRange
    If C.Value = "#" Then Sheet2.Range(C.Address) = "#"
Next

For Each C In Sheet2.UsedRange
    Range(C.Address) = "#"
Next

End Sub

Explanation:

Loop through every cell in the used range Sheet1
Set the conditional statement to copy every cell contains character hashtag (#) in the used range Sheet1 and paste it to the cell in Sheet2 with the same address as Sheet1.
Loop through once again every cell in the used range Sheet2 to copy every cell address in it and then use it to assign character hashtag (#) to the cell in Sheet1 with the same address as the used range Sheet2.

Example I/O:

Caveat: Make sure every cell in Sheet2 always blank every time you run the program.

Could =C.Value in the first line be ="#"?

@Riley Yes, it could. Thanks.

It seems I can save a  few more bytes by deleting the Sub and End Sub parts, then running the program in the Immediate Window. I'll try it tommorow whether it works or not. Could not access Excel right now...

But would that still count as a program or function if you did that?

@Neil Dunno about the formal definition but for me, a program is a set of instructions and it still works like normal program if we put the code in the Immediate Window although there are limitations. One of them is this code cannot be executed there. Ha-ha :D

I think it might have counted as a standard loophole.

I cannot seem to get the lone UsedRange call to compile, do you perhaps mean Sheet2.UsedRange

@TaylorScott "...in the Sheet1 code module".

05AB1E, 70 68 69 61 58 60 40 bytes
€S`¹gG~}Dg©L*0KŸ<U¹v¼y1åi®FXNå}ë0®×}J}¾ä

Explanation
€S`                                       # split each string in input to a charlist and place separately on stack
   ¹gG~}                                  # OR the char arrays to produce a single list with 1's in the columns that have 1's and 0 in the rest
        Dg L*                             # multiply by indices (1-indexed)
          ©                               # store row length in register
             0K                           # remove 0's (the indices which should not have 1's
               Ÿ<U                        # store a list of the indices that should have 1's in X
                  ¹v                 }    # for each string in input
                    ¼                     # increase counter
                     y1åi      ë   }      # if the row contains at least one 1
                         ®FXNå}           # push 1 for indices which should have 1 and else 0
                                0®×       # else push a row of 0's
                                    J     # join into a string
                                      ¾ä  # split the string in rows

Try it online

Mathematica, 91 70 bytes
21 bytes saved due to @MartinEnder.
ReplacePart["."+0#,Tuples[Range@@@MinMax/@(#~Position~"#")]]->"#"]&

Anonymous function. Takes a character matrix as input an returns a character matrix as output. The Unicode character is U+F3C7 for \[Transpose].

Jelly, 21 19 18 17 bytes
|/Tr/FṬ|
ỴµZÇZ&ÇY

This is a full program. Input and output are strings of 0's and 1's, delimited by linefeeds.
Try it online! or verify all test cases.
How it works
ỴµZÇZ&ÇY  Main link. Argument: s (string)

Ỵ         Split s at linefeeds into the array A.
 µ        Begin a new, monadic chain. Argument: A
  Z       Zip/transpose A.
   Ç      Apply the helper link to the transpose.
    Z     Zip/transpose to restore the original order.
      Ç   Apply the helper link to A.
     &    Take the bitwise AND of both results.
       Y  Join, separating by linefeeds.

|/Tr/FṬ|  Helper link. Argument: A (array of strings)

|/        Reduce A columnwise by bitwise OR. This casts to integer.
  T       Truth; yield the indices of 1's.
   r/     Reduce by range. This yields an exponentially growing, nested, ragged
          array that contains all integers between the lowest and highest index
          in the previous result, at least once but possibly multiple times.
     F    Flatten the result.
      Ṭ   Untruth; yield an array with 1's at the specified indices.
          Multiple occurrences of the same index are ignored.
       |  Take the bitwise OR of the result and each row of A.

Retina, 87 bytes
Byte count assumes ISO 8859-1 encoding.
Tm`A` `^\GA+¶|(¶A+)+\Z|^(A+?)(?<=(?=\D*^\2Z)\A\D*)|(A+)$(?=\D*\Z(?<!(?<!\3)$\D*))
T`p`L

Uses A for . and Z for #.
Try it online!

C#, 262 251 bytes
s=>{int l,t,r,b,i,j,k;l=t=r=b=i=-1;for(;++i<s.Length;){j=s[i].IndexOf('#');if(j>-1){k=s[i].LastIndexOf('#');l=l==-1|j<l?j:l;t=t==-1?i:t;r=k>r?k:r;b=i;}}for(i=t;i<=b;++i)for(j=l;j<=r;){var c=s[i].ToCharArray();c[j++]='#';s[i]=new string(c);}return s;};

Will golf it further when I have more time.
It compiles into a Func<string[], string[]>.
Formatted version:
s =>
{
    int l, t, r, b, i, j, k;
    l = t = r = b = i = -1;

    for (; ++i < s.Length;)
    {
        j = s[i].IndexOf('#');
        if (j > -1)
        {
            k = s[i].LastIndexOf('#');

            l = l == -1 | j < l ? j : l;

            t = t == -1 ? i : t;

            r = k > r ? k : r;

            b = i;
        }
    }

    for (i = t; i <= b; ++i)
        for (j = l; j <= r;)
        {
            var c = s[i].ToCharArray();
            c[j++] = '#';
            s[i] = new string(c);
        }

    return s;
};

PowerShell v3+, 215 162 148 144 139 bytes
param($n)$n|%{(((-join(0..($n[0].length-1)|%{$i=$_;+('1'-in(0..($n.length-1)|%{$n[$_][$i]}))}))-replace'(?<=1.*?).(?=.*?1)',1),$_)[0-ge$_]}

Takes input as an array of strings $n, with 0 instead of . and 1 instead of #. Then, we loop through $n, each iteration testing whether the current string is smaller than 0 (i.e., there's a 1 in it), and if so, output a string. Uses a pseudo-ternary in place of an if/else operation.
The string is constructed from loops through the width of the input string. Each iteration, we tack on a 0 or a 1 depending upon if 1 is found somewhere in the corresponding vertical column. For the last test case, for example, this will result in a string like 0011001001. Requires v3+ for the -in operator. That string is paired with a fancy-dancy regex replace to replace any "inner" 0s with 1s. Much thanks to Business Cat in chat for the assist on that. Our string would be 0011111111 at this point.
Else, output the current (all-zeros) string $_.
The resulting strings are left on the pipeline, and output is implicit. The default Write-Output for an array of strings is with a newline between each element, so that's visually what happens.
Examples
PS C:\Tools\Scripts\golfing> .\highlight-the-bounding-box-cartesian.ps1 '0000000001','0010000000','0000100100','0001000000'
0011111111
0011111111
0011111111
0011111111

PS C:\Tools\Scripts\golfing> .\highlight-the-bounding-box-cartesian.ps1 '0000000000','0000000000','0000100000','0001000000'
0000000000
0000000000
0001100000
0001100000

R, 158 155 bytes
This program takes in input points . and hashtags #, line by line.
v=c();f=which((d=matrix(strsplit(paste0(a<-scan(,""),collapse=""),"")[[1]],nr=sum(a<0),b=T))=="#",a=T);d[min(f[,1]):max(f[,1]),min(f[,2]):max(f[,2])]="#";d

Ungolfed :
a<-scan(,"")             #Input

v=c()                   #Empty vector
f=which((d=(matrix(strsplit(paste0(a,collapse=""),"")[[1]],nr=length(a),b=T)))=="#",a=T) #Main work is here !

d[min(f[,1]):max(f[,1]),min(f[,2]):max(f[,2])]="#"                        #Creates
                                                                          #the new figure

d                       #Displays it

Here are the details of the third line :
paste0(a,collapse="")
#Collapses the input into a single string

strsplit(paste0(a,collapse=""),"")[[1]]
#Split this string character-wise

matrix(strsplit(paste0(a,collapse=""),"")[[1]],nr=sum(a<0),b=T)
#Creates and fills (by row) a matrix with number of row the number of line of the input

which((d=(matrix(strsplit(paste0(a,collapse=""),"")[[1]],nr=l,b=T)))=="#",a=T)
#Gives the index of the matrix's elements that are "#"

Perl, 51 bytes
Includes +2 for -0p
Give input on STDIN, off character is A, on character is a, e.g.:
bounding.pl
AAAAAAAAAA
AAaAAAAAAA
AAAAaAAaAA
AAAaAAAAAA
AAAAAAAAAA
^D

bounding.pl:
#!/usr/bin/perl -0p
s%(?=\D*a).+%$a|=$&%eg;s%.*a.*%$a%g;s/a.*a/\L$&/g

Same length:
#!/usr/bin/perl -0p
s%.+%${a./a/g}|=$&%eg;s%.*a.*%$a1%g;s/a.*a/\L$&/g

Scala, 317 characters
val a=input.split("\n");val e=a.map{s=>(s.indexOf("#"),s.lastIndexOf("#"))}.zipWithIndex.filter(_._1._1!= -1);val b=(e.map{s=>s._1._1}.min,e.map{s=>s._1._2}.max,e.head._2,e.last._2);print((0 to a.length-1).map{y=>(0 to a(y).length-1).map{x=>if(x>=b._1&&x<=b._2&&y>=b._3&&y<=b._4)"#" else "."}.mkString+"\n"}.mkString)

More readable version, could probably have golfed it more:
val a=input.split("\n")
val e=a.map{s=>
    (s.indexOf("#"),s.lastIndexOf("#"))
}.zipWithIndex        // Need the indexes for the Y values
.filter(_._1._1!= -1) // Ugly because of tupleception: (actual tuple, index)

val b=(
    e.map{s=>s._1._1}.min,
    e.map{s=>s._1._2}.max,
    e.head._2,
    e.last._2)

print(
    (0 to a.length-1).map{y=>
        (0 to a(y).length-1).map{x=>
            if(x>=b._1&&x<=b._2&&y>=b._3&&y<=b._4)"#"
            else "."
        }.mkString+"\n"
    }.mkString
)

JavaScript (ES6), 168 bytes
s=>/^#/gm.test(s)?/#$/gm.test(s)?s.replace(/^.*#[^]*#.*$/m,s=>s.replace(/./g,'#'))?f(s.replace(/.$/gm,'')).replace(/$/gm,'.'):f(s.replace(/^./gm,'')).replace(/^/gm,'.')

Takes input as a multiline string. Works by recursively stripping leading and trailing .s from all lines until at least one line begins and one ends with a #, then selects as many lines as possible but starting and finishing on lines containing # and changes all the .s to #. Probably readily golfable.

Perl 6, 62 bytes
{.[.grep(/a/,:k).minmax;$_».grep('a',:k).flat.minmax]='a'xx*}

An anonymous routine that can be passed an array of arrays of characters (representing the matrix) as argument, and modifies it in-place so that the calling scope has the modified array afterwards.
Uses a instead of # as the "on" character. The "off" character can be anything, it doesn't care.

Python 3, 153 bytes
r=lambda w:list(zip(*w[::-1]))
f=lambda w,n=4:list(map(''.join,n and(('#'in w[0])and r(r(r(f(r(w),n-1))))or[w[0]]+foo(w[1:],n))or['#'*len(w[0])]*len(w)))

Input and output are a list of strings.
ungolfed
r=lambda w:list(zip(*w[::-1]))   # rotate grid cw 90 degrees

def f(w,n=4):
    if n:
        if '#' in w[0]:
            u = r(r(r(f(r(w), n-1))))

        else:
            u = [w[0]] + foo(w[1:], n)

    else:
        u = ['#'*len(w[0])]*len(w)

 return list(map(''.join,u))

theory of operation
The main idea is to remove rows and columns around the outside of the array if they don't have a '#'.  Whatever is left should be filled in with '#'s.
It is implemented using a recursive function.
Case 1: row 0 doesn't contain a '#'. Result is row 0 + recursive call on remaining rows.
Case 2: row 0 does contain a '#'.  No more rows can be removed.  Rotate array cw so that column 0 is now row 0.  Then recursively process the rotated array.  The result is rotated ccw.
Base case: The array has been rotated 4 times, meaning that all outer rows/columns have been removed if possible.  Whatever remains should be filled in with '#'s

Python 2, 184 bytes
def c(i):
 m=n=();e,z=enumerate,'for j,r in e(i):\n for k,c in e(r):%s'
 exec z%'\n  if"#"==c:m+=j,;n+=k,'
 exec z%'\n  if min(m)<=j<=max(m)<[]>min(n)<=k<=max(n):i[j][k]="#"'
 return i

Input and output are a list of strings.
Try it on Ideone (fork of Jonathan Allan's test page)

Python, 219 212 bytes
def b(a):j=len(a[0]);g=range;z=g(len(a));h=[i for i in z if'#'in a[i]];w=[i for i,c in[(i,[r[i]for r in a])for i in g(j)]if'#'in c];return[[any((r<h[0],h[-1]<r,c<w[0],w[-1]<c))and'.'or'#'for c in g(j)]for r in z]

(Although I think another method may well be shorter)
Takes and returns a list of list of chars.
Test it on ideoone

Pyth, 50 bytes
L}hbebjuXGhHX@GhHeH\#*yhMJs.e,Lkfq\#@bTUb.zySeMJ.z

Try it online!


text:
Draw the Union Jack
Preface
There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the union Jack! I feel like this would be a harder flag to draw but it should still be possible.
Challenge
Draw the Union Jack. It can be outputted to a file in any freely available graphics file format or drawn onto the screen.

Code Golf rules apply, shortest code in bytes wins.
Standard loopholes apply.
No builtins for flag drawing allowed.

Dimensions shall be as below. Minimum size 600x300 pixels (or units if your language supports only scalable graphics.) Maximum error 1 pixel.
Colours shall be red, white and blue as defined by your language or its documentation, or #CC0000, #FFFFFF and #003399 per Wikipedia page.

Related, ASCII version

"There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the" could be followed by any of thousands of national, organisational, state, etc. flags. What does this flag have which makes drawing it a fundamentally different challenge from all of the existing [tag:graphical-output] questions?

This is a lot like the Iceland flag challenge, however I find this one has a particular twist in the construction of the diagonal stripes.  Since they have rotational symmetry but not exact reflective symmetry, it adds an extra layer to the complexity.  Most of the strategies for the Iceland flag would not be a simple conversion to get this one.

Not harder than the Portuguese flag!

BBC BASIC
Rev B, 234 bytes
Instead of drawing one white and one red cross, we draw 100 progressively narrower crosses, switching from white background to red foreground at a coordinate of 60.
p=20761m=1049w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.F.c=-100TO0q=25881-c DIV60*512V.m;-c;-h;q;c;h;m;-w;-c;q;w;c;
N.

Download interpreter free at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
Fully golfed, 249 bytes
Single byte VDU codes e.g 25,0 combined into double-byte little endian e.g 25; and maximum use of constants for common values. Keywords compressed to abbreviated form, e.g. FOR=>F. (interpreter expands automatically.)
p=20761q=26393r=25881m=1049c=100w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.V.m;-c;-h;q;c;h;2m;-w;-c;q;w;c;m;-60;-h;r;60;h;m;-w;-60;r;w;60;

Semigolfed
Raw VDU codes. In BBC BASIC, characters can be sent to the VDU controller like VDU65 (prints an A.) There are certain special characters particular to the BBC for graphics. These must be followed by several other bytes to specify coordinates, etc. Here we use PLOT=>VDU25, GCOL=>VDU18, ORIGIN=>VDU29.
  c=100w=600h=300                                      :REM constants 100,width,height
  FORi=-1TO1                                           :REM loop -1 and 1 (0 draws nothing)
    VDU29,w;h;                                         :REM set origin (bring inside loop for golfing reasons)
    VDU18;4                                            :REM change to blue and draw triangles
    VDU25,4,134*i;0;25,4,w*i;-233;25,81,0;466;25,4,0;67*i;25,4,-466;h*i;25,81,932;0;
    VDU18;1                                            :REM change to red and draw parallelograms
    VDU25,4,511*i;h*i;25,0,89*i;0;25,117,0;0;25,4,w*i;-h*i;25,113,0;45*i;
  NEXT
  VDU25,4,-c;-h;25,103,c;h;25,4,-w;-c;25,103,w;c;      :REM draw white background rectangles
  VDU25,4,-60;-h;25,101,60;h;25,4,-w;-60;25,101,w;60;  :REM draw red foreground rectangles

First we draw half the diagonal parts: 2 blue triangles and 2 red parallelograms. Then we change the scale from -1 to +1 and draw the other half. Finally we draw the horizontal and vertical parts on top: 2 white rectangles to form a white cross, then 2 red rectangles. The image after the first iteration of the loop is shown below, along with the final image.

Ungolfed code
BBC basic remembers the last 2 locations of the graphics cursor. PLOT81 draws a triangle between the new coordinates specified and these last two locations. PLOT113 and PLOT117 draw a parallelogram in a similar way: three corners of the parallelogram have to be given in the order they are found going round the perimeter. The last three bits of the PLOT code define whether the given coordinates are absolute or relative, and whether foreground or background colour is used. The more significant bits define what type of shape is drawn (point, line, triangle, parallelogram, rectangle, etc.)
  ORIGIN600,300       :REM move the origin (which will be centre of flag) away from the corner of the screen.

  FORi=-1TO1          :REM at scales of -1 and 1, plot half each of the diagonal parts (i=0 plots nothing).
    GCOL0,4             :REM blue foreground colour
    PLOT4,134*i,0       :REM absolute move to peak of upper/lower triangle
    PLOT4,600*i,-233    :REM absolute move to left hand corner
    PLOT81,0,466        :REM relative move to right hand corner, plotting triangle

    PLOT4,0,67*i        :REM absolute move to peak of left/right triangle
    PLOT4,-466,300*i    :REM absolute move to lower corner
    PLOT81,932,0        :REM relative move to upper corner, plotting triangle

    GCOL0,1             :REM red foreground colour
    PLOT4,511*i,300*i   :REM absolute move to long edge of flag
    PLOT0,89*i,0        :REM relative move to corner of flag (top right / bottom left)
    PLOT117,0,0         :REM absolute move to centre of flag, plotting parallelogram (stripe)
    PLOT4,600*i,-300*i  :REM absolute move to corner of flag (bottom right / top left)
    PLOT113,0,45*i      :REM relative move to short edge of flag, plotting parallelogram (stripe)
  NEXT                :REM diagonal parts completed, now plot vertical/horizontal parts on top.

  PLOT4,-100,-300     :REM move to bottom left of vertical white stripe
  PLOT103,100,300     :REM move to top right corner, plot it in background colour (white)
  PLOT4,-600,-100     :REM move to bottom left corner of horizontal white stripe
  PLOT103,600,100     :REM move to top right corner, plot it in background colour (white)

  PLOT4,-60,-300      :REM move to bottom left of vertical red stripe
  PLOT101,60,300      :REM move to top right corner, plot it in foreground colour (red)
  PLOT4,-600,-60      :REM move to bottom left corner of horizontal red stripe
  PLOT101,600,60      :REM move to top right corner, plot it in foreground colour (red)

The right language (name) for the task :-D

SVG, 298 bytes
score excludes 3 unnecessary newlines added for clarity.
<svg xmlns="http://www.w3.org/2000/svg">
<path d="M67,0h466L0,267v-234L533,300h-466L600,33v232z" fill="blue"/>
<path d="M0,0v22L300,172L45,300h-45L600,0h-45L300,128L600,278v22z" fill="red"/>
<path d="M-10,110h270v-120h80v120h270v80h-270v120h-80v-120h-270z" fill="red" stroke="#fff" stroke-width="20"/>

Inspired by Siren's deleted answer (and in particular the saving in bytes from omitting </svg> at the end of the document), I came up with an SVG that is both dimensionally correct and slightly shorter.
It consists of a blue path and a red path (filled, without strokes) for the diagonal parts and a red path (filled, with 20 unit white border) for the final cross. Because of the thickness of the white border, the specified dimensions of the cross must exceed the required dimensions by 10 all around.
This works fine for me in Microsoft IE and Edge. Sometimes displays an "extra content at the end of the document" warning in Chrome.
Here's how it appears without and with the final cross. 8 points are required to describe the blue path, 10 points to describe the red path, and 12 points for the final cross. The intersections of straight lines within the first two paths do not have to be given.

SVG is an image format, not a programming language

@Mego there are quite a few SVG submissions on this site. It's actually more challenging to do it without the benefit of loops. Perhaps I should apply the following argument as used by the great Peter Taylor here: http://codegolf.stackexchange.com/questions/19050/olympic-games-logo-free-style-edition/19100#19100 though I was reluctant to do so as I don't know PHP: PS If anyone wants to argue that SVG isn't a programming language (and I'd be very inclined to agree), consider this a PHP program in the style of many PHP submissions to this site which just echo literal text.

Processing, 312 bytes
This is the type of puzzle where Processing is pretty efficient.
int a=300,b=2*a,c=255,d=100;size(b,a);background(0,51,153);stroke(c);strokeWeight(60);line(0,a,b,0);line(0,0,b,a);stroke(c,0,0);strokeWeight(20);line(0,310,a,160);line(-22,0,a,160);line(a,139,b,-12);line(a,139,624,a);noStroke();fill(c);rect(250,0,d,b);rect(0,d,b,d);fill(c,0,0);rect(270,0,60,b);rect(0,120,b,60);

Results in:

Logo, 260 239 bytes
(XLogo Interpreter)
I used the Java-based XLogo interpreter since it was one of the few Logo implementations I could find which supports setting the output window size.
The XLogo editor normally saves files as procedures which are meant to be called.  This program is written to be pasted into the immediate window instead.  This saves about 9 bytes.
window setscreensize[600 300]setsc 4 lt atan 2 repeat 2[repeat 2[setpc 7 setpw 60 fd 400 setpw 20 lt 90 fd 10 lt 90 setpc 1 fd 400 lt 90 fd 10 rt 90]lt asin .8]home wrap setpw 100 setpc 7 repeat 2[repeat 2[fd 600 lt 90]setpw 60 setpc 1] ht

Since exact colors weren't required, I regolfed this to use built-in color numbers which saved several bytes.  If you want to see a version with exact RGB colors, check the revisions.  I also substituted a trigonometric calculation with a shorter equivalent.

Ungolfed with commentary
The only real trickery here is changing colors for the second pass of a loop, and taking advantage of the wrap feature which allows us to draw the horizontal stripes with very little effort.  Since the flag height and width are both factors of 600, we can go forward 600 for either vertical or horizontal stripes and end up back at the center again.  This avoids having separate cases for each, even if it does draw the vertical bar twice as often.  We're saving code space, not clock-cycles.
to UnionJack
  #Initialize the screen
  window  #Allow the turtle to overshoot the boundary without reappearing on the opposite side
  setscreensize[600 300]
  setsc 4  #blue background

  lt atan 2 #Turn left, preparing to draw first diagonal
  repeat 2 [ #Draw 2 sets of main diagonal bars
    repeat 2 [ #Each main bar is made of 2 spokes
      setpc 7 setpw 60 #Use a wide white pen
      fd 400 #Draw past the corner of the window
      setpw 20 #Make the pen narrow
      lt 90 fd 10 lt 90 #Do a 10px U-turn
      setpc 1 #Switch to a red pen
      fd 400 #Draw back to the center.
      lt 90 fd 10 rt 90 #Do a 10 px S curve back to center, ready to draw the opposite spoke
    ] #Finish spoke
    lt asin .8 #Turn for the next bar.
  ] #Finish bar
  home #Return to a sane heading
  wrap #Makes the turtle wrap to the opposite side if it overshoots the boundary
  setpw 100 setpc 7 #Wide white pen
  repeat 2 [ #Draw 2 crosses
    repeat 2 [ #Each cross has 2 stripes
      fd 600 #Overshoot the boundary so that we end up where we started at the center, leaving a stripe behind
      lt 90 #Rotate to draw the next stripe
    ] #Finish the stripe
    setpw 60 setpc 1 #Change to a narrow red pen
  ] #Finish cross
  ht #Hide the turtle
end

Postscript (175 bytes)
00000000: 880a 880a 928b 3020 3092 6b30 881e 9263  ......0 0.k0...c
00000010: 883c 3330 9263 883c 3092 6392 1692 142f  .<30.c.<0.c..../
00000020: 727b 2e38 8800 3092 9d7d 9233 2f77 7b31  r{.8..0..}.3/w{1
00000030: 8801 3192 9d7d 9233 924e 3220 3192 8b30  ..1..}.3.N2 1..0
00000040: 202e 3220 2e36 929d 3020 3088 1e33 3092   .2 .6..0 0..30.
00000050: 8088 0f31 3592 ad34 3592 8834 7b77 8800  ...15..45..4{w..
00000060: 2d32 2e36 3888 1e35 2e33 3792 8072 8800  -2.68..5.37..r..
00000070: 3088 1e31 2e37 3992 8039 3092 887d 9283  0..1.79..90..}..
00000080: 924d 881e 3135 92ad 327b 7788 fb88 e288  .M..15..2{w.....
00000090: 0a36 3092 8039 3092 887d 9283 327b 7288  .60..90..}..2{r.
000000a0: fd88 e236 883c 9280 3930 9288 7d92 83    ...6.<..90..}..

Non-tokenized version:
10 10 scale
0 0 moveto
0 30 lineto
60 30 lineto
60 0 lineto
closepath
clip
/r {.8 0 0 setrgbcolor} def
/w {1 1 1 setrgbcolor} def
gsave
2 1 scale
0 .2 .6 setrgbcolor
0 0 30 30 rectfill
15 15 translate
45 rotate
4 {w 0 -2.68 30 5.37 rectfill r 0 0 30 1.79 rectfill 90 rotate} repeat
grestore
30 15 translate
2 {
w
-5 -30 10 60 rectfill
90 rotate
} repeat
2 {
r
-3 -30 6 60 rectfill
90 rotate
} repeat

Output:

The thick diagonal white stripes are thicker than the central horizontal/vertical red cross, but they should have the same width. And all four thin diagonal red strips should meet the horizontal/vertical white strips in sharp points, but the NE/SW strips do not.

It should be fixed now

The white diagonals are thinner but still look too thick compared to the reference drawing :-(

HTML/CSS, 742 bytes
A very unclever CSS implementation using three HTML elements.

See it unminified on CodePen.

C (gcc), 248 229 224 bytes
-24 bytes thanks to @ceilingcat
#define p putchar(c?c-1
i=-151,j,I,J;main(c){for(puts("P6 600 300 255 ");++i<150;)for(j=-301;++j<300;p?0:255:204))c=(c=fmin(I=abs(i),J=abs(j)))<30?0:c<50?:(c=i*j>0?J-2*I:2*I-J)>0&c<35?0:c*c<2704?:2,p?51:255:0),p?153:255:0);}

Try it online!
Outputs a PPM image.

Python 2, 265 bytes
r="D\0\0"
b="\0\x173"
w="U"*3
N=20*(270*w+60*r+270*w)
L=190*[b]+60*[w]+40*[r]+20*[w]+190*[b]
j=''.join
F=lambda p:j([j(L[150-p*100+i:150+p*150+i:p])+20*w+60*r+20*w+j(L[345-p*145-i:345+p*105-i:p])for i in range(0,200,2)])
print"P6 600 300 85 "+F(-1)+N+36000*r+N+F(1)

Output as binary PPM, usage:
python golf_unionjack.py > unionjack.ppm

L represents a vertical slice of the diagonal parts and F uses the (sort of) symmetry to save code and calculate the indices for upper and lower part.


text:
Creating a Crossed Square
Creating a Crossed Square
You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.
The general idea is for the output to be a hollow square that has a diagonal cross through it.:
Input: 7
Output:
*******
*#   #*
* # # *
*  #  *
* # # *
*#   #*
*******

In the above example the '*'s represent the outer box and the '#'s represent the diagonal cross.
Note that the above example uses two different characters so that it is easier to see what the output looks like, your program should use one character only.
Input
An integer of 1 or more, it is guaranteed to be odd.
Output
A square that is made up of a character of your choice with a cross through the middle.

The cross must be diagonal
The square may be output via the function or written to output
Trailing newlines are okay
Can output as a graphic, diagram or image if you wish too

Examples
Input: 1
Output:
*

Input: 3
Output:
***
***
***

Input: 5
Output:
*****
** **
* * *
** **
*****

Input: 7
Output:
*******
**   **
* * * *
*  *  *
* * * *
**   **
*******

Specs

Functions or full programs are allowed
You can get input by your preferred means
Standard loopholes are disallowed
Programs must work without any additional statements i.e. usings in C#, they must be included in the entry
You can output from a function or print the result

This is code golf so the shortest solution wins.

Could we also index these outputs with 0,1,2,3,...?

@flawr I'm not 100% sure what you mean

@TheLethalCoder He asks whether he can take input n and print a square of size 2n+1.

@MartinEnder Oh so in my examples input 1 gives * but for him it will be input 0?

@TheLethalCoder Yes, and input 1 would yield your example for 3.

@MartinEnder I don't really see why not

@Pakk One or more that's a typo, thanks for pointing it out

The Confederate Flag! How very Donald Trump....

MATL, 20 19 17 bytes
2-:XdtP!+~TTYa1YG

You can try it experimentally in MATL online. You may need to refresh the page if it doesn't work.
Sample run:

ASCII version: 19 bytes
2-:XdtP!+~TTYa~42*c

Try it online!

But at least make sure that the lines are parallel & rectangular. :D

@flawr Hm? What do you mean?

At least in the middle looks as if the sides of the squares are slanted, but it's just an illusions. Or is it? (Might also be a black hole behind my screen, warping space time.)

@flawr Or maybe go to the eye doctor :-P

Doesn't work over MATL online, version 19.0.0. Hmmm...

@EriktheOutgolfer Working again! The server needed some rebooting

VBA Excel, 168 bytes
Instruction:
I find Excel with the help of VBA is an effective and a sufficient tool for this challenge. Set the worksheet of Excel like following

Yes, we use the small, classic square-shaped pixels like the old times by using the cells in a worksheet as the pixels. Ha-ha...
Here I use cell A1 as the input and I change its font color to red. Why red? Because red is three-letter-color so it fits for golfing. Write and run the following code in the Immediate Window:
N=[A1]:Range("A1",Cells(N,N)).Interior.Color=vbRed:Range("B2",Cells(N-1,N-1)).Clear:For i=1To N:Cells(i,i).Interior.Color=vbRed:Cells(i,N+1-i).Interior.Color=vbRed:Next

Ungolfed the code:
Sub A()
    N = [A1]
    Range("A1", Cells(N, N)).Interior.Color = vbRed
    Range("B2", Cells(N - 1, N - 1)).Clear

    For i = 1 To N
        Cells(i, i).Interior.Color = vbRed
        Cells(i, N + 1 - i).Interior.Color = vbRed
    Next
End Sub

Step-by-step Explanation:
N = [A1]: Range("A1", Cells(N, N)).Interior.Color = vbRed

Range("B2", Cells(N - 1, N - 1)).Clear

Looping through the diagonal of range cells: Cells(i, i).Interior.Color = vbRed

Final step and output: Cells(i, N + 1 - i).Interior.Color = vbRed

Cells.RowHeight=48:set r=[A1]:r.Resize(r,r).Interior.Color=0:[B2].Resize(r-2,r-2).Clear:For i=1To[A1]:set r=Union(r,Cells(i,i),Cells(i,r-i+1)):Next:r.Interior.Color=0

JavaScript (ES6), 96 bytes

f=
n=>[...Array(n--)].map((_,i,a)=>a.map((_,j)=>i&&j&&n-i&&n-j&&i-j&&n-i-j?' ':'*').join``).join`
`
;
<input type=number min=1 step=2 oninput=  o.textContent=f(this.value)><pre id=o>

Python 2, 65 bytes
i=n=2**input()/2
while i:print bin((n>i>1or~-n)|n|i|n/i)[2:];i/=2

Uses Jonathan Allan's idea of outputting binary numbers like:
11111
11011
10101
11011
11111

The rows are created with bit arithmetic and displayed in binary. Each part it or'ed into the rest. The part are are produced by powers of 2 n (fixed) and i (falling) via

Left side 1
Right side n
Diagonals i and n/i
Top and bottom by n-1 when i==1 or i==n.

Actually, (1) and (4) are combined by producing 1 when 1<i<n and n-1 otherwise.

Java 7, 131 130 128 125 124 122 bytes
String c(int n){String r="";for(int i=n,j;n-->0;r+="\n")for(j=0;j<n;r+=i*j<1|n-i<2|n-j<2|i==j|i==n-++j?"*":" ");return r;}

3 bytes saved thanks to @LeakyNun;
1 byte saved thanks to @OliverGrégoire in my answer for the Draw a hollow square of # with given width challenge;
2 bytes saved thanks to @cliffroot.
Ungolfed & test code:
Try it here.
class M{
  static String c(int n){
    String r = "";
    for(int i = n, j; n-- > 0; r += "\n"){
      for(j = 0; j < n;
            r += i < 1      // Responsible for the first horizontal line
               | j < 1      // Responsible for the first vertical line
               | n-i < 2    // Responsible for the last horizontal line
               | n-j < 2    // Responsible for the last vertical line
               | i == j     // Responsible for the top-left to bottom-right diagonal line
               | i == n-++j // Responsible for the top-right to bottom-left diagonal line (and increasing j)
             ? "*"
             : " ");
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c(1));
    System.out.println(c(3));
    System.out.println(c(5));
    System.out.println(c(7));
  }
}

Output:
*

***
***
***

*****
** **
* * *
** **
*****

*******
**   **
* * * *
*  *  *
* * * *
**   **
*******

String c(int n){String r="";for(int i=-1,j;++i<n;r+="\n")for(j=0;j<n;r+=i<1|j<1|n-i<2|n-j<2|i==j|i==n-++j?"*":" ")return r;} 4 bytes saved

@LeakyNun 3 actually. You'd still need the ; behind the inner for-loop.

first, i believe it should be i-->0 rather than n-->0 and you can also use i*j<1 instead of i<1|j<1  for 2 bytes

@cliffroot Of course you had to find something. Hehe, jk, thanks! ;) I remember I've done something like that before in another answer, so pretty bad I forgot to do it here.. :S

Python, 114 110 96 90 bytes
Totally changed:
lambda n:[bin(sum(2**p for p in[range(n),{0,n-1,r,n-1-r}][0<r<n-1]))[2:]for r in range(n)]

Returns a list of strings, characters using 1 and 0.
-6 bytes thanks to TheBikingViking
Test it at ideone

Previous Python 2 @110
def f(n):g=range(n);n-=1;print'\n'.join(''.join((c in(r,n-r,0,n)or r in(0,n))and'#'or' 'for c in g)for r in g)

Test it on ideone

Save 6 bytes by converting to a lambda and restructuring the and-or expression: lambda n:[bin(sum(2**p for p in[range(n),{0,n-1,r,n-1-r}][0<r<n-1]))[2:]for r in range(n)].

@TheBikingViking Ah, you are right - I really should have golfed down to bit twiddling (my original intent) before putting the idea out there and sleeping :p.

C#, 112 101 bytes
Thanks to TheLethalCoder for reminding me that these anonymous lambda statement-nor-expression things are allowed in C#.
n=>{var r="";for(int y=n--,x;y-->0;r+="*\n")for(x=0;x<n;r+=y%n*x<1|y==x|y==n-x++?"*":" ");return r;};

Who said C# isn't a fun golfing language?

I know, right? 27591 bytes :p

Matlab, 68 66 64 58 bytes
Since graphical output is allowed too:
k=input('');[x,y]=ndgrid(abs(-k:k));spy(~(max(x,y)<k&x-y))

Which outputs e.g.

The ascii only versions would be:
This is using the indexing 0,1,2,3,...
k=input('');[x,y]=ndgrid(abs(-k:k));[(max(x,y)==k|~(x-y))*42,'']

Alternatively with the indexing 1,3,7,...:
n=input('');k=1:n;m=eye(n);m([k,end-k+1])=1;[(m|flip(m'))*42,'']

Nice, not only does the graphical output look better imo, it's cool that it's also shorter in terms of bytes. Usually making something more graphical instead of plain ASCII would only increase the byte-count (usually by a lot).

Logo, 155 bytes
Graphical solution, implemented as a function
I retooled my answer for Alphabet Triangle and changed the angles around a bit.  As before, r draws a line of characters.  This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times.  This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately.  This answer also properly handles even numbers.  I had to add special handling for an input of 1 to prevent it from going forward.
I implemented it as a function, b which takes the size as an argument:
pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter.
To call it, append a line and call b in the following format:
b 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:
repeat 4[
  b repcount*2+3
  rt 90
]

Haskell, 102 100 96 91 87 bytes
c s=unlines.f$f.(#)where f=(<$>[1..s]);x#y|elem y[1,s,x]||elem x[1,s,s-y+1]='*'|1>0=' '

Saved 2 bytes, thanks to flawr.
Saved 4 more bytes by using list comprehensions.
5 bytes saved combining flawr's improvement with any
4 bytes saved by replacing any with elem

Ungolfed version:
cross :: Int -> String
cross s = unlines $ map line [1..s]
    where line y = map (pos y) [1..s]
          pos y x | x == y = '*'
                  | x == s - y + 1 = '*'
                  | y `elem` [1, s] = '*'
                  | x `elem` [1, s] = '*'
                  | otherwise = ' '

I'm sure this can still be improved, but this is what I've come up with for now.
Old version:
c s=unlines.f$f.(#)where f=(<$>[1..s]);x#y|any(==y)[1,s,x]||any(==x)[1,s,s-y+1]='*'|1>0=' '

You're using [1..s] twice, I think you could define that in where.

It would result in 102 bytes too, since we'd have to add an extra space before the where keyword.
c s=unlines$(\m->(m#)<$>z)<$>z where z=[1..s];m#n|or((==)<$>[n,m]<*>[1,s])||n==m||n==s-m+1='*'|1>0=' '

Ah right, but you can pack <$>[1..s] into a function, right? Like c s=unlines$f(\m->f(m#))where m#n|or((==)<$>[n,m]<*>[1,s])||n==m||n==s-m+1='*'|1>0=' ';f=(<$>[1..s])

Good point, that does work indeed. :)

I didn't even know you could use let to define functions with guards within a list comprehension! Great job! (It seems this isn't already present here yet, it might be worth adding!)

PS: c s=unlines$f$f.(#)where f=(<$>[1..s]);m#n|or((==)<$>[n,m]<*>[1,s])||n==m||n==s-m+1='*'|1>0=' '

I was about to post a 92 byte solution with list comprehensions but combining it with yours gets down to 91.

R, 102 bytes
    n=scan();for(i in 1:n){for(j in 1:n){z=" ";if(i%in%c(1,n,n-j+1)|j%in%c(1,i,n))z="*";cat(z)};cat("\n")}

Note that it is more efficient to express the condition using %in% than i==1|j==1|...

It is possible to golf away one character if the input is guaranteed to be more than one:  n=scan();for(i in n:1){for(j in n:2){z=" ";if(i%in%c(1,n,n-j+1)|j%in%c(i,n))z="*";cat(z)};cat("*\n")}

94 bytes

PowerShell (133)
filter s($x){1..$x|%{$o="";$r=$_;1..$x|%{if($_-eq1-or$r-eq1-or$_-eq$x-or$r-eq$x-or$r-eq$_-or$r-1-eq$x-$_){$o+="*"}else{$o+="_"}};$o}}

Clunky, but it works well enough.
s(11)
***********
**_______**
*_*_____*_*
*__*___*__*
*___*_*___*
*____*____*
*___*_*___*
*__*___*__*
*_*_____*_*
**_______**
***********

Golfing suggestions definitely welcome, it's been too long since I've PowerShell'd.

C, 140 121 114 bytes
19 bytes thanks to Quentin.
7 bytes saved by switching from a double-nested loop to one loop.
main(a){scanf("%d",&a);for(int i=0;i<a*a;i++,i%a||puts(""))putchar(i/a&&i/a^a-1&&i%a&&-~i%a&&i%-~a&&i%~-a?32:42);}

Golfing suggestions welcome.

I never program in C, but isn't it possible to place the int in the first for-loop like in Java? I.e. int i,j;for(i=0; to for(int i=0,j;

The last time I used C you couldn't even put the int i,j; after the scanf!

Try n+~i-j etc.

GCC is fine with removing the #include completely.

@Neil What do you mean by you couldn't put that after that?

Back in my day you had to put all of your declarations at the start of your block before any statements.

Does it work? http://coliru.stacked-crooked.com/a/a8cf5f07d1c583ad

@YSC The input is supposed to be odd.

Java, 130 bytes
s->{for(int i=0;i<s;i++)for(int j=0;j<s;j++)System.out.print((s-1-i==j||i==j||i==0||j==0||i==s-1||j==s-1)?j==s-1?"*\n":"*":" ");};

Test Program
Consumer<Integer> consumer = s -> {
        for (int i = 0; i < s; i++) {
            for (int j = 0; j < s; j++) {
                System.out.print((s - 1 - i == j || i == j || i == 0 || j == 0 || i == s - 1 || j == s - 1) ? j == s - 1 ? "*\n" : "*" : " ");
            }
        }
    };

    consumer.accept(20);

+1! I would specify that it's Java 8, btw. Also, you can golf it a bit by removing the int  before j and use int i=0,j; instead. You can also replace all || with | and remove the parenthesis in the ternary-check. Also, you use s-1 four times, so I would put this in a variable. Also, you can change the ==0 to <1. So in total it becomes s->{for(int i=0,j,x=s-1;i<s;i++)for(j=0;j<s;j++)System.out.print(x-i==j|i==j|i<1|j<1|i==x|j==x?j==x?"*\n":"*":" ");} (116 bytes) Quite a bit shorter than my Java 7 answer, so nice approach!

@KevinCruijssen I always end up with a shorter answer, but with more room for improvement than you LMAO. Well golfed my friend.

Hehe. xD Feel free to use the 116 byte version btw. It's your code, just golfed down some more. ;) My Java 7 answer (which is unfortunately longer) uses a slightly different approach. If I would edit it into the 116 byte version I would basically steal your answer, which I don't want to.

No point just copying and pasting your golfs, I normally post a quick mock up and then come back to it later on to see if I missed anything that could be golfed. But you RUINED IT FOR MEE :( haha jk

Ah sorry. Most of the tips I gave are actually present in the Tips for golfing in Java. I guess I'm just 2quick4u. ;)

@KevinCruijssen Hahaha I guess so >:(

S.I.L.O.S, 212 bytes
readIO
a = i
lbla
a - 1
t = a
t + 1
t % i
t * a
b = i
lblb
b - 1
u = b
u + 1
u % i
u * b
u * t
v = a
v - b
u * v
v = a
v + b
v + 1
v % i
u * v
u |
if u c
print #
GOTO d
lblc
print .
lbld
if b b
printLine
if a a

Try it online!

:) thanks for bringing more attention to this language

@RohanJhunjhunwala I enjoyed programming in it, thank you for creating such a brilliant language.

GNU sed, 117 114 + 1(r flag) = 115 bytes
p;/^0$/Q;/^000$/{p;q}
h;s/./ /3g;s/  $/00/
:f;/ 00 /!{G;h;s/\n.*//p;t;:}
s/^(0 *)0  ?( *)0/\1 0\20 /
tf;s/00/0/p;g

Since sed has no native support for numbers, the input is given in unary based on this consensus. The second half of the square is the first half that was stored in reverse order in hold space.
Run:
sed -rf crossed_square.sed <<< "00000"

Output:
00000
00 00
0 0 0
00 00
00000

Python, 89 bytes
This was a throwback! I used python's turtle module.
from turtle import*
n=input()
for i in[(n,n),(n,0),(0,n),(0,0),(n,0),(0,n),(n,n)]:goto(i)

Here's the result when n=200:

Pyke, 28 24 23 bytes
]Ua]jshqjXq|0[j{|)Qt[)P

Try it here!

Scala, 141 137 bytes
val s=args(0).toInt-1;val t=0 to s;print(t.map{x=>t.map{y=>if(x==0||x==s||y==0||y==s||x==y||x==s-y)"*" else " "}.mkString+"\n"}.mkString)

Run:
$ scala cross.scala 10
Technically I could remove the print stuff and go to something like
def c(n:Int)={val (s,t)=(n-1,0 to n-1);t.map{x=>t.map{y=>if(x==0||x==s||y==0||y==s||x==y||x==s-y)"*" else " "}.mkString+"\n"}.mkString}

This would make it 135 or 121 bytes depending on whether you count the function syntax stuff.
Readable version:
def cross(n: Int) = {
   // Declares both s and t as variables with tuple expansion
   // s is the zero-based size and t is a range from 0 to s
   val (s,t) = (n-1, 0 to n-1)

   // Maps all rows by mapping the columns to a star or a space
   t.map { x =>
      t.map { y =>
        if (x == 0 || x == s || y == 0 || y == s || x == y || x == s-y) "*"
        else " "
      }.mkString+"\n" // Concatenate the stars and spaces and add a newline
   }.mkString         // Concatenate the created strings
 }

Pyth, 27 25 bytes
jmsm?|qFKaLJ/Q2,dk}JKN\ Q

Try it online!
Probably golfable.

Python 2, 83 bytes
i=n=input()
while i:l=['* '[1<i<n]]*n;i-=1;l[0]=l[~0]=l[i]=l[~i]='*';print`l`[2::5]

Modifies a list of the row's characters to put a * into the first, last, i'th, and i'th-to-last place. The first and last row start as all *, and the rest as all spaces. Works for evens too. A lambda expression is probably shorter than modification, but I like this method.

Mathematica, 81 bytes
""<>#&/@Table[If[i^2==j^2||i^2==#^2||j^2==#^2,"*"," "],{i,-#,#},{j,-#,#}]&[(#-1)/2]&

Creates a coordinate system with the origin in the center, and computes where the *s should go. Outputs an array of strings, one per row.

Javascript (289 270 bytes)
function s(a){b=[];for(i=0;i<a;i++)if(b.push([]),0==i||i==a-1)for(j=0;j<a;j++)b[i].push("*");else for(j=0;j<a;j++)0==j||j==a-1?b[i].push("*"):j==i||a-1-j==i?b[i].push("*"):b[i].push(" ");c="";for(i=0;i<b.length;i++){for(j=0;j<b[i].length;j++)c+=b[i][j];c+="\n"}return c}

Ungolfed:
function square(size){
str=[];

for(i=0;i<size;i++){
    str.push([]);
    if(i==0||i==size-1){
        for(j=0;j<size;j++){
            str[i].push("*");
        }
    }else{
        for(j=0;j<size;j++){
            if(j==0||j==size-1){
                str[i].push("*");
            }else if(j==i||size-1-j==i){
                str[i].push("*");
            }else{
                str[i].push(" ");
            }
        }
    }
}

out="";
for(i=0;i<str.length;i++){
    for(j=0;j<str[i].length;j++){
        out+=str[i][j];
    }
    out+="\n";
}
return out;
}

EDIT:
Saved 19 bytes thanks to Philipp Flenker.

Since trailing newlines are okay, I think you don't need the check for size==1

@PhilippFlenker Correct.

Charcoal, 8 bytes (noncompeting; language postdates challenge)
ＧＨ+↘↑↙Ｎ*

Try it online! Link is to verbose version of code. Explanation: When used as a parameter to the PolygonHollow command, + draws a box, and the arrows then create the diagonals. There are some other shortcut characters but they would need to be redefined to be useful e.g. Y is equivalent to ↖↗↓ but if it was eqivalent to ↗↓↖ then Y+ would suffice.

05AB1E, 7 bytes
0•V¾²•Λ

Try it online or verify all test cases.
Explanation:
0        # Push 0
 •V¾²•   # Push compressed integer 2064147
      Λ  # Use the Canvas builtin with the given three options:
         #  Length of the lines: the (implicit) input-integer
         #  Character/string to display: the "0"
         #  Directions: [2,0,6,4,1,4,7]
         # (after which the result is output implicitly immediately)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •V¾²• is 2064147.
The Canvas Builtin uses three arguments to draw a shape:

Length of the lines we want to draw: which is the input in this case
Character/string to draw: the 0 (could be any other digit as well)
The direction to draw in: the [2,0,6,4,1,4,7], where each digit represents a certain direction:

7   0   1
  ↖ ↑ ↗
6 ← X → 2
  ↙ ↓ ↘
5   4   3

So the [2,0,6,4,1,4,7] in this case translates to the directions \$[→,↑,←,↓,↗,↓,↖]\$.
Here a step-by-step explanation of how it draws for example input 7 with these steps:
Step 1: Draw 7 characters ("0000000") in direction 2→:
0000000

Step 2: Draw 7-1 characters ("000000") in direction 0↑:
      0
      0
      0
      0
      0
      0
0000000

Step 3: Draw 7-1 characters ("000000") in direction 6←:
0000000
      0
      0
      0
      0
      0
0000000

Step 4: Draw 7-1 characters ("000000") in direction 4↓:
0000000
0     0
0     0
0     0
0     0
0     0
0000000

Step 5: Draw 7-1 characters ("000000") in direction 1↗:
0000000
0    00
0   0 0
0  0  0
0 0   0
00    0
0000000

Step 6: Draw 7-1 characters ("000000") in direction 4↓:
0000000
0    00
0   0 0
0  0  0
0 0   0
00    0
0000000

Step 7: Draw 7-1 characters ("000000") in direction 7↖:
0000000
00   00
0 0 0 0
0  0  0
0 0 0 0
00   00
0000000

After which the result is output implicitly immediately afterwards.
See this 05AB1E tip of mine for an in-depth explanation of the Canvas builtin.

Perl, 83 +1 = 84 bytes
Run with the -n flag.
$\="*
*";print$c="*"x($_+1);for$b(1..$_){@a=($")x$_;@a[$b-1,-$b]=(a,a);print@a}say$c

The literal newline saves 1 byte over \n or $/.
Readable:
$\="*\n*";
print$c="*"x($_+1);
for$b(1..$_){
    @a=($")x$_;
    @a[$b-1,-$b]=(a,a);
    print@a
}
say$c

The code prints the top line and saves it in $c, then prints a bunch of spaces with the appropriate slots replaced with as, then prints the top line again.
The assignment to the $\ variable tells the interpreter to print the contents (an asterisk, a newline, and another asterisk) after every print, but this does NOT occur after a say.

SmileBASIC, 46 bytes
INPUT I
GBOX I,I,1,1GLINE 1,I,I,1GLINE 1,1,I,I

(No, SB does NOT use 1-indexed graphics...)

SHELL  ( 135 Bytes):
 C(){ j=$(($1-1));for i in $(seq 0 $j);do dc<<<2o10i`echo $((1|2**$i|2**($j-$i)|2**$j|(($i==0||$i==$j))*(2**$j-1)))`p;done|tr 01 ' X';}

tests:
 C 1
 X

 C 3
 XXX
 XXX
 XXX

 C 5
 XXXXX
 XX XX
 X X X
 XX XX
 XXXXX

 C 7
 XXXXXXX
 XX   XX
 X X X X
 X  X  X
 X X X X
 XX   XX
 XXXXXXX

 C 9
 XXXXXXXXX
 XX     XX
 X X   X X
 X  X X  X
 X   X   X
 X  X X  X
 X X   X X
 XX     XX
 XXXXXXXXX

Kotlin, 123 116 bytes
change if with \n to println
{s:Int->val n=s-1
for(r in 0..n){for(c in 0..n)print(if(n-r==c||r==c||r<1||c<1||r==n||c==n)"#"
else " ")
println()}}

Try it online!

Vyxal, 8 bytes
×» Ḣ¡»ø∧

Try it Online!
Port of 05AB1E. Uses canvas builtin.
How?
×» Ḣ¡»ø∧
×        # Push asterisk
 » Ḣ¡»   # Push compressed integer 2064147 (translates to directions [→,↑,←,↓,↗,↓,↖])
      ø∧ # Canvas builtin with implicit input as the length, 2064147 as the directions, and asterisk as the character