+ 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 ; }
5 Respuestas
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 ;
}
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 ;
}
0
Send the answer for above question
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.
- 1
Write a program to generate the first n terms in the series 1,4,9,16,25