Following is a C program source code for identifying an AP(arithmetic progression ) series and printing further numbers of series but;
*it doesn't work for fractions like 1.2 , 1.4 , 1.6.......
find out the error
#include<stdio.h>
main()
{
float a,b,c,i,d,e,n;
printf("consecutive numbers of AP\n");
scanf("%f%f%f",&a,&b,&c);
printf("enter number of terms");
scanf("%d",&n);
d=b-a;
if(c-b==b-a)
{
printf("AP series\n");
{
for(i=0;i<n;i++)
printf("%f\n",a+i*d);
}
}
else
printf("not in ap");
}
*it doesn't work for fractions like 1.2 , 1.4 , 1.6.......
find out the error
#include<stdio.h>
main()
{
float a,b,c,i,d,e,n;
printf("consecutive numbers of AP\n");
scanf("%f%f%f",&a,&b,&c);
printf("enter number of terms");
scanf("%d",&n);
d=b-a;
if(c-b==b-a)
{
printf("AP series\n");
{
for(i=0;i<n;i++)
printf("%f\n",a+i*d);
}
}
else
printf("not in ap");
}
No comments:
Post a Comment