0% found this document useful (0 votes)
6 views1 page

Answer C

The document outlines various types of operators in C programming, including arithmetic, relational, logical, bitwise, increment/decrement, assignment, and typecast operators. It also explains concepts of cohesion and coupling in software design, as well as the use of header files for organizing code. Additionally, it provides a sample C program that demonstrates drawing shapes and displaying employee information.

Uploaded by

dosrokhaata2
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)
6 views1 page

Answer C

The document outlines various types of operators in C programming, including arithmetic, relational, logical, bitwise, increment/decrement, assignment, and typecast operators. It also explains concepts of cohesion and coupling in software design, as well as the use of header files for organizing code. Additionally, it provides a sample C program that demonstrates drawing shapes and displaying employee information.

Uploaded by

dosrokhaata2
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/ 1

Answer number 9--- >= (Greater than or equal to) Answer number 11---

Cohesion: Cohesion refers to the degree to which the components of a <= (Less than or equal to)
3.) Logical Operators: structure union
module (or function) are logically related to one another and work together
&& (AND): True if both operands are true. Each member has its own memory All members share the same
to achieve a single purpose.
|| (OR): True if at least one operand is true. space. memory space.
Coupling: Coupling refers to the degree of dependency between different
! (NOT): Reverses the logical state. The size is the sum of the sizes of The size is equal to the size of the
modules or components in a system.
4.) Bitwise Operators: all members. largest member.
Keywords are reserved words in C that have predefined meanings. They & (AND)
cannot be used as variable names, function names, or identifiers. | (OR) All members can be accessed Only one member can be accessed
Examples: ^ (XOR) independently. at a time.
 int, char, if, else, return, for, while, switch, void ~ (NOT) Used when you need to store Used when you need to store
<< (Left shift) related data that will be used different types of data, but only one
Operators are symbols used to perform operations on variables or values. >> (Right shift) together. at a time.
Types of Operators in C: 5.) Assignment Operators:
1.) Arithmetic Operators: Used for basic arithmetic operations. = (Simple assignment) Less memory efficient (due to
More memory efficient (shares
+ (addition), - (subtraction), * (multiplication), / (division), % (modulus) +=, -=, *=, /=, %= (Compound assignment) independent memory for each
memory space for all members).
2.) Relational Operators: Used to compare values. 6.) Increment/Decrement Operators: member).
== (equal to), != (not equal to), > (greater than), < (less than), >= (greater ++ (Increment)
than or equal to), <= (less than or equal to) -- (Decrement) #include <stdio.h>
3.) Logical Operators: Used for logical operations. 7.)sizeof: Returns the size of a data type or variable. #include <string.h>
&& (AND), || (OR), ! (NOT) 8.)Typecast Operator:
4.) Bitwise Operators: Used for bit manipulation. (type): Converts one data type to another. struct Employee {
& (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (bitwise NOT), << (left char name[50];
shift), >> (right shift) Answer number 7--- char department[50];
5.) Increment/Decrement Operators: Used to increase or decrease C Program to Draw a Circle, Rectangle, and Display “BCA Exam char address[100];
the value of a variable. 2081”: float salary;
++ (increment), -- (decrement) #include <graphics.h> int age;
#include <conio.h> };
Header files in C contain declarations of functions and macros that can be int main() {
used in multiple source files. They are used to organize code and allow the int gd = DETECT, gm; void displayEmployee(struct Employee emp) {
reusability of functions and declarations. initgraph(&gd, &gm, ""); if (emp.age >= 30 && emp.age <= 50 && strcmp(emp.address,
Common Header Files: "Kathmandu") == 0) {
<stdio.h>: Contains input/output functions like printf(), scanf(). setcolor(RED); printf("Employee Name: %s\n", emp.name);
<stdlib.h>: Contains memory management functions like malloc(), }
free(), and process control functions like exit(). int circle_x = 300, circle_y = 200, radius = 50; }
circle(circle_x, circle_y, radius); int main() {
In C programming, operators are symbols used to perform operations struct Employee employees[] = {
on variables or values. There are several types of operators in C, categorized int rect_left = 100, rect_top = 100, rect_right = 400, rect_bottom = 300; {"John Doe", "IT", "Kathmandu", 60000, 35},
based on the operations they perform. rectangle(rect_left, rect_top, rect_right, rect_bottom); {"Jane Smith", "HR", "Lalitpur", 50000, 40},
Types of Operators in C {"Alice Johnson", "Finance", "Kathmandu", 55000, 45},
setcolor(WHITE); {"Bob Brown", "Marketing", "Kathmandu", 65000, 32},
1.) Arithmetic Operators:
{"Charlie Davis", "Sales", "Kathmandu", 70000, 60}
+ (Addition): Adds two operands.
outtextxy(250, 350, "BCA Exam 2081"); };
- (Subtraction): Subtracts the second operand from the first.
int n = sizeof(employees) / sizeof(employees[0]);
* (Multiplication): Multiplies two operands.
/ (Division): Divides the first operand by the second. getch();
for (int i = 0; i < n; i++) {
% (Modulus): Returns the remainder after division.
closegraph(); displayEmployee(employees[i]);
}
2.) Relational Operators (Comparison):
== (Equal to) return 0;
} return 0;
!= (Not equal to)
}
> (Greater than)
< (Less than)

You might also like