Posts

Program even and odd

Program   #include <stdio.h> int main() {     int num;     // Input from user     printf("Enter a number: ");     scanf("%d", &num);     // Check even or odd     if (num % 2 == 0) {         printf("The number is Even");     } else {         printf("The number is Odd");     }     return 0; } Explain  % is the modulus operator (gives remainder). If num % 2 == 0 → number is even Otherwise → number is odd If you want, I can also show: Program using loop (multiple numbers) Program without using % operator

Oop concept πŸ₯°

πŸ˜πŸ˜‡  Object-Oriented Programming (OOP) is a programming method that uses objects and classes to design programs. It helps to make programs easy to understand, reusable, and secure. In OOP, everything is treated as an object. πŸ”Ή Basic Concepts of OOP 1. Class A class is a blueprint or template used to create objects. πŸ‘‰ Example: Think of a Car as a class. Car has: Color Speed Model These are called properties (variables) and functions (methods). Code:  C++ class Car { public:     string color;     int speed;     void drive() {         cout << "Car is driving";     } }; 2. Object An object is an instance of a class. πŸ‘‰ Real-life Example: If Car is a class, then BMW, Audi are objects. C++  code Car c1; c1.color = "Red"; c1.speed = 100; c1.drive(); Four Main Principles of OOP 3. Encapsulation Encapsulation means binding data and functions together in a single unit (class). It also protects data from unauthoriz...

Hello world program πŸ˜„

πŸ’₯ Basic Hello World Program in C 😍 Program : C #include <stdio.h> int main() {     printf("Hello, World!");     return 0; } πŸ” Explanation of Each Line (In Detail) 1️⃣ #include <stdio.h> #include → This is a preprocessor directive. It tells the compiler to include the standard input-output header file. < stdio.h> contains built-in functions like: printf() → used to print output scanf() → used to take input πŸ‘‰ Without this line, printf() will not work. 2️⃣ int main() main() is the starting point of every C program. The program execution always begins from this function. int means this function will return an integer value. 3️⃣ { } (Curly Braces) These define the body of the function. All statements of the program are written inside these braces. 4️⃣ printf("Hello, World!"); printf() is an output function. It prints the message written inside double quotes ("") on the screen. ✔ "Hello, World!" → This is a string constant (you s...

Special symbols (Separators)

 πŸ”· Special Symbols in C (Specific Symbols) in Detail Special Symbols are characters that have a fixed meaning in C programming. They are used to perform different operations like grouping, separating, defining blocks, accessing data, etc. πŸ’«List of Special Symbols in C Language Symbol        Name         Function / Use   ()                  Parentheses     Used in functions                                                   and expressions {}                 Curly Braces     Define the                                                          ...

Operator in c programming language

 πŸ’₯ Operators in C Programming Language (In Detail) In C programming, an operator is a symbol that tells the compiler to perform a specific mathematical or logical operation on variables and values. πŸ‘‰ Example: C a + b Here,          + is an operator and a, b are operands. πŸ”Ή Types of Operators in C Language 1. Arithmetic Operators Used to perform basic mathematical operations. Operator      Meaning         Example +                   Addition              a + b -                   Subtraction          a - b *                  Multiplication      a * b /                    Division                a / b %  ...

Constant in c programming language

 What is a Constant? A constant is a value that cannot be modified once it is defined. Example: C 10 3.14 'A' "Hello" πŸ”Ή Types of Constants in C C constants are mainly divided into: Integer Constants Floating (Real) Constants Character Constants String Constants Enumeration Constants Symbolic Constants 1️⃣ Integer Constants These are whole numbers (without decimal point). ➤ Types of Integer Constants ( a) Decimal Integer Base 10 numbers Digits: 0–9 Example: C 10 -25 500 ( b) Octal Integer Base 8 numbers Starts with 0 Digits: 0–7 Example: C 075 012 (c) Hexadecimal Integer Base 16 numbers Starts with 0x or 0X Digits: 0–9 and A–F Example: C 0x1A 0XFF 2️⃣ Floating (Real) Constants These contain decimal points or exponential form. ➤ Types: (a) Fractional Form C 3.14 -0.98 10.0 (b) Exponential Form C 1.5e3 // 1.5 × 10³ 2E-2 // 2 × 10⁻² 3️⃣ Character Constants A single character enclosed in single quotes ' '. Example: C 'A' '5' '#' ...

Identifiers in c programming language

 What are Identifiers in C? Identifiers are the names given to program elements in C. They are used to identify variables, functions, arrays, structures, unions, and labels. πŸ‘‰ Simply: An identifier is a name used to identify something in a program. Examples of Identifiers C int number; float total_marks; void calculateSum(); Here: number → variable identifier total_marks → variable identifier calculateSum → function identifier Rules for Naming Identifiers in C An identifier must follow these rules: 1.Only alphabets, digits, and underscore (_) are allowed ✅ total_marks ❌ total-marks 2.First character must be a letter or underscore ✅ _count, sum ❌ 1sum 3.Cannot use keywords as identifiers ❌ int, float, return (These are reserved words) 4.No spaces allowed ❌ total marks ✅ total_marks 5.Case-sensitive Sum and sum are different identifiers 6.Length C allows long identifiers, but first 31 characters are significant (for many compilers) πŸ‘‰Valid and Invalid IdentifiersπŸ˜€ Valid Identifier...