C Program to check whether a given number is prime or not (using do-while loop)
C Programming Language / Loop control in C Language
6478Program:
#include void main() { int number, i = 2; int indicator = 0; printf("Enter a number to check prime or Not: "); scanf("%d",&number); do{ if(number%i == 0) { indicator = 1; break; } i++; }while(i < number/2); if(indicator == 1){ printf(" \n Number %d is not prime. \n", number); } else{ printf(" \n Number %d is prime. \n", number); } }
Output:
Enter a number to check prime or Not: 13 Number 13 is prime.
Explanation:
Check whether a given number is prime or not (using for loop)
Write a program to check whether a number is a prime number or not.(Using While loop)
Write a program to check whether a number is a prime number or not.(Using While loop)
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS