#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long unsigned int t=0,n1,n,count=0,n3,n4,num,n2;
scanf("%lu",&n);
n1=n-1;
while(n1!=-1)
{
num=pow(2,n1);
t=t+num;
n1–;
}
n1=0;
scanf("%lu",&n2);
if(t==n2)
{
while(n1<n)
{
scanf("%lu",&n3);
n4=pow(2,n1);
if(n3!=n4)
{
count=1;
break;
}
n1++;
}
}
else
printf("\n No\n");
if(count==1)
printf("\n No\n");
else
printf("\n Yes\n");
getch();
}
Do not use the header file conio.h
and functions in it. This header is available only in ANSI C/C++ (Turbo C++), not in standard C.
But, that should be giving you a compile time error.
Your main
should return an integer (0
, to be precise, in case of successful completion). Hence change your void main()
to int main()
. That should save you from getting the NZEC (Non-Zero Exit Code) runtime error.
clrscr()
and getch()
are functions from conio.h
. They should be removed together with #include <conio.h>
1 Like