Write a C program to print "Geeks for Geeks" without using a semicolon Last Updated : 11 Sep, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report First of all we have to understand how printf() function works. Prototype of printf() function is: int printf( const char *format , ...) Parameter format: This is a string that contains a text to be written to stdout.Additional arguments: ... (Three dots are called ellipses) which indicates the variable number of arguments depending upon the format string. printf() returns the total number of characters written to stdout. Therefore it can be used as a condition check in an if condition, while condition, switch case and Macros. Let's see each of these conditions one by one. Using if condition: C #include<stdio.h> int main() { if (printf("Geeks for Geeks") ) { } } Time Complexity: O(1)Auxiliary Space: O(1) 2. Using while condition: C #include<stdio.h> int main(){ while (!printf( "Geeks for Geeks" )) { } } Time Complexity: O(n)Auxiliary Space: O(1) 3. Using switch case: C #include<stdio.h> int main(){ switch (printf("Geeks for Geeks" )) { } } Time Complexity: O(1)Auxiliary Space: O(1) 4. Using Macros: C #include<stdio.h> #define PRINT printf("Geeks for Geeks") int main() { if (PRINT) { } } Time Complexity: O(1)Auxiliary Space: O(1) Output: Geeks for Geeks One trivial extension of the above problem: Write a C program to print ";" without using a semicolon c #include<stdio.h> int main() { // ASCII value of ; is 59 if (printf("%c", 59)) { } } Output: ; Time Complexity: O(1) Auxiliary Space: O(1) This blog is contributed by Shubham Bansal. Comment More infoAdvertise with us Next Article Write a C program to print "Geeks for Geeks" without using a semicolon K kartik Follow Improve Article Tags : Misc C Language c-puzzle Practice Tags : Misc Similar Reads C Program to print numbers from 1 to N without using semicolon? How to print numbers from 1 to N without using any semicolon in C. C #include<stdio.h> #define N 100 // Add your code here to print numbers from 1 // to N without using any semicolon What code to add in above snippet such that it doesn't contain semicolon and prints numbers from 1 to N?We stro 2 min read How to print a semicolon(;) without using semicolon in C/C++? Another interesting question is how can a semicolon be printed without using any semicolon in the program. Here are methods to print ";" : Using printf / putchar in if statement: CPP // CPP program to print // ; without using ; // using if statement #include <stdio.h> int main() { // ASCII val 1 min read C program to print characters without using format specifiers As we know that there are various format specifiers in C like %d, %f, %c etc, to help us print characters or other data types. We normally use these specifiers along with the printf() function to print any variables. But there is also a way to print characters specifically without the use of %c form 1 min read Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure? As we all know the concept of printing the given string repeatedly using various loops(for loop,while loop),recursion and some control structure also. But the question is how we will print the given string repeatedly i.e. infinitely without using any loops,recursion and any control structure? Exampl 1 min read Print "Hello World" in C/C++ without using any header file Write a C/C++ program that prints Hello World without including any header file. Conceptually it's seems impractical to write a C/C++ program that print Hello World without using a header file of "stdio.h". Since the declaration of printf() function contains in the "stdio.h" header file. But we can 2 min read Like