In this tutorial you will learn about the C Program to Print 1 to 10 Without Using Loop and its application with practical example.
C Program to Print 1 to 10 Without Using Loop
In this tutorial, we will learn to create a C program that will Print 1 to 10 Without Using Loop in C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional statements in c programming.
Print 1 to 10 Without Using Loop
As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values.In c programming language we can do all the work for multiple printing with the help of loops but in today’s tutorial we will complete the program without using the loops.
There are two ways to complete this program.
With the help of this program, we can Print 1 to 10 Without Using Loop.
Algorithm 1:-
1 2 3 4 5 6 7 |
1. Declaring the variables for the program. 2. Printing the numbers with out using the loops. 3. Ending the program. |
Algorithm 2:-
1 2 3 4 5 6 7 8 9 |
1. Declaring the variables for the program. 2. Write the conditions for the program. 3. Printing numbers from user defined functions. 4. Calling user defined function. 5. End program. |
Program 1 to Print 1 to 10 Without Using Loop:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> void main() { //printing manually numbers without using loops by method 1 // printing manually each line printf("1\n"); printf("2\n"); printf("3\n"); printf("4\n"); printf("5\n"); printf("6\n"); printf("7\n"); printf("8\n"); printf("9\n"); printf("10\n"); } |
Program 2 to Print 1 to 10 Without Using Loop:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include<stdio.h> //function to print the data without the loops void printNumber(int value) { //printing manually numbers without using loops by method 2 int i; printf("%d\n", value); i = value + 1; if (i > 10) return; //printing numbers printNumber(i); } void main() { //calling user defined numbers printNumber(1); } |
Output:-
The above program we have printed each line manually by writing the codes.
Output 2:-
The above program we have first initialized the set of variables for the program.
- i = it will hold the integer value.
User defined Function for printing.
Printing the numbers from the function.
Calling the user defined function.