notesonly.in

One notebook for every subject — open it anywhere.

Log in

C programming: data types, operators, control statements

Programming Fundamentals · Engineering

Study notes

Write a C program to check if a number is prime. #include <stdio.h> int main() { int n=17, i, flag=1; for(i=2;i*i<=n;i++){ if(n%i==0){flag=0;break;} } if(flag) printf("Prime"); else printf("Not prime"); return 0; } Output: Prime.

← Back to topics for Engineering