SAP
Company
Programming
Program
Write a code for checking if atheentered series is in ap or gp and generate next number of the series??
Read Solution (Total 2)
-
- #include
#include
int main()
{
float a, r, i, last_term, sum = 0;
int n;
printf("Enter the first term of the G.P. series: ");
scanf("%f", &a);
printf("Enter the total numbers in the G.P. series: ");
scanf("%d", &n);
printf("Enter the common ratio of G.P. series: ");
scanf("%f", &r);
sum = (a *(1 - pow(r, n + 1))) / (1 - r);
last_term = a * pow(r, n - 1);
printf("last_term term of G.P.: %f", last_term);
printf("n Sum of the G.P.: %f", sum);
return 0;
} - 7 years agoHelpfull: Yes(0) No(0)
- #include
#include
using namespace std;
void checkSeries(int arr[],int n)
{
sort(arr,arr+n);
int flag=1;
if(flag==1){
int d=arr[1]-arr[0];
for(int i=2;i - 6 years agoHelpfull: Yes(0) No(0)
SAP Other Question