120 likes | 204 Views
A Simple C Program. /* Take a number multiply it by 10 and display it */ #include < stdio.h > main() { int number, result; printf ("Type in a number <br>"); scanf ("%d", &number); result = number *10; printf ("The number multiplied by 10 equals %d<br>", result); } Sample Program Output
E N D
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Comments are set between /* and */
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The C pre-processor replaces this directivewith the contents of the stdio.h header file from the standard C library.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Every C program must have one main function.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Each variable must be explicitly defined as a specific type.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the printf() function for creating output.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the printf() function for creating output. \n is the newline character
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the scanf() function for capturing input.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 %d tells scanf() to interpret the input as a decimal value
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The = operator is used for assignment. The * operator is used for multiplication.
A Simple C Program /* Take a number multiply it by 10 and display it */ #include <stdio.h> main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 %d tells printf() to treat the value of the result variable as a decimal nbr.