Nested function in C

What is nested function?
If a function is defined inside another function, then it is called as nested function. 

Nested function example in C:
Consider the following example,
int add(int a, int b) {
       void print(int res) {
         printf("Result is %d, res);
      }
      print(a+b);
      return 0;
}

Here, print() is a nested function.  Because, it is defined inside another function named add().

Example C program using nested functions:
 
#include <stdio.h>
void add(int a, int b) {
void print(int res) { // nested function
printf("Result is %d\n", res);
return;
}
print(a + b); // passing sum of a and b as parameter
return;
}

int main() {
add(10, 20);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Result is 30



Static function in c

What is static function in C?
Static function is nothing but a function that is callable only by other functions in the same file where the static function is defined.

Static function example:
Consider the following example,
 
// static.c is the file name
static int add(int a, int b) {
return (a + b);
}

Here, we have defined a static function named add() in static.c.  Below is main.c file which has main function calling another function named add().

 
// main.c
#include <stdio.h>
int main() {
int res;
res = add(10, 20); // main function makes call to static function
printf("Result: %d\n", res);
return 0;
}


Let us try to compile both together to get a single executable.
  Output:
  jp@jp-VirtualBox:~/$ gcc static.c main.c 
  /tmp/ccSWRV5a.o: In function `main':
  ex45.c:(.text+0x19): undefined reference to `add'
  collect2: ld returned 1 exit status


From main function, we are calling a static function named add() in another another file. This results to the above error. Basically, static functions are not allowed to be called from other files. 

Let us see what happens if we make static function as non-static.
 
// static.c is the file name
int add(int a, int b) {
return (a + b);
}

 
// main.c
#include <stdio.h>
int main() {
int res;
res = add(10, 20); // main function makes call to static function
printf("Result: %d\n", res);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ gcc static.c main.c 
  jp@jp-VirtualBox:~/$ ./a.out
  Result: 30



main function in C

main() function is mandatory for any C program.  Because, the program execution starts from main().  Default return type for main function is an integer.  Return value from main function could help us to find the exit status of a C program.

Consider the following example,
 
#include <stdio.h>
int main() {
int val;
printf("Enter an integer: ");
scanf("%d", &val);

if (val < 0) {
printf("%d is negative\n", val);
return (-1);
} else {
printf("%d is positive\n", val);
return (val);
}
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter an integer: -1
  -1 is negative
  jp@jp-VirtualBox:~/$ echo $?
  255  // exit status of the program
  jp@jp-VirtualBox:~/$ ./a.out
  Enter an integer: 50
  50 is positive
  jp@jp-VirtualBox:~/$ echo $?
  50  // exit status of the program


How to get exit status of a command?
"echo $?" provides exit status of any program.  Here, the exit codes of our program are the return values from main function.  Exit codes are from 0 to 255(unsigned char).  So, shell would return 255 for the exit code -1(wraparound occurs).

What is command line argument?
Basically, command is an executable used to perform a specific task(eg. ls command). Any arguments supplied to an executable(command) are called command line arguments.

Example:
ls -a  => lists all files in a directory(including hidden files)

Here,
ls  - command
-a - command line argument

main function with command line arguments:
main function can be written with no arguments or with command line arguments.

Consider the following example,
int main(int argc, char *argv[]) {
         : 
       return 0;
}

Here, we have written main function with command line arguments.
argc and argv are command line arguments.
argc    - number of command line arguments
*argv[] - array of character pointers

How to pass command line arguments in C?
While executing program in the shell, we can supply arguments along with executable name.

Example: ./a.out   arg1  arg2  arg3
./a.out  - Executable
arg1, arg2, arg3 - command line arguments

Example C program to illustrate command line arguments:
 
#include <stdio.h>
int main(int argc, char *argv[]) {
int i;
for (i = 0; i < argc; i++) {
printf("argv[%d]: %s\n", i, argv[i]); // prints command line arguments
}
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out india is my country
  argv[0]: ./a.out
  argv[1]: india
  argv[2]: is
  argv[3]: my
  argv[4]: country



How to call functions using function pointers?

What is function pointer?
Every function has an address.  We can assign the address of functions to pointers.  Then those pointers are called pointers to functions.  Pointers to function is also called as function pointers

Let us see how to call functions using function pointer.  Below is an example function pointer

int (*func)(int, int);
Here, func is a pointer to a function that takes two integer arguments and returns an integer

Consider the following example,
int add(int a, int b) {
         return (a + b);
}

int main() {
          int (*func) (int, int);
          func = add;  //assigning address of function add()
          (*func)(10, 20);  // calls the add function
          return 0;
}

Here,
"func = add" is equivalent to "func = &add"(& is optional)
"(*func)(10, 20)" is equivalent to "func(10, 20)" (* is optional)

Let us write an example C program that calls a function using function pointer.

 
#include <stdio.h>
int add(int a, int b) {
return (a + b);
}

int main() {
int res;
int (*func)(int, int);
func = &add; // assign address of the function add()
res = func(10, 20); // calling add()
printf("Sum of 10 and 20 is %d\n", res);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Sum of 10 and 20 is 30



Variable arguments in C

In C language, its possible to write functions with variable arguments.  A function that takes variable number of arguments is also called as variadic function.  Below is an example prototype for a variadic function.

int func_name(int num, ...);
func_name     - name of the function
num               - number of arguments in argument list
...(ellipsis)     - used to denote variable arguments

Below are the list of macros availabe in 'stdarg.h' used to retrieve variable arguments.

void va_start (va_list arg, last_arg)
It initializes argument pointer arg to point to first optional argument and last_arg is the last named argument to a function.

type va_arg (va list arg, type) 
Returns subsequent optional argument and type is data type of the actual argument

void va_end (va list arg)
Ends the use of variable arguments.

Example C program on variable length argument list
 
#include <stdio.h>
#include <stdarg.h>
int sum(int, ...); // function prototype

int sum(int num, ...) {
int i, val, total = 0;
va_list arg;
/* initializes arg pointer to point to 1st optional arg */
va_start(arg, num); // num - no of arguments in parameter list
for (i = 0; i < 5; i++) {
val = va_arg(arg, int); // get subsequent argument
printf("Argument %d: %d\n", i + 1, val);
total = total + val;
}
va_end(arg); // end the use of variable argument
return (total);
}

int main() {
int res;
/* first argument to sum denotes the no of arguments in parameter list */
res = sum(5, 10, 20, 30, 40, 50);
printf("Resultant sum value is %d\n", res);
return 0;
}


  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Argument 1: 10
  Argument 2: 20
  Argument 3: 30
  Argument 4: 40
  Argument 5: 50
  Resultant sum value is 150



Call by value vs call by reference

Difference between call by value and call by reference
There are two types of parameter passing schemes.
     1. Call by value
     2. Call by reference

Call by Value:
     A copy of actual arguments are passed to the formal arguments.  So, any modification to formal arguments won't affect the original value of actual arguments.

Example C program to illustrate call by value:
 
#include <stdio.h>
/* swaps given two number */
void swap(int a, int b) {
int tmp;
tmp = a;
a = b;
b = tmp;
printf("Inside swap() -> a = %d\tb = %d\n", a, b);
return;
}

int main() {
int a, b;
printf("Enter two integers: ");
scanf("%d%d", &a, &b);
swap(a, b); // pass by value
printf("Inside main() -> a = %d\tb = %d\n", a, b);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter two integers: 10 20
  Inside swap() -> a = 20 b = 10
  Inside main() -> a = 10 b = 20



Call by Reference:
Here, the address of variables are passed from the actual argument to the formal argument.  So, the called function acts on addresses rather than values.  Here, the formal arguments have the pointer to the actual arguments. So, any change made to formal arguments reflect on actual arguments.

Example C program to illustrate call by reference
 
#include <stdio.h>
/* swaps given two number */
void swap(int *a, int *b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
printf("Inside swap() -> *a = %d\t*b = %d\n", *a, *b);
return;
}

int main() {
int a, b;
printf("Enter two integers: ");
scanf("%d%d", &a, &b);
/* address of variable is passed to swap() */
swap(&a, &b); // pass by reference
printf("Inside main() -> a = %d\t b = %d\n", a, b);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter two integers: 10 20
  Inside swap() -> *a = 20 *b = 10
  Inside main() ->  a = 20 b = 10



Comma operator in C

Basically, comma operator is used to separate expressions.  Consider the following,

i++, j++, k++, val = val + 10;

Here, there are four expression and they are separated by comma operator.  The above statement is equivalent to the following.

i++;
j++;
k++;
val = val + 10;

Comma operator is most often used in for statement and function arguments.  Below are few examples on comma operator usage.

Example 1: (comma operator in for loop)
for (i = 0, j = 0, k = 0; i < 10; i++, j++, k++) {
      : :
}

Example 2: (comma operator in function argument)
int add(int a, int b) {  // comma operator
      return (a + b);
}

main() {
       add(10, 20);  // comma operator in function argument
}


Example C program using comma operator

  #include <stdio.h>
void add(int a, int b) {
printf("Sum of %d and %d is %d\n", a, b, a + b);
}

int main() {
int i, j, k, val = 0; // variable declaration

/* comma operator in for loop */
for (i =0, j = 0, k = 0; i < 5; i++, j++, k++) {
printf("Hello world\n");
}

/* comma operator in function argument */
printf("\ni = %d, j = %d, k = %d\n", i, j, k);
i++, j++, k++, val = val + 10; // comma operator in statement
printf("i = %d, j = %d, k = %d, val = %d\n", i, j, k, val);
add(10, 20); // comma operator in function argument
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Hello world
  Hello world
  Hello world
  Hello world
  Hello world

  i = 5, j = 5, k = 5
  i = 6, j = 6, k = 6, val = 10
  Sum of 10 and 20 is 30



sizeof operator in C

It is used to find the size(in bytes) of data type or variable.  Consider the following examples,

Example 1:
int arr[100];
sizeof(int)            - 4 bytes  // size of an integer
sizeof(arr)            - 400 bytes // size of 100 elements in an integer array

Example 2:
Structure is a user defined compound data type which can have elements of different data types grouped under a common name.  We will see more about structures in forth coming tutorials.

struct student {
     char name[100];
     int age, rollno;
};
struct student obj, *ptr

sizeof(struct student) - 108 bytes   // size of structure student
sizeof(obj)                - 108 bytes  // size of structure variable of type student
sizeof(ptr)                 - 4 bytes    // size of pointer to structure of type student

The total size of the structure student is 108 bytes(name - 100 bytes, age - 4 bytes, rollno - 4 bytes).  Here, obj is a structure variable of type student and ptr is a pointer to structure of type student.

The return type of sizeof() operator is unsigned integer.  And this operator is defined in <stddef.h>

Example C program on sizeof() operator
 
#include <stdio.h>
struct student {
char name[100];
int age, rollno;
};

int main() {
int arr[100];
struct student obj, *ptr;
printf("sizeof(int): %d\n", sizeof(int)); // size of integer
printf("sizeof(arr): %d\n", sizeof(arr)); // sizeof array
printf("sizeof(struct student): %d\n",
sizeof(struct student)); // size of structure
printf("sizeof(obj): %d\n", sizeof(obj)); // obj is of type struct student
printf("sizeof(ptr): %d\n", sizeof(ptr)); // ptr is pointer to struct student
return 0;
}


  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  sizeof(int): 4
  sizeof(arr): 400
  sizeof(struct student): 108
  sizeof(obj): 108
  sizeof(ptr): 4




Pointer operators in C

There are two types of pointer operators.  They are
1. Address operator(&)
2. Indirection operator(*)

Address Operator:
It is used to get the address of the given  variable.  Consider the following,
Example:
int a = 10, *ptr;
ptr = &a;
Here, &a gives us the address of the variable and the same is address to pointer variable ptr.  Address operator is also known as reference operator.

Indirection operator:
It is used to get the value stored in an address.  Consider the following,
Example:
int a = 10, b, *ptr;
ptr = &a;  // referencing(&a)
b = *ptr;  // dereferencing(*ptr)
Here, ptr has the address of the variable a.  On dereferencing the pointer ptr, we will get the value stored at the address of a.

Example C program on pointer operators

  #include <stdio.h>
int main() {
int a = 10, b, *ptr;
ptr = &a; // referencing (&a)
b = *ptr; // dereferencing (*ptr)
printf("Value of &a is 0x%x\n", &a);
printf("Value of ptr is 0x%x\n", ptr);
printf("Value of a is %d\n", a);
printf("Value of b is %d\n", b);
printf("Value of *ptr is %d\n", *ptr);
return 0;
}


  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Value of &a  is 0xbfb1715c
  Value of ptr  is 0xbfb1715c
  Value of a is 10
  Value of b is 10
  Value of *ptr is 10



Bitwise shift operators with example

There are two types of shift operators.  They are
1. Left shift operator (<<)
2. Right shift operator(>>)

Left shift operator:
It is used to shift the bits of the first operand to left by the number of bit places the second operand specifies.

Example: 2 << 4
Binary value of 2 is 00000010
00000010 << 4 is 00100000
Decimal value of 00100000 is 32

Right shift operator:
It is used to shift the bits of the first operand to right by the number of bit places the second operand specifies.

Example: 32 >> 4
Binary value of 32 is 00100000
00100000 >> 4 is 00000010
Decimal value of 00000010 is 2

Example C program on bitwise shift operators
 
#include <stdio.h>
int main() {
int x = 2, y = 4, res;
res = x << y; // left shift x by y
printf("%d << %d is %d\n", x, y, res);
x = res;
res = x >> y; // right shift x by y
printf("%d >> %d is %d\n", x, y, res);
return 0;
}


  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  02 << 4 is 32
  32 >> 4 is 2



Null statement

If a statement has only semicolon, then it is called as null statement.

Syntax:
 ;

What is the purpose of null statement?
do nothing

Example 1:
for (i = 0; i < 5; i++)
;   // null statement
Here, the body of the for loop is null statement.

Example 2:
goto label;
........
label:
;
Program needs at least one statement below label.  If we have no valid statement to place below label, then we can put null statement below label as shown above.

Example c program using null statement
 
#include <stdio.h>
main() {
int i;
for (i = 0; i < 5; printf("Hello world\n"), i++)
; // null statement
if (i == 5)
goto err;
printf("You can't execute me!!");
printf(" Yahoooooooooo!!!\n");
err:
; // null statement behind label
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Hello world
  Hello world
  Hello world
  Hello world
  Hello world



Compound statement

Compound statement is a set of statements or no statements enclosed within set braces. It is also called as blocks.  Compounds statements are usually used in control flow statements(if, if-else, nested if, for, while, do-while etc).

Example 1: 
if (a < b) {
printf("a is less than b");
printf("I am inside compound statement\n");
}
There are two statements inside the if block which are compound statements.

Example 2: 
for (i = 0; i < 5; i++) {

}

There is no statement present inside the for loop.  It is also called as compound statement.

Example 3: 
for (i = 0; i < 5; i++) {
      int j = 10;  // variable declaration
}
Variable declaration is allowed inside blocks.  But, the scope(lifetime) of the variable is only inside the block where it is declared.

Example c program using compound statements
 
#include <stdio.h>
int main() {
int i = 20;

/* two statements inside if block */
if (i > 10) {
printf("Value of i is greater than 20\n");
printf("Compound statement\n");
}

printf("\nBlock with empty statement!! - start\n");
/* zero statements inside for loop */
for (i = 0; i < 5; i++) {

}
printf("Block with empty statement!! - End\n\n");

/* variable declaration inside for loop */
for (i = 0; i < 5; i++) {
int j = i;
printf("Value of j is %d\n", j);
}
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out 
  Value of i is greater than 20
  Compound statement

  Block with empty statement!! - start
  Block with empty statement!! - End

  Value of j is 0
  Value of j is 1
  Value of j is 2
  Value of j is 3
  Value of j is 4



Expression statement

It is possible to convert expressions into statements.  All we need to do is add a semicolon at the end of expressions.  Consider the following,

1 + 1;
2 * 2;
3 / 3;
10 <= 9;

All of the above are valid expression statements.  But, they are useless since we are not storing the result of the expression in any variable.  We won't get any compilation error when we include the above statements in our code.  Expression statements are useful when we store the result of the expression in some variable as shown below.

x = 1 + 1;
y = 2 * 2;
res = (10 <= 9);

 
#include <stdio.h>
int main() {
int x, y, res;
2 + 3;
4 * 9;
10 < 2;
x = 2 + 3;
y = 4 * 9;
res = (10 < 2);
printf("Value of x is %d\n", x);
printf("Value of y is %d\n", y);
printf("Value of res is %d\n", res);
return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Value of x is 5
  Value of y is 36
  Value of res is 0




for, while, do-while difference

Now, we are going to see the following in detail.
  1. difference between while and do while
  2. difference between for and do while
  3. difference between for and while

Difference between while and do-while loop
while loop do-while loop
Expression is evaluated at the beginning in while loop.

Example:
     while (expression) {
            statement;
     }
Expression is evaluated at the end in do-while loop

Example:
     do {
            statement;
      } while (expression);
while loop executes the statement inside the loop only if the truth value of the expression is not 0.
do-while loop executes the statement inside the loop at least once, regardless of whether the expression is true or not.
Variable used in expression needs to be initialized at the beginning of the loop or before the loop


Example 1:
     // initialization - outside loop
     int i = 0; 
     while (i < 5) {
          printf("Hello world\n");
          i = i + 1;
     }

Example 2:
  // initialization at the start of loop
     while ((ch = getchar()) != '\n') {
          printf("Hello world\n");
     }


Variable used in expression can be initialized inside loop or before the loop or at the end of the loop.


Example:
     int i, j = 0;
     do {
            printf("Hello World\n");
            if (j == 0) {
                 // initialization - inside loop
                 i = 0;
                 j = j + 1;
            } else {
                 i++;
            }
     } while (i < 5);






Difference between for and do-while loop

for loop do-while loop
Expression is evaluated at the beginning in for loop.
Expression is evaluated at the end in do-while loop
for loop executes the statement inside the loop only if the truth value of the expression is not 0
do-while loop executes the statement inside the loop at least once, regardless of whether the expression is true or not.
Variable used in expression can be initialized at the beginning of the loop or before the loop

Example 1:
(initialization at the start of loop)
     for (i = 0; i < 5; i++) {
          printf("Hello wold");
     }

Example 2: 
(initialization - before loop)
    int i = 0;
    for ( ; i < 5; i++) {
         printf("Hello world");
    }









Variable used in expression can be initialized inside inside the loop or before the loop or at the end of the loop.

Example 1:
(initialization inside loop)
    do {
          ch = getchar();
     } while (ch != '\n');

Example 2:
(initialization before the loop)
     int i = 0;
     do {
          printf("Hello world\n");
          i = i + 1;
      } while (i < 5);

Example 3:
(initialization at the end of the loop)
     do {
          printf("Hello world\n");
     } while ((ch = getchar()) != '\n');




Difference between for and while loop
for loop
while loop
Initialization, expression evaluation and iteration can be performed in single line

Initialization, expression evaluation and iteration cannot be performed in single line.

Mostly, for loop is preferred for known iterations

While loop is preferred for unknown iterations.

Below is the syntax for for loop:
     for (initialization;
              expression; iteration) {
                      statement;
     }

Below is the syntax for while loop.
     while (expression) {
          statement;
     }




Let us write a simple C program that illustrates while and do-while loop construct difference.
 
#include <stdio.h>
int main() {
int i, j, k;
j = k = 0;
// variable(j) in expression is initialized outside the loop
while (j < 5) {
printf("While loop\n");
j = j + 1;
}

printf("\n");
do {
printf("Do-While loop\n");
if (k == 0) {
i = 0;
k = k + 1;
} else {
//variable in expression is initialized inside loop
i = i + 1;
}
} while (i < 5);

printf("\nValue of i is %d\n", i);


/*
* value of i is 5 by this time. So, the truth value
* of expression in both while and do-while will be 0.
* Statement inside while loop won't be executed. Whereas,
* statement inside do-while will be executed once
* irrespective of truth value of the expression
*/
while (i < 0) {
printf("Truth value of my expression is 0 - while loop\n");
}

do {
printf("Truth value of my expression is 0 - do-while loop\n");
} while (i < 0);

return 0;
}

  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  While loop
  While loop
  While loop
  While loop
  While loop

  Do-While loop
  Do-While loop
  Do-While loop
  Do-While loop
  Do-While loop
  Do-While loop

  Value of i is 5
  Truth value of my expression is 0 - do-while loop



Control flow overview

Control flow tell us the order in which instructions need to be executed.  Basically, control statements are of three types.
1. Conditional control statements
2. Loop control structure
3. Direct control flow.

Conditional control statements:
Below are various conditional control statments availabe in c language.
1. if statement
2. if-else statment
3. else-if statement
4. nested if statments
5. switch statment

Loop control structure:
Below are various loop control structures available in c language.
1. for
2. while
3. do-while

Direct control flow:
Below are various direct control flow statements available in c language
1. break
2. continue
3. goto
4. return
5. null statement

We will see more about the above topics in detail in the forthcoming tutorials.

scanf() and printf() functions

Scanf() function:
It is used to read input from the keyboard.

int scanf(const char *format, ...);

For better understanding, lets rewrite the above as follows.
scanf("format specifiers", &v1, &v2, &v3);

v1, v2 and v3 are the input variables whose value needs to read from the keyboard.  We need to pass address of the variable as argument to store the input values from keyboard. Here, ampersand(&) represents address.

&v1 - address of variable v1
Input value for v1 will be stored at address of variable v1

Format specifier can be any of the following
%u  - unsigned int
%d  - int
%x  - hexadecimal
%o  - octal
%f  - float
%lf - double
%c  - char
%s  - string

scanf("%d", &v1); - inputs integer value
scanf("%x", &v2); - inputs hexadecimal value
scanf("%f", &v3); - inputs float value


printf() function:
It prints the given data on the output screen.

printf("format specifiers", v1, v2,..vn);
Here, format specifier can be any of the above mentioned.  Whereas, v1, v2..vn are the values of the variables which needs to be printed on the output screen.

printf("%d", 10);              - prints 10 on the output screen
printf("%f", num);            - prints the float value in variable num on the output screen
printf("%d and %d", a, b); - prints the value of the integers a and b on the output screen.

Suppose, if the value of a is 10 and the value of b is 20.  Then, the output for the below statement would be 10 and 20
printf("%d and %d", a, b);


Below is an example C program using scanf( ) and printf( ) functions.
 
#include <stdio.h>
int main() {
/* declarations */
int integer;
unsigned int uint;
float flt;
double dbl;
char str[32];

/* input data from user */
printf("Enter an integer: ");
scanf("%d", &integer); // inputs integer from keyboard
printf("Enter an unsigned integer: ");
scanf("%u", &uint); // inputs unsigned int from keyboard
printf("Enter a float value: ");
scanf("%f", &flt); // inputs float value from stdin(keyboard)
printf("Enter a double value: ");
scanf("%lf", &dbl); // inputs double value
printf("Enter a string:");
scanf("%s", str); // inputs string

/* print the result on the output screen */
printf("\nResult:\n");
printf("Value of integer: %d\n", integer);
printf("Value of unsigned integer: %u\n", uint);
printf("Value of float: %f\n", flt);
printf("Value of double: %lf\n", dbl);
printf("Value of string: %s\n", str);
return 0;
}


  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter an integer: -234324
  Enter an unsigned integer: 1000
  Enter a float value: 10.345
  Enter a double value: 999.234234
  Enter a string:helloworld

  Result:
  Value of integer: -234324
  Value of unsigned integer: 1000
  Value of float: 10.345000
  Value of double: 999.234234
  Value of string: helloworld