0% found this document useful (0 votes)
38 views4 pages

LTC-04 C Program

The document discusses various arithmetic assignment operators in C language: addition, subtraction, multiplication, division, and modulo division assignment. It provides examples of each operator and their equivalent expressions. It also provides two code examples demonstrating the use of multiplication and division assignment operators and their outputs. The second document section discusses decision control structures in C including if, if-else, nested if-else, break, continue, goto, and switch statements. It provides syntax examples and outputs for if and if-else statements.

Uploaded by

Kh Jl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views4 pages

LTC-04 C Program

The document discusses various arithmetic assignment operators in C language: addition, subtraction, multiplication, division, and modulo division assignment. It provides examples of each operator and their equivalent expressions. It also provides two code examples demonstrating the use of multiplication and division assignment operators and their outputs. The second document section discusses decision control structures in C including if, if-else, nested if-else, break, continue, goto, and switch statements. It provides syntax examples and outputs for if and if-else statements.

Uploaded by

Kh Jl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

 Arithmetic Assignment operators C language supports five arithmetic

assignment operators
1. Addition assignment
- It is expressed by +=
- The expression a+=b have same meaning as a=a+b
2. Subtraction assignment
- It is expressed by -=
- The expression a-=b have same meaning as a=a-b
3. Multiplication assignment
- It is expressed by *=
- The expression a*=b have same meaning as a=a*b
4. Division assignment
- It is expressed by /=
- The expression a/=b have same meaning as a=a/b
5. Module division assignment
- It is expressed by %=
- The expression a%=b have same meaning as a=a%b
// Find the output of this program // // Find the output of this program //
#include<stdio.h> #include<stdio.h>
#include<conio.h> #include<conio.h>
void main() { void main() {
int a=10, b=3; int a=10, b=3;
clrscr(); clrscr();
a*=2; a/=2;
b+=5; b%=2;
printf("a=%d \t b=%d ", a, b); printf("a=%d \t b=%d ", a, b);
getch(); getch();
} }
OUTPUT: a=20 b=8 OUTPUT: a=5 b=0
Size of operator
- It is used to display required amount of memory for store data.
- syntax:
sizeof(name of the variable)
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
clrscr();
b=sizeof(a);
printf("size of a is =%d", b);
getch();
}
--------------------------------------x-------------------------------------

# THE DECISION CONTROL STRUCTURE #


Decision controls:
- Program is a group of several statements which are compiling one by one
through compiler. But compiler does not know which statement will be executed
first and which statement will be execute last.
- This problem is solved by using decision controls.
- Decision controls are used to control the flow of execution of the program.
TYPES: They are many types.
1. if statement. 5. continue statement.
2. if else statement. 6. go to statement.
3. Nesting of if else statement. 7. switch statement.
4. break statement.
1. if statement
- If condition is true then given statement or a block of statement will be
execute otherwise not.

Syntax: if(conditon)
{
do this ----
do this ----
}
NB: The region between curly brackets is referred as block of is statement
Program Program
#include<stdio.h> #include<stdio.h>
#include<conio.h> #include<conio.h>
void main() void main()
{ {
int x=10, y=20; int x=10, y=10;
clrscr(); clrscr();
if(x!=y) if(x!=y)
printf("condition is match"); printf("condition is match");
getch(); getch();
} }
OUTPUT: condition is match OUTPUT:
2. if else statement
- If the condition is true, then block of ` if ‘ statement/statements will be
executed otherwise else part will be executed.
Syntax: if(condition) {
----
----
}
else {
----
----
}
// Find the output of the following program //
#include<stdio.h>
#include<conio.h>
void main()
{
int x=10, y=20;
clrscr();
if(x>=y)
printf("condition is true ");
else
printf("condition is false");
getch();
}
OUTPUT: condition is false
_______________________________________________________

// Find the output of the following program //


#include<stdio.h>
#include<conio.h>
void main()
{
int x=30, y=20;
clrscr();
if(x>=y) {
printf("x=%d \t", x);
printf("DSW");
}
else {
printf("y=%d", y);
printf("LAW");
}
getch();
}
OUTPUT: x=30 DSW

You might also like