Expected 'While' before function call error



```
#include <string>
#include <vector>
#include <iomanip>
#include <istream>
#include <fstream>
#include "...\myUtils.cpp"
void inputCases(string[], vector<double>);
void inputPrice(string[], vector<double>);
void displayReport(string[], vector<double>, vector<double>);
using namespace std;

int main()
{
    double tmpCases, tmpPayRate;
               
    vector <double> cases;
    vector <double> payRates;
    
    ofstream file;
    file.open("salsaCase.txt");
           
    string tmpName[5];
    tmpName[0]="Mild";
    tmpName[1]="Medium";
    tmpName[2]="Sweet";
    tmpName[3]="Hot";
    tmpName[4]="Zesty";   
    char mans=0; 
   
     do
     {//menu
      cout<<"1. Input Price\n";
      cout<<"2. Input Cases Sold\n";
      cout<<"3. Display Report\n";
      cout<<"4. Quit\n";
      
      cin>>mans;
      while (mans <1 || mans > 4)
      {
            cout <<"Please enter a valid menu choice(1-4)\n";
            cin>>mans;
            }
      if (mans !=4)
      {//guts of menu
      switch (mans)
      {
             case 1:
                  void inputPrice(string tmpName[], vector<double> payRates);
                  break;
             case 2:
                  void inputCases(string tmpName[], vector<double> cases);
                  break;
             case 3:
                  void displayReport(string tmpName[], vector<double> payRates, vector<double> cases);
                  break;
         }
         if (mans == 4)
         exit(0);
         }
         }

         //function definitions
         //input price per case
         //ERROR happens right below here
          void inputPrice (string tmpName[] ,vector<double> payRates)
         {
              for(int i=0;i<5;i++)
              {
              cout<<"Enter price for one case of "<< tmpName[i] <<": ";
              cin >> tmpPayRate;
              payRates.push_back(tmpPayRate);
              cin.ignore();
             pause();
              }
         }
  //input number of cases
              void inputCases(string tmpName[] ,vector<double> cases)
              {
               for(int i=0;i<5;i++)
              {
             cout << "Enter # of cases of "<< tmpName[i] <<" salsa : ";
             cin >> tmpCases;
             cases.push_back(tmpCases);
             cin.ignore();
             pause();
             } 
             }//show sales   
            int displayReport(string tmpName[], vector<double> payRates, vector<double> cases)
             {
             cout<< setprecision(2)<<fixed<<showpoint;
             file<< setprecision(2)<<fixed<<showpoint;   
     
    cout<<setw(20) << left << "  Names"
        <<setw(10) << right<< "Hours"
        <<setw(10) << "Price"
        <<setw(15) <<"GrossPay\n";
        
    file<<setw(20) << left << "  Name"
        <<setw(10) << right<< "Hours"
        <<setw(10) << "Price"
        <<setw(15) <<"GrossPay\n";
        
    for(int i=0;i<cases.size();i++)
    {   
        //loop for generating salsa case lists
            double grossPay =cases[i]*payRates[i];
            cout<<setw(20) << left << tmpName[i]
        <<setw(10) << right << cases[i]
        <<setw(10) << payRates[i]
        <<setw(15) << grossPay <<"\n";
        
            file<<setw(20) << left << tmpName[i]
        <<setw(10) << right << cases[i]
        <<setw(10) << payRates[i]
        <<setw(15) << grossPay <<"\n";
        file.flush();
        pause();
    }
    }
    
    
    
    file.close();
    pause("\n\n\nPress a key to terminate...");
    exit(0);
    
   
}
```

using DevC++ only because my teacher says so  

following is compiler error codes



