C Program To Print 1+4+9+16 Series, using For Loop

preview_player
Показать описание

Lets write C program to print/display number series 1 + 4 + 9 + 16 + 25 + using for loop.

For Loop Logic
We initialize count to 1, as the number series starts from 1. We iterate for loop until count is less than or equal to user entered limit. For each iteration of the for loop we increment the value of count by 1.

Inside for loop we square the value of count and print the result, for each iteration of for loop.

Example:
We ask the user to enter a number. If user enters limit = 5, then we display the first 5 numbers in the series i.e., 1 + 4 + 9 + 16 + 25 +

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

Write a c program to display the series as given bellow: 1, 2, 5, 10, 17………….up to nth terms. Can you please explain how to do this.

sandalkaur
Автор

why you u %d+ in the 2nd statement
it + is neccessary

aaryanchaudhary