Introduction
If you're starting your journey in programming, learning the C language is a solid foundation. It not only teaches core programming logic but also gives you insight into how computer memory, data types, and control structures work. Below are the most important and commonly practiced C programs every diploma computer engineering student or beginner should know. These simple examples will help you understand syntax, user input, and output formatting in C.
Hello World Program C Program
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Addition of Two Numbers C Program
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
Multiplication of Two Numbers C Program
#include <stdio.h>
int main() {
int a, b, multiply;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
multiply = a * b;
printf("Multiply = %d", multiply);
return 0;
}
Subtraction of Two Numbers C Program
#include <stdio.h>
int main() {
int a, b, subtract;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
subtract = a - b;
printf("Subtraction = %d", subtract);
return 0;
}
Related Posts
Division of Two Numbers C Program
#include <stdio.h>
int main() {
float a, b, result; // Corrected variable name
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
result = a / b; // Correct usage
printf("Result = %.2f\n", result);
return 0;
}
Add Zero Division Check C Program
#include <stdio.h>
int main() {
float a, b, divide;
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
if (b != 0) {
divide = a / b;
printf("Division = %.2f", divide);
} else {
printf("Error! Division by zero is not allowed.");
}
return 0;
}
Conclusion
Mastering these basic C programs is essential for building a strong programming foundation. Whether you're preparing for exams, lab tests, or interviews, these programs will help you understand the core structure and logic of C. As you progress, try combining these concepts into larger, more complex projects. Practice regularly, and you'll gain confidence and fluency in programming with C.