```
E:\COP2\classNotes\1stdraft.cpp: In function `int main()':
E:\COP2\classNotes\1stdraft.cpp:66: error: expected `while' before "inputPrice"
E:\COP2\classNotes\1stdraft.cpp:66: error: expected `(' before "inputPrice"
E:\COP2\classNotes\1stdraft.cpp:66: error: expected primary-expression before "tmpName"
E:\COP2\classNotes\1stdraft.cpp:66: error: expected primary-expression before "payRates"
E:\COP2\classNotes\1stdraft.cpp:67: error: expected `)' before '{' token
E:\COP2\classNotes\1stdraft.cpp:67: error: expected `;' before '{' token

E:\COP2\classNotes\1stdraft.cpp:79: error: a function-definition is not allowed here before '{' token
E:\COP2\classNotes\1stdraft.cpp:79: error: expected `,' or `;' before '{' token
E:\COP2\classNotes\1stdraft.cpp:90: error: a function-definition is not allowed here before '{' token
E:\COP2\classNotes\1stdraft.cpp:90: error: expected `,' or `;' before '{' token

Execution terminated
```
> You might have missed a bracket somewhere... Only such a mistake causes so many insignificant errors.
> 
> 


And to find it, [format your code](http://www.gidnetwork.com/b-38.html) properly. It's your first debugging tool.
May be the function is executed before the document is ready.
Try to use document.ready function like this:



```
$( document ).ready(function() {
    $('#machines').change(function() {
        var $selected = $(this).find(':selected');
        $('#description').html($selected.data('description'));
    }).trigger('change');
});

``` the compiler will throw the following errors:  


10: error: increment of read-only variable **k**,  


12: error: **lvalue** required as increment operand. Hi,  

  

check the following Code  

SQLCopy Code

```
-- Question 1 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E

-- Question 1&2 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites',
CASE WHEN (E.TotalTime/60)>=6 THEN E.TotalTime - (30* ROUND((E.TotalTime/60*6),1))
     ELSE (E.TotalTime/60) END 'TotalWorkHours'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E
```
  

  

For ur Question 2, I am not getting. give some more details about that. if possible send some sample data. if access over lap like (From date is 2013 -04-05 11:55:00PM to 2013-04-05 19:10:00PM)  

then we can't able to fine the time difference. So check the code for Question No 1 and give the feedback.  

  

Regards,  

GVPrabu In C ++ 11, the code is well defined, but may not do what you expect. Exact Effects: 21.4.5 / 2:



>  Returns: `*(begin() + pos)`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> if `pos < size()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> , otherwise a reference to an object of type `T`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> with a value `charT()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> ; the reference value should not be changed.
> 
> 
> 



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

So, if the string is not empty, it returns a reference to the beginning of the internal buffer. If empty, it returns a reference `char`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

with a value `0`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

whose location is implementation information. Something like the following code should do the trick, provided you complete it (just plan 'A' is covered') and make it robust.  

  


```
#include<stdio.h>

int get\_description(const char type\_plan[], const char ** description, const char ** claim\_limit )
{
  int result = 0; // 0 is 'success' , non-zero is 'failure' 

  switch (type\_plan[0])
  {
  case 'A':
    *description = "Room Charges 150/day\nIntensive Care Unit (ICU) Charges 300/day\nHospital Supplies and Services : As charged. Subject to approval by EZMediLife. Surgical Fees\n";
    switch(type\_plan[1])
    {
    case '1':
      *claim\_limit = "Annual Claim Limit 100.000\n";
      break;

    case '2':
      *claim\_limit = "Lifetime Claim Limit 500000\n";
      break;

    default:
      result = -1;
      break;
    }

    break;
  case 'B':
    //...

  case 'C':
    //...

  default:
    result = -1;
    break;
  }

 return result;

}


int main()
{
  const char * plane[]  = { "A1", "K3", "A2" }; -- test planes

  for ( size\_t n=0; n<sizeof(plane) / sizeof(plane[0]); ++n)
  {
    const char * description, * claim\_limit;
    if ( get\_description( plane[n], &description, &claim\_limit) == 0)
    {
      printf("plane %s: %s%s", plane[n], claim\_limit, description);
    }
    else
    {
      printf("unknown plane %s\n", plane[n]);
    }
    printf("\n");
  }
  return 0;
}
``` not sure i understood. are you having problems with this code?

if yes, i think you’re using the wrong comparison operator (not = but ==). You are mixing [expressions](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.expression?view=netframework-4.7.1) with [lambda expressions](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.lambdaexpression?view=netframework-4.7.1). There are many posts showing how you can combine lambda expressions, but the essential part is to compose expressions from lambda expression [bodies](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.lambdaexpression.body?view=netframework-4.7.1) and rebind the [parameters](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.lambdaexpression.parameters?view=netframework-4.7.1).


The later is usually achieved by a custom [`ExpressionVisitor`](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.expressionvisitor?view=netframework-4.7.1) like this:



```
using System.Linq.Expressions;

public static class ExpressionExtensions
{
    public static Expression ReplaceParameter(this Expression expression, ParameterExpression source, Expression target)
    {
        return new ParameterReplacer { Source = source, Target = target }.Visit(expression);
    }

    class ParameterReplacer : ExpressionVisitor
    {
        public ParameterExpression Source;
        public Expression Target;
        protected override Expression VisitParameter(ParameterExpression node)
        {
            return node == Source ? Target : base.VisitParameter(node);
        }
    }
}

```

Now regarding the EF Core combined query filters. 


Using dictionaries and expression lists seems overcomplicated for what are you doing. Since [`IMutableEntityType`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.metadata.imutableentitytype?view=efcore-2.1) provides read/write access to the [`QueryFilter`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.metadata.imutableentitytype.queryfilter?view=efcore-2.1#Microsoft_EntityFrameworkCore_Metadata_IMutableEntityType_QueryFilter), the same can be achieved with a small set of a custom extension methods.


All they go inside a class like this:



```
using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

public static class QueryFilterExtensions
{
}

```

First method:



```
public static void AddQueryFilter(this IMutableEntityType target, LambdaExpression filter)
{
    if (target.QueryFilter == null)
        target.QueryFilter = filter;
    else
    {
        var parameter = target.QueryFilter.Parameters[0];
        var left = target.QueryFilter.Body;
        var right = filter.Body.ReplaceParameter(filter.Parameters[0], parameter);
        var body = Expression.AndAlso(left, right);
        target.QueryFilter = Expression.Lambda(body, parameter);
    }
}

```

This is a non generic method which combines the exiting filter with passed filter using `AndAlso` (C# `&&`) operator and shows the aforementioned lambda expression combining principles.


However it's not so useful directly, like inside your entity type configuration loop (it can, but requires you to build manually the lambda expression instead of letting C# compiler do that). So here comes the second method:



```
public static void AddQueryFilter<T>(this IMutableEntityType target, Expression<Func<T, bool>> filter)
{
    LambdaExpression targetFilter = filter;
    if (target.ClrType != typeof(T))
    {
        var parameter = Expression.Parameter(target.ClrType, "e");
        var body = filter.Body.ReplaceParameter(filter.Parameters[0], parameter);
        targetFilter = Expression.Lambda(body, parameter);
    }
    target.AddQueryFilter(targetFilter);
}

```

It's a generic method - not quite type-safe, but allows you to use a compile time lambda expression and bind it to the actual entity type as follows:



```
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
    if (typeof(IDeleted).IsAssignableFrom(entityType.ClrType))
        entityType.AddQueryFilter<IDeleted>(e => e.DateTimeDeleted == null);
}

```

Looks better, isn't it :)


The last custom extension method is complement to (replacement of) the standard EF Core generic [`HasQueryFilter`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.metadata.builders.entitytypebuilder-1.hasqueryfilter?view=efcore-2.1#Microsoft_EntityFrameworkCore_Metadata_Builders_EntityTypeBuilder_1_HasQueryFilter_System_Linq_Expressions_Expression_System_Func__0_System_Boolean___) method:



```
public static EntityTypeBuilder<TEntity> AddQueryFilter<TEntity>(this EntityTypeBuilder<TEntity> target, Expression<Func<TEntity, bool>> filter)
    where TEntity : class
{
    target.Metadata.AddQueryFilter(filter);
    return target;
}

```

and allows you to replace



```
this.AddToDict<DbMyEntity>(t => t.Name == null || t.Name == "Something");

```

with the more convenient



```
modelBuilder.Entity<DbMyEntity>()
    .AddQueryFilter(t => t.Name == null || t.Name == "Something");

```

**Update (EF Core 3.0):** `QueryFilter` property has been replaced with `GetQueryFilter` and `SetQueryFilter` extension methods. c = input()  

t = len(c)  

temp = ""  

for i in range(0,len(c)):  

    if t<3:  

        break  

    else:  

        if i in (0,1,t-2,t-1):  

            temp = temp+c[i]  

        else:  

            continue  

print(temp) Check if any of the values in the cells are null.  

If they are you need to modify your code to check for null conditions before using `ToString()`. What is Delayed Branching ?
  

One way to maximize the use of the pipeline, is to find an instruction that can be safely exeucted whether the branch is taken or not, and execute that instruction. So, when a branch instruction is encountered, the hardware puts the instruction following the branch into the pipe and begins executing it, just as in predict-not-taken. However, unlike in predict-not-taken, we do not need to worry about whether the branch is taken or not, we do not need to clear the pipe because no matter whether the branch is taken or not, we know the instruction is safe to execute.
  

More Read : <https://www.cs.umd.edu/class/fall2001/cmsc411/projects/branches/delay.html>
  

Moving $I\_1$ after branch


* $I1$ is updating the value of  $R2$
* $R2$ which is used to determine branch condition $R1$
* Value of $R2$ is available after branch
  

$\Rightarrow$ `Cannot be moved`


Moving $I\_3$ after branch


* value of $R1$ is computed in this instruction
* $R1$ is the branch condition
  

$\Rightarrow$ `Cannot be moved`


Moving $I\_4$ after branch


* $I4$ is simple store instruction used to store R1 in memory
* program execution will have no effect if this is placed after conditional branch
  

$\Rightarrow$ `Can be moved`


Moving $I\_2$ after branch


* It update the memory location to place the storing of conditional branch instruction $R1$
* If moved after branch , when compiler reaches $I4$ program execution will stop
  

$\Rightarrow $ `Cannot be moved`


Hence, **option D is answer.**