Tutorials
Courses
Data Structure
Java
Python
HTML
Interview Preparation
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
SQL
Web Development
System Design
Aptitude
GfG Premium
Similar Topics
Web Technologies
32.8K+ articles
DSA
20.1K+ articles
Misc
8.2K+ articles
C++
4.2K+ articles
C++ Programs
2.1K+ articles
C Language
1.5K+ articles
Recursion
958+ articles
CPP-Library
254+ articles
programming-puzzle
49+ articles
c-puzzle
30+ articles
cpp-puzzle
32 posts
Recent Articles
Popular Articles
Execute both if and else statements in C/C++ simultaneously
Last Updated: 13 September 2023
Write a C/C++ program that executes both if-else block statements simultaneously.Syntax of if-else statement in C/C++ language is:if (Boolean expression){ // Statement ...
read more
C++
c-puzzle
CPP-Basics
cpp-puzzle
Implementing ternary operator without any conditional statement
Last Updated: 16 June 2022
How to implement ternary operator in C++ without using conditional statements.In the following condition: a ? b: cIf a is true, b will be executed.Otherwise, c will be exe...
read more
DSA
Nvidia
cpp-operator
cpp-puzzle
Print "Hello World" with empty or blank main in C++
Last Updated: 14 June 2022
Write a program in C++ that prints "Hello World", it has a main function and body of main function is empty.Following are three different solutions.We can create a global ...
read more
Misc
C++
cpp-puzzle
Using return value of cin to take unknown number of inputs in C++
Last Updated: 23 June 2022
Consider a problem where we need to take an unknown number of integer inputs.A typical solution is to run a loop and stop when a user enters a particular value. How to do ...
read more
Misc
C/C++ Puzzles
C++
cpp-input-output
cpp-puzzle
C/C++ Tricky Programs
Last Updated: 14 March 2024
We may come across various tricky programs in our day-to-day life. Maybe in technical interviews, coding tests, or C/C++ classrooms.Here is a list of such programs:-Print ...
read more
C++
c-puzzle
cpp-puzzle
Programming puzzle (Assign value without any control statement)
Last Updated: 20 July 2022
Given four integers 'a', 'b', 'y' and 'x', where 'x' can only be either zero or one. Your task is as follows:If 'x' is zero assign value 'a' to the variable 'y'If 'x' is o...
read more
Aptitude
cpp-puzzle
programming-puzzle
Maximum of four numbers without using conditional or bitwise operator
Last Updated: 31 October 2023
Given four numbers, print the maximum of the 4 entered numbers without using conditional or bitwise operator (not even ternary operators). Examples: Input : 4 8 6 5Outpu...
read more
Competitive Programming
cpp-puzzle
programming-puzzle
Print a number 100 times without using loop, recursion and macro expansion in C?
Last Updated: 21 June 2022
It is possible to solve this problem using loop or a recursion method. And we have already seen the solution using #define directive (Macro expansion) but what if all thre...
read more
C++
c-puzzle
cpp-puzzle
Print 1 to 100 without loop using Goto and Recursive-main
Last Updated: 06 April 2023
Our task is to print all numbers from 1 to 100 without using a loop. There are many ways to print numbers from 1 to 100 without using a loop. Two of them are the goto stat...
read more
Misc
Recursion
C Language
DSA
cpp-puzzle
Print system time in C++ (3 different ways)
Last Updated: 10 December 2018
First MethodPrinting current date and time using time()Second MethodCPP // CPP program to print current date and time// using time and ctime.#include stdio.h#in...
read more
Misc
C++
cpp-puzzle
date-time-program
Measure execution time of a function in C++
Last Updated: 11 January 2025
We can find out the time taken by different parts of a program by using the std::chrono library introduced in C++ 11. We have discussed at How to measure time taken by a p...
read more
C++
CPP-Library
cpp-puzzle
Calculate range of data types using C++
Last Updated: 12 January 2018
C++ program for printing the range data type like int, char, short.Signed Data TypesMETHOD1.) calculate total number of bits by multiplying sizeof with 8 (say n)2.) Calcul...
read more
Misc
C++ Programs
C++
cpp-data-types
cpp-puzzle
Why "using namespace std" is considered bad practice
Last Updated: 29 March 2024
The statement using namespace std is generally considered bad practice. The alternative to this statement is to specify the namespace to which the identifier belongs using...
read more
Misc
C++
cpp-namespaces
cpp-puzzle
Print a character n times without using loop, recursion or goto in C++
Last Updated: 05 December 2022
Given a character c and a number n, print the character c, n times. We are not allowed to use loop, recursion, and goto. Examples :Input : n = 10, c = 'a'Output : aaaaaaaa...
read more
Misc
C++
cpp-string
cpp-puzzle
Increment a number without using ++ or +
Last Updated: 17 April 2023
The task is to Increment a number without using ++ and + operators.Examples:Input : 3Output : 4Input : 9Output : 10The idea is based on the fact that the negative numbers ...
read more
Bit Magic
C++ Programs
DSA
cpp-puzzle
programming-puzzle
1
2
3
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our
Cookie Policy
&
Privacy Policy
Got It !