• Register

Recent questions tagged integer

0 votes
1 answer 10 views
Problem: Hi there! I am trying to convert an integer number to a byte array using following snippet: static void Main(string[] args) { int i = 44; byte[] b = Convert.ToByte(i); //Error foreach (byte byt in b) Console.WriteLine(byt); Console.ReadKey(); ... says “Cannot implicitly convert byte to byte[]”. Does anybody have any idea why this error is occuring and how can I resolve it?
asked Nov 18 Sheeza 3.6k points
0 votes
1 answer 3 views
Problem: Hi programmers! I am trying to store the index of the elements in an enumeration in an integer variable but I am facing some issue that says “cannot implicitly convert types”. My question is that how can I achieve what I am trying to do?? If someone could explain in easy words, that would be appreciable. Thanks.
asked Nov 17 Sheeza 3.6k points
0 votes
1 answer 12 views
Problem: Hi there! I got an assignment in which I have to generate a game that works like ludo. This would be a two-player game. My program will generate a random number between 1 and 6 whenever a player presses Enter key and adds all the numbers of a user unless the ... excedes 100. I do not know how to generate random numbers between 1 and 6. I would be glad if someone could help me. Thanks!
asked Nov 10 Sheeza 3.6k points
0 votes
1 answer 7 views
Problem: I was able to fill a first array with the integers and display it, but I can't make a second array with the odd numbers found in the first array. using namespace std; #include <iostream> #include <cstdlib> Function to load the first array: void load (int vec [10]) { int i; for (i = 0; i <= 10; ... [cont] = vec [i]; cont ++; } } for (i = 0; i <tam; i ++) { cout << vec2 [i]; } return 0; }
asked Nov 8 sasha 2.2k points
0 votes
1 answer 10 views
Problem: Hello programmers! I have an enumeration of numbers and I want to convert the type of an integer number to my enumeration. How can I do that?
asked Nov 2 Sheeza 3.6k points
0 votes
1 answer 10 views
Problem: Hi there! I am trying to run the following code on visual studio but the compiler is showing error on a line saying that it Cannot implicitly convert type &lsquo;float&rsquo; to &lsquo;int&rsquo;. using System; using System.Collections.Generic; using System.Diagnostics; ... I have no idea about the issue. I am trying to store a floating point number in an integer variable. Please guide.
asked Nov 2 Sheeza 3.6k points
0 votes
1 answer 14 views
I got a list of numbers in the range 0-1023. I want to convert them to integers such that 1023 maps to -1, 1022 maps to -2 etc.. while 0, 1, 2, ....511 remain unchanged. I came up with this: def convert(x): return (x - 2**9) % 2**10 - 2**9 is there a more better way?
asked Oct 29 psandprop 2.4k points
0 votes
1 answer 9 views
0 votes
1 answer 10 views
0 votes
1 answer 8 views
0 votes
1 answer 6 views
0 votes
1 answer 33 views
0 votes
1 answer 9 views
Task: Read an integer N . For all non-negative integers i<N , print i2. if __name__ == '__main__': n = int(input()) if (n<=0) and (n>=20): print("Exit") else: for(i=0,i<=n,i++): print(i*i) I am getting below error File "solution.py", line 6 for(i=0,i<=n,i++): ^ SyntaxError: invalid syntax Exit Status 255
asked Oct 25 psandprop 2.4k points
0 votes
1 answer 14 views
Problem: I want to convert numbers from decimal to binary in C#. The number to be converted is taken input from user and I want my program to convert it to binary. Is it possible to do so?
asked Oct 24 Sheeza 3.6k points
0 votes
1 answer 18 views
0 votes
1 answer 8 views
Problem: I want to convert a character to integer in C#. I have tried Convert.ToInt32(), int32.Parse(), (int)char, but nothing works as desired. I do not want to convert my character into string first. I want to convert my character directly into integer. How I can do that? Is there any mechanism for doing so?
asked Oct 22 Sheeza 3.6k points
0 votes
1 answer 6 views
Problem: I want to round off a number based on the number after decimal point. For example, if a number is 3.4, it should be rounded off to 3 and if a number is 3.6, it should be rounded off to 4. What should I do in order to do so?? I tried typecasting but it did not work as desired.
asked Oct 21 Sheeza 3.6k points
0 votes
1 answer 7 views
Problem: I want to convert a hexadecimal string such as s=0x33 to integer. Is there any mechanism to do that? If yes, please give an example. Thanks
asked Oct 18 Sheeza 3.6k points
0 votes
1 answer 33 views
Problem: Is there any way to convert integer value to bool value? How can I assign true or false to a bool variable based on user input?
asked Oct 18 Sheeza 3.6k points