Printing a line of text without sem;colon

Photo by Kevin Ku from Pexels

I could work as a content writer for a couple of newsletters during my college life and also helped friends in coding. I like debugging a lot. Well I wanted to share a couple of common programming language related questions that I saw in some popular sites.

“Printing a line of text without semicolon” is a very famous question.

I came across this question around 20 to 25 times. So here is the code solution to this one:

Well, let me explain this code for those people who are confused of what happens in this code. The lines marked #1 to #6 and #8 does not need explanation if you know the C programming language’s general syntax. Even the line marked #7 is a small manipulation of the general syntax of if.

if() denotes a condition statement, that evaluates to true if the statement given in the parenthesis evaluates to true, else, if() evaluates to false. printf() is a function that prints the argument passed to it(let us keep it simple here). Hence it evaluates to true if it has an argument and if() also evaluates to true. Hence the if part is executed and it has no statement. This code hence prints the message without any semicolons.

(Go to http://alvand.basu.ac.ir/~dezfoulian/files/Programming/Prentice%20Hall%20-%20The%20C%20Programming%20Language-%20Brian%20W.%20Kernighan,%20Dennis%20M.%20Ritchie,%202nd%20ed.,%20ISBN%20.pdf for a pdf version of the text to learn C programming language. I found this one online.)

Originally published at https://anand-jagadeesh.blogspot.com on May 16, 2020.

--

--

Enthusiastic about DevOps, ML/AI, XAI & Interpretable AI, Edge Computing and Energy Efficient AI | GGP'22 @ VCC | MSc AI @ UofStA'22 | Ex-SE2 @ Dell EMC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anand Jagadeesh

Enthusiastic about DevOps, ML/AI, XAI & Interpretable AI, Edge Computing and Energy Efficient AI | GGP'22 @ VCC | MSc AI @ UofStA'22 | Ex-SE2 @ Dell EMC