- 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

Given with n numbers program must find those n number whose sum is a perfect square

Input : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)^2

START Step 1 : Declare a Macro for size let’s say of 5 and i to 1 Step 2: loop While till i<=SIZE Step 2.1 -> printing (2*i)-1 Step Step 2.2 -> incrementing i with 1 Step Step3-> End loop While STOP

#include <stdio.h> # define SIZE 5 int main() { int i=1; while(i<=SIZE) { printf("\n %d",((2*i)-1)); i++; } }

If we run the above program then it will generate the following output

1 3 5 7 9

- Related Questions & Answers
- Print numbers with digits 0 and 1 only such that their sum is N in C Program.
- Find maximum N such that the sum of square of first N natural numbers is not more than X in C++
- Find maximum N such that the sum of square of first N natural numbers is not more than X in Python
- Print all the combinations of N elements by changing sign such that their sum is divisible by M in C++
- Maximum sum of distinct numbers such that LCM of these numbers is N in C++
- Print N lines of numbers such that every pair among numbers has a GCD K
- Count numbers upto N which are both perfect square and perfect cube in C++
- Count ordered pairs of positive numbers such that their sum is S and XOR is K in C++
- Sum of square of first n odd numbers
- Print all odd numbers and their sum from 1 to n in PL/SQL
- Sum of square-sums of first n natural numbers
- Find three integers less than or equal to N such that their LCM is maximum - C++
- Check if product of array containing prime numbers is a perfect square in Python
- Count of pairs in an array whose sum is a perfect square in C++
- Place N^2 numbers in matrix such that every row has an equal sum in C++

Advertisements