Write a program in C Program to find the sum of the following :
The input contain a sequence of two or more positive integers terminated by -1. Write a piece of code to count the ‘incidences’ in this sequence (i.e the number of pairs of equal, adjacent numbers). For example, the following sequence contains 4 incidences:
4 2 9 9 3 7 7 7 3 3 -1
i've write and please check for me
main()
{
int a,p,j;
scanf("%d %d %d",&a,&p,&j);
if (a==p)
printf("The number of pairs of equal is equal to 1 \n");
if (p==j)
printf("The number pairs of equal is equal to 1 \n");
else
if (a==p&&p==j)
printf("contain 2 incidences \n");
}
Output :
1
1
9
the number of pairs of equal to 1
Press any key to continue