















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to input/output (i/o) and operators in c programming. It covers the use of the scanf() and printf() functions for taking user input and displaying output, respectively. The document also explains the different types of operators in c, including arithmetic, increment/decrement, assignment, relational, and logical operators. It includes examples to illustrate the usage and working of these operators. This comprehensive guide can be useful for students learning c programming, as it covers fundamental concepts that are essential for understanding and writing c code.
Typology: Summaries
1 / 23
This page cannot be seen from the preview
Don't miss anything!
to display output to the user.
In C programming, printf() is one of the main output function. The function sends formatted output to the screen. For example, Example 2: Integer Output
We use %d format specifier to print int types. Here, the %d inside the quotations will be replaced by the value of testInteger. Example 2: C Output
To print float, we use %f format specifier. Similarly, we use %lf to print double values. Example 3: float and double Output
In C programming, scanf() is one of the commonly used function to take input from the user. The scanf() function reads formatted input from the standard input such as keyboards.
Example 5: Integer Input/Output Here, we have used %d format specifier inside the scanf() function to take int input from the user. When the user enters an integer, it is stored in the testInteger variable.
Example 7: C Character I/O
● (^) When a character is entered by the user in the above program, the character itself is not stored. Instead, an integer value (ASCII value) is stored. ● (^) And when we display that value using %c text format, the entered character is displayed. If we use %d to display the character, it's ASCII value is printed. Example 8: ASCII Value
In programming, comments are hints that a programmer can add to make their code easier to read and understand. For example,
There are two ways to add comments in C:
In C programming, there is another type of comment that allows us to comment on multiple lines at once, they are multi-line comments. To write multi-line comments, we use the /..../ symbol. For example,
An operator is a symbol that operates on a value or a variable. For example: + is an operator to perform addition. C has a wide range of operators to perform various operations.
An arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division etc on numerical values (constants and variables). Operator Meaning of Operator
C Increment and Decrement Operators C programming has two operators increment ++ and decrement -- to change the value of an operand (constant or variable) by 1. Increment ++ increases the value by 1 whereas decrement -- decreases the value by 1. These two operators are unary operators, meaning they only operate on a single operand.
Example 2: Increment and Decrement Operators
++a = 11 --b = 99 ++c = 11. --d = 99.
Here, the operators ++ and -- are used as prefixes. These two operators can also be used as postfixes like a++ and a--.