Skip to content
Related Articles

Related Articles

Improve Article

Write a URL in a C++ program

  • Difficulty Level : Medium
  • Last Updated : 28 Jun, 2021

Writing URLs in programming code doesn’t affect the program and the compiler will not throw any error.

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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;
}

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
?>


Output:
This code is error free
This code is error free
This code is error free
This code is error free
This code is error free

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/

This article is contributed by MAZHAR IMAM KHAN. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.




My Personal Notes arrow_drop_up
Recommended Articles
Page :