Write a C program to print “ Tutorials Point ” without using a semicolon


To print any string without using a semicolon we need to find how the standard output work and why is semicolon used.

The semicolon is a end of line statement that is used to tell the program that the line is ended here. The standard print statement printf used here is a method of the standard io library. Let's dig deep into the printf() method.

int printf(const char *format , ...)

This method returns an integer and has a set of arguments format and … . The format is a string that is printed in the output screen. And the … is the additional number of arguments that are given to the function based on the string.

The funnctions return the total number of character that is to be printed on the screen.

Using this we can find ways to bypass the use of end of line statement while printing the statement. We can use some statements that do not require the end of LINE statement to execute like the for loop. We can use this to print are set a statement without using the semicolon.

There are several methods by which we can print statement without using the semicolon;

Using the if condition

#include<stdio.h>
int main() {
   if (printf("Tutorials point") )
   { }
}

Using the switch statement

#include<stdio.h>
int main() {
   switch (printf("Tutorials point") )
   { }
}

Using the while loop

#include<stdio.h>
int main() {
   while (printf("Tutorials point") )
   { }
}

Using the macros

#include<stdio.h>
#define Out printf("Tutorials point")
int main() {
   switch (out)
   { }
}

Updated on: 01-Jul-2020

138 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements