Adpratical2
Pasted Oct 8, 2026, 3:06 AM5 files183 lines
Scan to open on your phone
Point a camera at the QR code - it opens this exact paste, no app needed.
https://codepastes.com/adpratical2q10a.cC
#include <stdio.h>
int main()
{
char input[100],stack[100];
int top=0,i;
stack[0]='Z';
printf("Enter string of 0's and 1's: ");
scanf("%s",input);
for(i=0;input[i]!='\0';i++)
{
if(input[i]=='0')
{
if(stack[top]=='1') top--;
else stack[++top]='0';
}
else if(input[i]=='1')
{
if(stack[top]=='0') top--;
else stack[++top]='1';
}
else
{
printf("Invalid input!\nAdipt Shah\n");
return 0;
}
}
if(top==0)
{
printf("String Accepted by PDA.\n");
printf("Remaining stack: Z\n");
printf("Final State: qf\n");
printf("Adipt Shah\n");
}
else
{
printf("String Rejected by PDA.\n");
printf("Remaining stack: ");
for(i=0;i<=top;i++) printf("%c ",stack[i]);
printf("\nAdipt Shah\n");
}
return 0;
}3,923 chars · codepastes.com