In this tutorial you will learn about the C Print Series upto n Term and its application with practical example.
C Program to Print Series upto n Term.
In this tutorial, we will learn to create a C program that will Print Series up to n Term 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.
- For loop in c programming.
Print Series up to n Term.
As we all know the c programming is a very powerful language. In the c programming language, we have many pre-defined functions for arithmetic operations. But today we will print the series up to the given number using the c programming language.
With C programming we can make many arithmetics series with just a little code.
With the help of this program, we can Print Series up to n Term.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declare the variables for the program. 2. Take the input number from the user. 3. Pass that number to a while loop. 4. Calculate the size of number. 5. Print the size of that number. 6. End the program. |
Program to Print Series up to n Term:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include<stdio.h> int main() { //declaring the variable for the program int No, i; //taking input number from the user for the series printf("Enter the value of No (limit) for the series : "); scanf("%d", &No); printf("\n"); //printing the series upto the given number with the //help of for loop for(i=1; i<=No; i++) { if(i==No) //printing numbers printf("%d", i); else //printing numbers printf("%d,", i); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- i = it will hold the integer value for the loop.
- No = it will hold the integer value of number input.
Display message to Take input number from the user and scan the input number.
Program code to print the list up to the given number.