Prime Number Check - C Typing CST Test
Loading…
Prime Number Check — C Code
Determines if a number is prime by checking divisibility up to square root. Shows optimization in prime checking.
#include <stdio.h>
int main() {
int n = 29, isPrime = 1;
for (int i = 2; i <= n / 2; i++) {
if (n % i == 0) {
isPrime = 0;
break;
}
}
if (isPrime)
printf("%d is Prime\n", n);
else
printf("%d is Not Prime\n", n);
return 0;
}C Language Guide
C is a general-purpose, procedural programming language that provides low-level access to memory, efficient performance, and a foundation for system and application software development.
Primary Use Cases
- ▸Operating system kernels (e.g., Linux, Windows)
- ▸Embedded systems and microcontrollers
- ▸Device drivers and hardware interfaces
- ▸Compilers, interpreters, and runtime systems
- ▸High-performance computing and real-time applications
Notable Features
- ▸Low-level memory access with pointers
- ▸Procedural programming with structured code
- ▸Efficient and fast execution
- ▸Standard libraries for I/O, string, and math operations
- ▸Portability across platforms via ANSI C standard
Origin & Creator
Created by Dennis Ritchie at Bell Labs in 1972, originally for developing the UNIX operating system.
Industrial Note
C is essential in embedded systems, OS kernels, compilers, device drivers, and performance-critical applications where low-level memory control and speed are required.