This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Wednesday 5 June 2013

Program to find the squares of the first N natural numbers using FOR loop



#include<stdio.h>
void main()
{
int i, n, sqr=0;
clrscr();
printf("Enter the value of n:");
scanf("%d", &n);
printf("Squares of first %d natural numbers = %d", n, sqr);
for(i=1; i<=n; i++)
{
sqr=i*i;
printf("%d\n",sqr);
}
getch();
}

No comments:

Post a Comment