Open In App

Write a URL in a C++ program

Improve
Improve
Like Article
Like
Save
Share
Report

Writing URLs in programming code doesn’t affect the program and the compiler will not throw any error.
 Here, we will how to use Url in various languages without any errors.

The full form of URL is  Uniform Resource Locators. URLs are unique they store the address of a particular web application.

C++




// C++ program to demonstrate URL in code
#include <iostream>
using namespace std;
 
int main()
{
    https://www.geeksforgeeks.org/
 
    for (int i = 0; i < 5; i++)
    {
        cout << "This code is error free" << endl ;
 
        // Uncommenting below goto statement causes
        // infinite loop
        // goto http;
    }
 
    return 0;
}


Java




/*package whatever //do not write package name here */
import java.io.*;
 
class GFG {
    public static void main (String[] args)
    {
         https://www.geeksforgeeks.org/
        for(int i = 0; i < 5; i++){
             System.out.println("This code is error free");
        }
    }
}


PHP




<?php
// PHP program to demonstrate
// URL in code
 
https://www.geeksforgeeks.org/
 
for ($i = 0; $i < 5; $i++)
{
    echo "This code is error " .
                 "free" , "\n" ;
 
    // Uncommenting below
    // goto statement causes
    // infinite loop
     
    // goto https;
}
 
// This code is contributed
// by m_kit
?>


C#




using System;
class Demo {
  static void Main() {
    string input = "https://www.geeksforgeeks.org";
     
    // See if input matches one of these starts.
    for (int i = 0; i < 5; i++)
 
      Console.WriteLine("This code is error");
  }
}
 
// This code is contributed by aayushcoding100.


Javascript




<script>
//new URL(url, [base])
let mainUrl = new URL('https://www.geeksforgeeks.org');
alert(mainUrl);
for (let i = 0; i < 5; i++) {
        document.write("This code is error");
}
 
// This code is contributed by aayushcoding100.
</script>


Output: 
 

 

Explanation: 
 

  1. Any identifier followed by a : becomes a (goto) labels in a Program.
  2. A single line comment begins with a // and so in https://www.geeksforgeeks.org/ and so it is a comment. And therefore:
label- http: 
comment- www.geeksforgeeks.org/

Time complexity : O(1) 
Auxiliary Space : O(1)



Last Updated : 21 Jun, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads