B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP

C Operators

C operators are special symbols used to perform operations on variables and values. These include arithmetic, relational, logical, and assignment operators.

C ऑपरेटर विशेष प्रतीक होते हैं जो वेरिएबल्स और मानों पर ऑपरेशन करने के लिए उपयोग किए जाते हैं। इनमें अंकगणितीय, तुलनात्मक, लॉजिकल और असाइनमेंट ऑपरेटर शामिल हैं।

Example 1: Addition (+)

#include 

int main() {
    int a = 5, b = 3;
printf("Sum = %d", a + b);
    return 0;
}

Explanation (English): Adds two numbers.

व्याख्या (हिंदी): दो संख्याओं को जोड़ता है।

Output: Sum = 8


Example 2: Subtraction (-)

#include 

int main() {
    int a = 5, b = 3;
printf("Difference = %d", a - b);
    return 0;
}

Explanation (English): Subtracts second number from first.

व्याख्या (हिंदी): दूसरी संख्या को पहली से घटाता है।

Output: Difference = 2


Example 3: Multiplication (*)

#include 

int main() {
    int a = 5, b = 3;
printf("Product = %d", a * b);
    return 0;
}

Explanation (English): Multiplies two numbers.

व्याख्या (हिंदी): दो संख्याओं को गुणा करता है।

Output: Product = 15


Example 4: Division (/)

#include 

int main() {
    int a = 10, b = 2;
printf("Quotient = %d", a / b);
    return 0;
}

Explanation (English): Divides first number by second.

व्याख्या (हिंदी): पहली संख्या को दूसरी से भाग देता है।

Output: Quotient = 5


Example 5: Modulus (%)

#include 

int main() {
    int a = 10, b = 3;
printf("Remainder = %d", a % b);
    return 0;
}

Explanation (English): Gives remainder of division.

व्याख्या (हिंदी): भाग करने के बाद बचा हुआ शेषफल देता है।

Output: Remainder = 1


Example 6: Greater Than (>)

#include 

int main() {
    int a = 5, b = 3;
printf("a > b: %d", a > b);
    return 0;
}

Explanation (English): Checks if a is greater than b.

व्याख्या (हिंदी): जांचता है कि a, b से बड़ा है या नहीं।

Output: a > b: 1


Example 7: Less Than (<)

#include 

int main() {
    int a = 2, b = 4;
printf("a < b: %d", a < b);
    return 0;
}

Explanation (English): Checks if a is less than b.

व्याख्या (हिंदी): जांचता है कि a, b से छोटा है या नहीं।

Output: a < b: 1


Example 8: Equal To (==)

#include 

int main() {
    int a = 4, b = 4;
printf("a == b: %d", a == b);
    return 0;
}

Explanation (English): Checks if a is equal to b.

व्याख्या (हिंदी): जांचता है कि a, b के बराबर है या नहीं।

Output: a == b: 1


Example 9: Not Equal (!=)

#include 

int main() {
    int a = 5, b = 3;
printf("a != b: %d", a != b);
    return 0;
}

Explanation (English): Checks if a is not equal to b.

व्याख्या (हिंदी): जांचता है कि a, b से अलग है या नहीं।

Output: a != b: 1


Example 10: Logical AND (&&)

#include 

int main() {
    int a = 1, b = 0;
printf("a && b: %d", a && b);
    return 0;
}

Explanation (English): Returns true if both a and b are true.

व्याख्या (हिंदी): दोनों सही होने पर true देता है।

Output: a && b: 0


Example 11: Logical OR (||)

#include 

int main() {
    int a = 1, b = 0;
printf("a || b: %d", a || b);
    return 0;
}

Explanation (English): Returns true if at least one is true.

व्याख्या (हिंदी): कम से कम एक सही हो तो true देता है।

Output: a || b: 1