+ 4

Write a function to display this series (1,4,9,16,25,…) and so on, where number of terms is given by the user.

in C program #include<stdio.h> int square(int); int main() { int i; for(i=1;i<10;i++){ if(i%2==0){ printf("%d %d ",i*i,square(i)); } } } int square(int i) { return ; }

12th May 2018, 10:57 AM
Jordan
Jordan  - avatar
5 Réponses
0
Here you go. #include<stdio.h> int square(int); int main() { int i; int n; printf ("Enter the number:"); scanf ("%d",&n); for(i=1;i<n;i++) { if(i%2==0) { printf("%d ",square(i)); } } } int square(int i) { return i*i ; }
30th May 2018, 8:29 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
if you want series of numbers which provided by user then here you go. #include<stdio.h> int square(int); int main() { int i=0; int n; printf ("Enter the number:"); scanf ("%d",&n); while(n) { if(i%2==0) { printf("%d ",square(i)); n--; } i++; } } int square(int i) { return i*i ; }
30th May 2018, 8:31 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
Send the answer for above question
29th Jun 2019, 5:48 AM
lahari murari
0
if you want series of numbers which provided by user then here you go. #include<stdio.h> int square(int); int main() { int i=0; int n; printf ("Enter the number:"); scanf ("%d",&n); while(n) { { printf("%d ",square(i)); n--; } i++; } } int square(int i) { return i*i ; } //Correct code...the above codes will print only squares of even numbers.
9th Jan 2020, 6:14 PM
Nisarg Doshi
Nisarg Doshi - avatar
- 1
Write a program to generate the first n terms in the series 1,4,9,16,25
29th Jun 2019, 5:47 AM
lahari murari