C Programming
C Programming
C Programming
C Output
In C programming, printf() is one of the main output function. The function sends formatted output to the
screen. For example,
<stdio.h> statement.
● The return 0; statement inside the main() function is the "Exit status" of the program.
It's optional.
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.
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 6: Float and Double Input/Output
#include <stdio.h>
int main() {
Output :
// print Hello World to the screen Hello World
printf("Hello World");
return 0;
}
Types of Comments
#include <stdio.h>
int main() {
return 0;
}
2. Multi-line Comments in C
In C programming, there is another type of comment that allows us to comment on multiple lines at
#include <stdio.h>
int main() {
int age;
…………………………….
C Programming Operators
Operator Meaning of Operator
An operator is a symbol that operates on a value or a variable. For
example: + is an operator to perform addition. + addition or unary plus
/ division
c = a+b;
Example 1: Arithmetic Operators printf("a+b = %d \n",c);
c = a-b;
printf("a-b = %d \n",c);
c = a*b;
printf("a*b = %d \n",c);
c = a/b;
printf("a/b = %d \n",c);
Output : c = a%b;
printf("Remainder when a
a+b = 13 divided by b = %d \n",c);
a-b = 5
a*b = 36
a/b = 2 return 0;
Remainder when a divided by b=1 }
C Increment and Decrement Operators
C programming has two operators increment ++ and decrement -- to change the value of
These two operators are unary operators, meaning they only operate on a single operand.
Example 2: Increment and Decrement Operators
return 0;
}
C Assignment Operators
An assignment operator is used for assigning a value to a variable. The
= a=b a=b
+= a += b a = a+b
-= a -= b a = a-b
*= a *= b a = a*b
/= a /= b a = a/b
%= a %= b a = a%b
C Relational Operators Operat Meaning of Operator Example
or
&& Logical AND. True only if all If c = 5 and d = 2 then, expression ((c==5)
operands are true && (d>5)) equals to 0.