Home >Backend Development >C++ >Write a C program that prints 'Tutorials Point' without using semicolons

Write a C program that prints 'Tutorials Point' without using semicolons

WBOY
WBOYforward
2023-09-11 18:05:021398browse

写一个C程序,打印“ Tutorials Point ”,不使用分号

To print any string without using semicolon, we need to understand how standard output works and why semicolon is used.

The semicolon is an end-of-line statement that tells the program that the line ends here. The standard print statement printf used here is a method of the standard io library. Let’s take a closer look at 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 macro

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

The above is the detailed content of Write a C program that prints 'Tutorials Point' without using semicolons. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete