

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How will you print numbers from 1 to 100 without using loop in C?
There are several methods to print numbers without using loops like by using recursive function, goto statement and creating a function outside main() function.
Here is an example to print numbers in C language,
Example
#include<stdio.h> int number(int val) { if(val<=100) { printf("%d\t",val); number(val+1); } } int main() { int val = 1; number(val); return 0; }
Output
12345678910111213 14151617181920212223242526 27282930313233343536373839 40414243444546474849505152 53545556575859606162636465 66676869707172737475767778 79808182838485868788899091 9293949596979899100
In the above example, a function number is created with an argument val. If val is less or equal to 100, print the value and increment value by one. In the main() function, val is initialized with 1 and called function number.
if(val<=100) { printf("%d\t",val); number(val+1); }
- Related Questions & Answers
- Program to print numbers from 1 to 100 without using loop
- Print 1 to 100 in C++, without loop and recursion
- C Program to print numbers from 1 to N without using semicolon
- Print a number 100 times without using loop, recursion and macro expansion in C
- Python program to print all Disarium numbers between 1 to 100
- Python program to print all Happy numbers between 1 and 100
- Print a pattern without using any loop in C++
- How to print all the Armstrong Numbers from 1 to 1000 using C#?
- C program to print number series without using any loop
- C program to print four powers of numbers 1 to 9 using nested for loop
- How to print a name multiple times without loop statement using C language?
- Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
- Java program to print prime numbers below 100
- Printing 1 to 1000 without loop or conditionals in C/C++
- How will you explain Python for-loop to list comprehension?
Advertisements