Friday, 27 November 2020

How to check url is http or https in java

 This is a java program to check protocol is http or not.

URLProtocolDemo.java    

 
import java.net.*;    
public class URLProtocolDemo{    
public static void main(String[] args){  
//String url="https://www.w3schools.com/html/";  
try{    
    URL url=new URL(url);    
     String protocol=   url.getProtocol();
     System.out.println("Protocol of given url is : "+protocol);
     if(protocol.equalsIgnoreCase("https")); 

     System.out.println("Protocol is a https protocol");    
       }

    else{

           if(protocol.equalsIgnoreCase("http")){
                   System.out.println("Protocol is a http protocol");    
              }

          else{
                   System.out.println("Protocol is neither http nor https protocol ");    
               }    
   }

catch(Exception e)  {
    System.out.println(e);
  }  
 }
}



Thursday, 26 November 2020

Printing diagonal elements of a given matrix in C language

Printing diagonal elements of a given matrix in language: 

In this we are going to display left and right diagonal elements of a given matrix in language.

#include <stdio.h>
void main(){
int matrix1[3][3],i, j;

 // reading the elements of first matrix
    printf(" enter elements of first matrix ");
    for( i=0; i<3 ;i++){
        for(j=0;j<3;j++){
            scanf( "%d", &matrix1[i][j]);
        }
    }

    // printing the resultant matrix  
    printf(" the matrix is  \n");
    for (i=0; i<3; i++){
        for( j=0; j<3; j++){
            printf(" %d ", matrix1[i][j]);
        }
        printf(" \n ");
    }
printf(" the left diagonal elements of this matrix are \n");

printf( "%d,   %d,   %d ",  matrix1[0][0],matrix1[1][1],matrix1[2][2]);

printf(" the right diagonal elements of this matrix are \n");

printf(" %d,   %d,   %d ",  matrix1[0][2],matrix1[1][1],matrix1[2][0]);
}

Sunday, 22 November 2020

What's the difference between comment line and code line?

What's the difference between comment line and code line?

  • Comment line:  

    Comment line is a that describes something about the code. But these lines wont get executed.
  •  Code line: 

    Code line  is a line that has the logic or our program. This line will get executed. Compiler will compile this line and output will be generated.
The similarity between comment line and code line is both will be there in the same file.But when we run code line will get executed and comment line wont get executed.

Tuesday, 17 November 2020

Elements features of Basic and C programming

Elements features of Basic and C programming:

BASIC Language Features:

BASIC a programming language which is abbreviated as Beginners All Purpose Symbolic Instruction Code,  is the Simplest and high level programming language.


 The language used in BASIC is very simple English, which can be easily programmed by anyone.
 
 BASIC a programming language designed in 1964, by John G. Kemeny and Thomas E. Kurtz  at Dartmouth College in the U.S. state of New Hampshire.
 This programming language is widely used because it is easy to learn  and it supported by most  operating systems.


 
It was the principal programming language during the 1970s taught to students,

As it is simple, BASIC language is used for a wide variety of business applications.
There is an ANSI standard for the BASIC programming language.

It allow multi features which are described below.
   

  1.     It is a general-purpose programming languages  
  2.     It is a high-level programming languages
  3.     It allow input from the keyboard.
  4.     It access Menu driven Application.
  5.     It is structured programming language.
  6.     BASIC programming language has Built in Functions.
  7.     BASIC allow User defined functions.
  8.     Subroutine features are available  BASIC language.
  9.     It allows us to  create Loops.
  10.     It contains several System commands.