Home > Backend Development > C++ > body text

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

WBOY
Release: 2023-09-11 18:05:02
forward
1348 people have browsed it

写一个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 , ...)
Copy after login

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") )
   { }
}
Copy after login

Using the switch statement

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

Using the while loop

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

Using macro

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

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!