Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

C Programming Language #includestdio.h #include stdlib.h //method to find the precidence number of given char int find_precidence(char c) {...

C Programming Language

#include<stdio.h>

#include <stdlib.h>

//method to find the precidence number of given char

int find_precidence(char c)

{

switch(c)

{

case '!':

return 0;

case '%':

return 1;

case '&':

return 2;

case '^':

return 3;

case '|':

return 4;

}

}

int main()

{

char s[100];//string to read 3 operators

int t;

//reading number of test cases

scanf("%dn",&t);

int i=1;

while(i<=t)

{

//reading 3 operators

int j,k;

scanf("%[^'n']s",s);

//printf("%sn",s);

int a[] = {0,0,0,0,0};

char ac[]= {'!','%','&','^','|'};

printf("Case #%d:",i);

for(j=0;s[j]!='';j++)if(s[j]!=' ')a[find_precidence(s[j])]++;

//printing from highest to lowest

for(j=0;j<5;j++)

{

for(k=0;k<a[j];k++)

printf("%c ",ac[j]);

}

printf("n");

char c;

scanf("%c",&c);

i++;

}

return 0;

}

This is the code, it compiles and runs correctly but my assignment says it is wrong. Are there any mistakes or other methods I should know of?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question