Home > Article > Backend Development > Write a program to print "Tutorials Point" in C language without using semicolon
In this problem we have to write a program to print "Tutorials Point" without using semicolon.
We all know that it is necessary to end a statement with a semicolon. The print statement will be executed when a semicolon is added at the end.
So, to print the "tutorial point" without semicolon, we first need to understand the printf method in c. in actually returns an integer, which is the total number of characters that need to be printed.
int printf(constant char *format, ...)
This method can accept n parameters. The first is the string to be printed, which returns the total number of characters to be printed.
Using the knowledge about the printf method we can print the "tutorial point" without using a semicolon by using a print statement inside the conditional statement, which will execute an empty code piece. Alternatively, we can use macros and while loops to accomplish this task.
Let’s take a look at them,
Program using if statement for printing, p>
Real-time demonstration
#include<stdio.h> int main(){ if (!printf("Tutorails Point") ) { } }
Tutorails Point
A program that uses switch statements to print,
Real-time demonstration
#include<stdio.h> int main(){ switch (!printf("Tutorails Point") ) { } }
Tutorails Point
Program using while loop printing,
Online demonstration
#include<stdio.h> int main(){ while(!printf("Tutorails Point") ) { } }
Tutorails Point
Program using macros for printing,
Real-time demonstration
#include<stdio.h> #define printstr printf("Tutorails Point") int main(){ if (!printstr) { } }
Tutorails Point
The above is the detailed content of Write a program to print "Tutorials Point" in C language without using semicolon. For more information, please follow other related articles on the PHP Chinese website!