Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary basic c language course in 1 hour

Rating
-
Sold
-
Pages
25
Uploaded on
04-12-2023
Written in
2021/2022

learning c language makes every programing language easier

Institution
Course

Content preview

1

Operators
A n o p e r a t o r i s a s y m b o l t h a t t e l l s t h e c o m p i l e r t o p e r f o r m s p e c i fi c m a t h e m a ti c a l o r
l o g i c a l f u n c ti o n s . A n o p e r a t o r i s a s y m b o l t h a t o p e r a t e s o n a v a l u e o r a v a r i a b l e .
Following are the types of operators

 Arithmetic Operators
 Relational Operators
 Logical Operators
 Bitwise Operators
 Assignment Operators

Arithmetic Operators
The following table shows all the arithmetic, consider variable A has 10 and variable B has 20 then
Operator Description Example

+ Adds two operands. A + B = 30

− Subtracts second operand from the first. A − B = -10

* Multiplies both operands. A * B = 200

/ Divides numerator by de-numerator. B/A=2

% Modulus Operator and remainder of after an integer division. B%A=0

++ Increment operator , it increases the integer value by one. A++ = 11

-- Decrement operator, it decreases the integer value by one. A-- = 9



Relational Operators: The following table shows all the relational operators. Assume variable A holds 10
and variable B holds 20 then −

Operator Description Example


== Checks if the values of two operands are equal or not. If yes, then the condition becomes true. (A == B) is
not true.


!= Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. (A != B) is
true.


> Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. (A > B) is not
true.


< Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. (A < B) is
true.


>= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition (A >= B) is
becomes true. not true.


<= Checks if the value of left operand is less than or equal to the value of right operand. If yes, then the condition (A <= B) is
becomes true. true.

, 2

Logical Operators
Following table shows all the logical operators supported by C language. Assume variable A holds 1 and
variable B holds 0, then −
Show Examples
Operator Description Example

&& Called Logical AND operator. If both the operands are non-zero, then the (A && B) is false.
condition becomes true.

|| Called Logical OR Operator. If any of the two operands is non-zero, then the (A || B) is true.
condition becomes true.

! Called Logical NOT Operator. It is used to reverse the logical state of its !(A && B) is true.
operand. If a condition is true, then Logical NOT operator will make it false.


Bitwise Operators
Bitwise operator works on bits and perform bit-by-bit operation. They are &, |, and ^



Operator Description Example

& Binary AND Operator copies a bit to the result if it exists in both operands. (A & B)

| Binary OR Operator copies a bit if it exists in either operand. (A | B)

^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B)


Assignment Operators
The following table lists the assignment operators supported by the C language


Operator Description Example

= Simple assignment operator. Assigns values from right side C = A + B will assign the value of A + B to
operands to left side operand C

+= Add AND assignment operator. It adds the right operand to
C += A is equivalent to C = C + A
the left operand and assign the result to the left operand.

-= Subtract AND assignment operator. It subtracts the right
operand from the left operand and assigns the result to the C -= A is equivalent to C = C - A
left operand.

, 3

C Control Statements:
Control statements is a process of transferring control from one place to another
place or skipping control or repeating control until the condition satisfies .

We have two types,

 Branching
 Looping
Branching: Branching is a process of jumping control from one place to another place (one statement
to another statement)
In branching we have several models
1. if
2. if else
3. if else ladder
4. nested if else
5. switch
Looping:
Looping is a process of repeating certain statements again and again until the condition satisfies.
In looping we have
1. while
2. do while
3. for
if statement:
The statements inside the body of “if” only execute if the given condition returns true. If the condition
returns false then the statements inside “if” are skipped.
Syntax of if statement:



if(condition)
{
Statements;
--
--
}
Ex:
#include <stdio.h>
main()
{
int x,y;
x=10; y=20;
if (x<y)
{
printf("Variable x is less than y");
}
}


if else statement
Syntax of if else statement:
If condition returns true then the statements inside the body of “if” are executed and

Written for

Course

Document information

Uploaded on
December 4, 2023
Number of pages
25
Written in
2021/2022
Type
SUMMARY

Subjects

$9.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
nareshsf6

Get to know the seller

Seller avatar
nareshsf6 lecturer
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
1
Last sold
-
computer science lecturer

I will make you learn different programming languages and make you code very very easy

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions