User Avatar

Brett Leonard

1y ago

Helping Tech Experts Build Leadership Skills & Thrive in an AI-Driven World.

My programming roots: Demystifying and connecting C language through Hello World

In 2001, I went back to school for computers and software development. The first programming language I learned was C. I'm going to introduce you to it in this essay and connect it's syntax with Java and C#.

This is Hello World in C

#include <stdio.h>

int main()

{

printf("Hello World");

}

Much of the structure of Java and C# is derived from C. Take the first line, #include<stdio>. Can you name the Java and C# equivalents?

That first line is a preprocessor directive that tells the compiler to include a specific library. In this case, it is the standard input/output library. This is equivalent to the "import" (import java.io.*; and "using" (using System;) statements in Java and C#.

The next line, int main(), is a declaration of the main function, which serves as the entry point of the program that returns an integer. The Java equivalent is "public static void main(String[] args)" and the C# is "public static void Main(string[] args)". Again, very similar to C.

Now you can see why behind the origin story of Java and C# is C.

In the last block, we see these curly braces, "{" and "}", used to open and close code blocks. Here we see a deviation in usage, but the fundamental concept is the same. Both Java and C# have adopted this method of separating out code statements.

The line "printf("Hello World");" is a call to the "printf" function, which is used for formatted output in C. The Java equivalent is "System.out.println("Hello World");" and the C# is "Console.WriteLine("Hello World");" As you can see, both are very similar to C. Also, the ";" as a line terminator is common in each language.

The all-in-one writing platform.

Write, publish everywhere, see what works, and become a better writer - all in one place.

Trusted by 80,000+ writers