How to print numbers from 1 to N without using any semicolon in C.
What code to add in above snippet such that it doesn’t contain semicolon and prints numbers from 1 to N?
We strongly recommend you to minimize your browser and try this yourself first
Method 1 (Recursive)
1 2 3 4 5 6 7 8 9 10
See this for complete run. Thanks to Utkarsh Trivedi for suggesting this solution.
Method 2 (Iterative)
1 2 3 4 5 6 7 8 9 10
See this for complete run. Thanks to Rahul Huria for suggesting this solution.
How do these solutions work?
main() function can receive arguments. The first argument is argument count whose value is 1 if no argument is passed to it. The first argument is always program name.
num = 1 argv = <file_name>
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to print a semicolon(;) without using semicolon in C/C++?
- Write a C program to print "Geeks for Geeks" without using a semicolon
- Print Hello World without semicolon in C/C++
- Role of SemiColon in various Programming Languages
- C program to print a string without any quote (singe or double) in the program
- How will you print numbers from 1 to 100 without using loop?
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure?
- C program to print characters without using format specifiers
- Print "Even" or "Odd" without using conditional statement
- Print substring of a given string without using any string function and loop in C
- Print individual digits as words without using if or switch
- Print "Hello World" in C/C++ without using any header file
- How to print a number 100 times without using loop and recursion in C?
- Print a number 100 times without using loop, recursion and macro expansion in C?
- To find sum of two numbers without using any operator
- C program to copy string without using strcpy() function
- Print 1 to 100 in C++, without loop and recursion
- How to print range of basic data types without any library function and constant in C?
- Print 2D matrix in different lines and without curly braces in C/C++?
Improved By : maveriek