Download presentation

Presentation is loading. Please wait.

Published byJourney Hoad Modified over 4 years ago

1
1 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
2 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
3 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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 directive with the contents of the stdio.h header file from the standard C library.

4
4 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
5 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
6 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
7 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
8 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
9 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
10 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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
11 A Simple C Program /* Take a number multiply it by 10 and display it */ #include 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.

Similar presentations

OK

Overview of C. C—a high-level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories. We will discuss: –the elements of a.

Overview of C. C—a high-level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories. We will discuss: –the elements of a.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google