Program to count the no of digits in a number

Counting the number of digits in a number is a common beginner-level program in C. This helps in understanding how to use loops and arithmetic operations like division. #include <stdio.h> int main() { int num, count = 0; // Input from user printf(“Enter a number: “); scanf(“%d”, &num); // Handle 0 separately if (num == […]

Program to check whether a given number is a palindrome or not

A number is called a palindrome if it reads the same backward as forward. Examples: 121, 1331, 454 are palindrome numbers. #include int main() { int num, original, reversed = 0, remainder; // Input from user printf(“Enter a number: “); scanf(“%d”, &num); original = num; // Store original number // Reverse the number while (num […]

Program to enter a grade & check its corresponding remarks

This program accepts a grade as input (like A, B, C, etc.) and displays the corresponding remark using conditional statements. This is a good practice for learning if-else or switch-case in C. #include <stdio.h> int main() { char grade; // Input from user printf(“Enter your grade (A, B, C, D, F): “); scanf(” %c”, &grade); […]

Write a program to check for the relation between 2 nos

#include <stdio.h> int main() { int num1, num2; // Input two numbers from user printf(“Enter first number: “); scanf(“%d”, &num1); printf(“Enter second number: “); scanf(“%d”, &num2); // Check and display the relationship if (num1 > num2) { printf(“%d is greater than %d\n”, num1, num2); } else if (num1 < num2) { printf(“%d is less than […]

Write a program to check whether the given no is even or odd

#include <stdio.h> int main() { int number; // Input number from user printf(“Enter a number: “); scanf(“%d”, &number); // Check if the number is even or odd if (number % 2 == 0) { printf(“%d is an even number.\n”, number); } else { printf(“%d is an odd number.\n”, number); } return 0; }   Explanation: […]

C and C++

Write a program to perform division of 2 nos

#include int main() { int a,b; float c; printf(“Enter 2 nos : “); scanf(“%d %d”, &a, &b); if(b == 0) { printf(“Division is not possible”); } c = a/b; printf(“quotient is %f \n”,c); return 0; } Enter 2 nos: 6 2 quotient is 3 Output: Enter 2 nos: 6 0 Division is not possible

C and C++

Operators Precedence in C

Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator. For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * […]

C and C++

Operators in C

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C language is rich in built-in operators and provides the following types of operators: Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Increment and decrement operators Conditional operators Misc Operators Arithmetic operator: These are used to perform […]