[Solved] Execute query using C# [closed]

SqlCommand has ExecuteReader, for executing the command and returning a dataset, ExecuteScalar for returning a single value of a primitive type (int, string, etc.), or executeNonQuery for returning nothing. You can also pass a command to a SqlDataAdapter, and use that to populate a DataTable object. Please google SqlCommand and you will find LOTS of … Read more

[Solved] Why is this for loop infinite?

if(r+1 != 9 && c+1 != 9 && realmap[r+1][c=1] ==10 I have no clue what any part of your code actually does or checks, but this will reset c to 1 every pass that the first two conditions are satisfied and thus cause an infinite loop. 0 solved Why is this for loop infinite?

[Solved] C# error in dividing two integers [closed]

When dividing integers the result will be an integer. This means that you are expecting a value such as 0.75 (which you appear to be thinking you’ll multiply by 100 to get a percentage) then the integer value returned will be only the 0 which is the leading integer. The remainder would be available with … Read more

[Solved] Different output from macros and function definition [duplicate]

In the macro #define prod(a,b) ((a>b)?a*a:b*b) a and b are referenced more than once. So prod(p1++,q1++) becomes (p1++ > q1++) ? p1++*p1++ : q1++*q2++ Note that this is very different than calling the function prod1(p1++, q1++) which only increments p1 and q1 once. And does so predictably. 2 solved Different output from macros and function … Read more

[Solved] function declaration in pro*C without body [closed]

This snippet is in the archaic K&R C syntax which predates ANSI C. Then it is indented strangely which makes it look at first glance like you describe, but it really isn’t. calc_options is the function definition with three arguments, the 3rd of which is a pointer options to typedef option_info. This is the same … Read more

[Solved] conversion from milliseconds to hours in C [closed]

Just assuming there are two variables A & B. long long B; // B is the required milliseconds printf(“Enter the required ms: “); scanf(“%lli”, &B); double A = (double) B / 3600000; // to hours printf(“%lf\n”, A); Disclaimer: Your program has no such declaration which is written in your question. But for sake of simplicity, … Read more

[Solved] c# round to two decimal places [closed]

Please add excepted result and the purpose on your question. Check this: List<decimal> abc = new List<decimal> { 500, 500 }; List<decimal> abcd = new List<decimal> { 12, 100 }; var cd = string.Join(“,”, abc.Zip(abcd, (q1, q2) => Math.Round(q2 / q1 * 100.00M, 2))); solved c# round to two decimal places [closed]

[Solved] C++ beginner got 42 [closed]

The function bool lessThanOrEqualToZero(int);, as defined, makes your program have undefined behavior since not all paths in the function leads to the function returning a bool that you declared that it should return. Specifically: If num > 0 is true the function doesn’t return a value. When a program has undefined behavior, you can’t trust … Read more

[Solved] C – Is there a way to leave a variable unchanged outside of the loop?

You may be looking for the declaration of additional blocks as in #include<stdio.h> int main() { int i=1; printf(“before %d\n”,i); { int i=0; printf(“within %d\n”,i); } printf(“after %d\n”,i); return(0); } which when executed yields before 1 within 0 after 1 From the comment I grasp that a function invocation may be preferable which may be … Read more

[Solved] Accessing struct through method

data has a class type.toBit is a member function of that class, and returns an object of a type that has a member, b3. It would be something along these lines: struct Something { some_type b3; }; struct Data { Something toBit(); }; Data data; some_type x = data.toBit().b3; It’s impossible to guess anything more … Read more

[Solved] How to fix missing semicolon error automatically visual studio c# [closed]

I would do this: Open up Replace in file. Select “Use Regular Expressions”. Enter “.$” in Search term (no quotes). Enter “;” in Replace term (no quotes). Now do replace single or replace all. Replace all will add too many semicolons (blank lines and comments and all other), but will probably give less than 1800 … Read more