1 / 11

A Simple C Program

A Simple C Program. /* Take a number multiply it by 10 and display it */ #include &lt; stdio.h &gt; main() { int number, result; printf (&quot;Type in a number <br>&quot;); scanf (&quot;%d&quot;, &amp;number); result = number *10; printf (&quot;The number multiplied by 10 equals %d<br>&quot;, result); } Sample Program Output

pearl
Télécharger la présentation

A Simple C Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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 */

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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

  8. 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.

  9. 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

  10. 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.

  11. 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.

More Related