- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a program to print ‘Tutorials Point’ without using a semicolon in C
In this problem, we have to write a program that will print ‘Tutorials Point ’ without using a semicolon.
We all know that to end a statement in c semicolon is necessary. And print statement will be executed when a semicolon is added at the end.
So, for printing ‘Tutorials point’ without a semicolon, we will have to first learn about the printf method in c. in actually returns an integer which is the count of total number of characters that are required to be printed.
Syntax
int printf(constant char *format, ...)
The method can accept n number of arguments. The first will be the string to be printed and it returns the total number of characters to be printed.
Using this knowledge about the printf method we can print ‘tutorials point’ without using a semicolon by using the print statement inside the condition of a conditional statement, which will execute an empty block of code. Also, we can use macros and while loop for completing this task.
Let’s see each of them,
Program to print using if statement,
Example
#include<stdio.h> int main(){ if (!printf("Tutorails Point") ) { } }
Output
Tutorails Point
Program to print using switch statement,
Example
#include<stdio.h> int main(){ switch (!printf("Tutorails Point") ) { } }
Output
Tutorails Point
Program to print using while loop,
Example
#include<stdio.h> int main(){ while(!printf("Tutorails Point") ) { } }
Output
Tutorails Point
Program to print using macros,
Example
#include<stdio.h> #define printstr printf("Tutorails Point") int main(){ if (!printstr) { } }
Output
Tutorails Point