Skip to content

Instantly share code, notes, and snippets.

@sachendra003
Created January 1, 2018 16:59
Show Gist options
  • Save sachendra003/69cdc458bb061b789adc919d876fbe9d to your computer and use it in GitHub Desktop.
Save sachendra003/69cdc458bb061b789adc919d876fbe9d to your computer and use it in GitHub Desktop.
C Program to Find index of Array
#include <stdio.h>
#include <stdlib.h>
int main()
{
char a[]={'a','b','c','d'};
int i,p,c=0;
char num;
int n=sizeof(a)/sizeof(a[0]);
printf("Enter a character :\n");
scanf("%c",&num);
for(i=0;i<n;i++)
{
if(a[i]==num)
{
p=i;
printf("Element index is %d",p);
c=1;
break;
}
else
{
c=0;
}
if(c==0)
{
//printf("Number is not in Array: \n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment