43. Series I

1)Write a program to generate the first n terms in the series --- 1,4,9,16,25, ....
Image result for c programming
Input Format:

Input consists of a single integer which corresponds to n.

Output Format:

Output consists of the terms in the series separated by a blank space.

Sample Input:
 7
Sample Output:
1 4 9 16 25 36 49

Code:
  #include<stdio.h>
int main()
{
  int n,i;
  scanf("%d",&n);
  for (i=1;i<=n;i++)
  {
  printf("%d ",i*i);
  }
  return 0;
}

No comments