Posts

Showing posts from March, 2019

JAVA Program for Twin Prime Number

Image
Twin Prime Number A twin prime is a prime number that is either 2 less or 2 more than another prime number.  Example- (5,7),  (11,13),  (17,19). In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair. Java Program : class TwinPrimes {     public static void main(String args[]) {         String primeNo = "";         int j = 0;         int LastPrime = 1;         System.out.println("Twin Primes are:");         for (int i = 1; i < 100; i++) {             for (j = 2; j < i; j++) {                if (i % j == 0) {                break;                }             }             if (i == j) {                primeNo += i + " ";                if ((i - LastPrime) == 2) {                System.out.println("("+(i-2)+","+i+")");                }                LastPrime = i;             }

Python Program to check two String are Anagram or not

Anagram An anagram is a word or phrase that's formed by rearranging the letters of another word or phrase. For example, the letters that make up “A decimal point” can be turned into the anagram “I'm a dot in place.” ... “Dormitory” turns into the anagram “dirty room,” Examples of anagram "restful" = "fluster" "funeral" = "real fun" "adultery" = "true lady" "customers" = "store scum" "forty five" = "over fifty" Python Program for Anagram String s1=input("Enter the First String: ") s2=input("Enter the Second String: ") def anagramCheck(s1, s2):           if(sorted(s1)== sorted(s2)):         print("The strings are anagrams.")      else:         print("The strings aren't anagrams.") anagramCheck(s1,s2)

Display Browser information using javascript

Q. Write a program using Java script for Web Page to display browsers information. Ans. <!DOCTYPE> <html> <head>     <title>Browsers information</title>   <script language=javascript>   function showBrowserinfo()   {     document.write("<b>Web Page to display browsers information</b> <br><br>");     document.write("Name "+navigator.appName+"<br>");     document.write("Version "+navigator.appVersion  +"<br>");     document.write("Codename " +navigator.appCodeName  +"<br>");     document.write("Cookie enable"+navigator.cookieEnabled  +"<br>");     document.write("Java Enable"+navigator.javaEnabled  +"<br>");     document.write("Mime type"+navigator.mimeTypes  +"<br>");     document.write("Platform"+navigator.platform  +"<br>");    

Armstrong Number in Javascript

Image
Q. Write a program in javascript to check given number is Armstrong or not ?  Ans.  An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 153 is an Armstrong number example -  153 = 1**3 + 5**3 +  3**3 = 1+125+27 => 153 Armsrong Number program in javascript <!doctype html> <html> <head> <script> function armstr() { var arm=0,a,b,c,d,num; num=Number(document.getElementById("no_input").value); temp=num; while(temp>0) { a=temp%10; temp=parseInt(temp/10); // convert float into Integer arm=arm+a*a*a; } if(arm==num) { alert("Armstrong number"); } else { alert("Not Armstrong number"); } } </script> </head> <body> Enter any Number: <input id="no_input"> <button onclick="armstr()">Check</button></br></br> </body> </html>

Change String into Lowercase

C program for Change String into Lowercase #include<stdio.h> #include<conio.h> void low_str (char[]); int main() {   char string[100];   printf("Enter a string to convert it into Lower case :   ");   gets(string);   low_str(string);   printf("Entered String  converted into lower case is: \"%s\"\n", string);   return 0; } //function for string convert into lower string void low_str(char s[]) {   int c=0;   while(s[c]!='\0')   {     if(s[c]>='A' && s[c]<='Z')     {       s[c]=s[c]+32;     }   c++;   } }