C Program to check prime number #include<conio.h> #include<stdio.h> void main() { int p,i; clrscr(); printf("enter no. to check prime: "); scanf("%d",&p); for(i=2;i<p;i++) if(p%i==0) { printf("%d is not a prime number ",p); break; } if(i==p) printf("%d is prime number",p); getch(); } Explanation int p,i; p and i are two variables of integer type ; printf() and scanf() are predefine functions use for read and write respectively. for(i=2;i<p;i++) for loop use to check prime number count if(p%i== 0) if p % i = 0 then it means 'p' has any common factor between 1 to p which means it is not a prime...
skillrocks technical interview question Q1 an array of 20 integer having digits 1 to 20 in random order, if we omit any one digit and replace it by zero find the number omitted. example |1|3|5|7|8|9|4|2|6|10|0|13|15|16|17|19|18|15|20|12|14| Q2 find the greatest no. from an array having random numbers of 100 size, with out sorting. Q3 find the frequency of 1 to 9 from an array of size 100 having value 1 to 9 randomly arranged Conditions: 1. use only one loop. 2. do not use counters. 3. most efficiently Answer is waiting.....
This Function check if the given string is date type or not!!. And Return True or false according to the result. function isDate($string ='') { DateTime::createFromFormat('Y-m-d', $string) !== FALSE ? return true : return false; }
Comments
Post a Comment