\n");">
Login
Order Now
Support
C Programming Assignment Solution - Flex and Bison

C Programming Assignment Solution - Flex and Bison

  • 18th Aug, 2022
  • 16:07 PM


#include
#include
int main()
{
      printf("\nplease input data in below format........\n");
      printf("\nCalculate any type true and false boolean calculation in given bellow --------->\n");
      printf("\n1.(TRUE & FALSE) -->Input in --> TRUE FALSE & --->format \n2.(TRUE | FALSE) -->Input in --> TRUE FALSE | --->format\n3.(TRUE !) -->Input in --> TRUE'  --->format\n4.( NOT(TRUE AND FALSE) OR FALSE ) -->Input in --> TRUE FALSE & ' FALSE |--->format \n");
       char str1[50];
       char newString[10][10]; 
       int i,j,ctr;
       printf("---------------------------------------\n");    
       printf(" Please input values  : ");
       fgets(str1, sizeof str1, stdin);    
       j=0; ctr=0;
    for(i=0;i<=(strlen(str1));i++)
    {
        // if space or NULL found, assign NULL into newString[ctr]
        if(str1[i]==' '||str1[i]=='\0')
        {
            newString[ctr][j]='\0';
            ctr++;  //for next word
            j=0;    //for next word, init index to 0
        }
        else
        {
            newString[ctr][j]=str1[i];
            j++;
        }
    }
 char a,b,c,d,e,f;
 int a1,b1,c1,d1,e1,f1;
               
    for(i=0;i     {
       
        for(j=0;j<1;j++)
        {
          if(i==0){
             a=newString[i][j];}
          if(i==1){
             b=newString[i][j];}
          if(i==2){
             c=newString[i][j];}
          if(i==3){
             d=newString[i][j];}
          if(i==3){
             e=newString[i][j];}
          if(i==3){
             f=newString[i][j];}
        }  
    }

 // make integer from character value for condition checks....   
if((a=='t') | (a=='T')){
    a1=1;
 }
 else{
   a1=0;
 }
if((b=='t') | (b=='T')){
   b1=1;
 }
 else{
   b1=0;
 }
 if((c=='t') | (c=='T')){
    c1=1;
 }
 else{
   c1=0;
 }
 if((d=='t') | (d=='T')){
    d1=1;
 }
 else{
   d1=0;
 }
 if((e=='t') | (e=='T')){
    e1=1;
 }
 else{
   e1=0;
 }
 if((f=='t') | (f=='T')){
    f1=1;
 }
 else{
   f1=0;
 }

   // checks the conditions---------
// !(true & false) | true calculation....................   
  if(d=='!') {
    if ( !(a1 & b1) | e1 ){
       printf("Output is-->");
       printf("true");
                }
                else{
                  printf("Output is-->");
                  printf("false");
                  }
              }   
//true | false condition check...........................
  else if(c=='|'){
    if ( a1 | b1 ){
      printf("Output is-->");
       printf("true");
                }
                else{
                  printf("Output is-->");
                  printf("false");
                  }
              }

//  Not ! true or false calculation.......................
  else if( b=='!'){
    if ( !a1 ){
      printf("Output is-->");
       printf("true");
                }
                else{
                  printf("Output is-->");
                  printf("false");
                  }
              }
 //
// (true & false ) condition check........................
  else if(c=='&'){
              if ( a1 & b1 ){
                printf("Output is-->");
                   printf("true");
                }
                else{
                  printf("Output is-->");
                  printf("false");
                  }
              }
  else{
      printf("please enter input in given right format in given choice :....");
     }
    
    return 0;
}
 

Share this post

assignment helpassignment helperassignment expertsassignment writing services