top of page

Element Is Present In Series



#include <stdio.h>

void main() {

int i=0;

int a[100];

int se=0,fe;

int na[5],cd,sn,n;

int count=0;

printf("\nEnter range of series : ");

scanf("%d",&n);

printf("\nEnter first element : ");

scanf("%d",&fe);

printf("\nEnter common difference : ");

scanf("%d",&cd);

for(i=0;i<n;i++)

{

a[i]=fe;

fe=fe+cd;

printf("---%d",a[i]);

}

printf("\nEnter element : ");

scanf("%d",&sn);

for(i=0;i<n;i++)

{

if(sn==a[i])

{

count=count+1;

printf("\n%d is present in series",sn);

}

}

if(count==0)

{

printf("\n%d is not present in series",sn);

}

}

Recent Posts

See All
Stack Using Queue

A stack can be implemented using two queues in C. The basic idea is to use one queue for enqueue operations and another for dequeue...

 
 
 
Queue Using Stack

A queue can be implemented using two stacks in C. The basic idea is to use one stack for enqueue operations and another for dequeue...

 
 
 
Queue Using Array

#include <stdio.h> #include<stdlib.h> #include<math.h> #define size 5 int queue[size]; int front = -1; int rear = -1; void enque(void);...

 
 
 

Comments


bottom of page