Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Comment



Specifer



" ; " after loop



Iterative statement



Header file




Pointer_ print prime or composite number until -1 is entered




// AHF C PROGRAM SOLVING

//solving here POINTER	programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int a,*n= & a; int i,flag=0; pf("Enter -1 to stop."); pf("\nEnter any number: "); scanf("%d",n); while(*n!=-1) { for(i=2;i<*n/2;i++) { /*checking whether the given number is divisible by the condition */ if(*n%i==0) { flag=1; //break; } } if(flag==0) pf("\n%d is prime.",*n); else pf("\n%d is composite.",*n); pf("\nEnter -1 to stop......\t"); scanf("%d",n); //taking number to exit } return 0; }
OUTPUT:


© 2018 - All rights reserved