I am trying to generate a program using the builtin Random and generate an algorithm that determines whether the number is odd or even. I need to write a program that generates 100 random numbers, determine if its even or odd and finally count the number of even and odd. I am new to Python. This is what I have thus far, but nothin is working. Could someone give me a push in the right direction?? Thank you so much. import random def main(): # explain program intro() # get a random number number = random.randint(1,100) # generate Boonlean variables …

Member Avatar
Member Avatar
+0 forum 8

this is my code, when even i run it it tells me that the number is even while it is odd. #include<stdio.h> #include<stdlib.h> int main(void) { int value; /* To read a number and say wheither it is even or odd*/ printf("Please enter any number \n"); scanf("%u", &value); if (value/2 != 0) printf("the number is Even \n"); else printf("the number is Odd \n "); printf("The value is %u \n",value*10); return 0; } please help me out in getting the code to work in the right way that i want it to.

Member Avatar
Member Avatar
+0 forum 1

What are the repercussions of having an odd number of RAM modules. E.g. 3 x 4GB I know it will work but I want to know exactly what damage it can do/problems it can create. Cheers EDIT: And also, why is it better to have more RAM modules (e.g 2x4GB < 4x2GB)

Member Avatar
Member Avatar
+0 forum 5

Upon playing with the graphics/random class - I have discovered something odd. Private Sub Me_Load(sender As Object, e As EventArgs) Handles Me.Load For i = 0 To 5000 DrawColor(GimmiRectangle) Next End Sub Private Sub DrawColor(ByVal rNew As Rectangle) Try Dim g As Graphics = Me.CreateGraphics g.DrawRectangle(New Pen(Color.FromArgb(New Random().Next(255), New Random().Next(255), New Random().Next(255))), rNew) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Function GimmiRectangle() As Rectangle Try Dim rect As New Rectangle(New Random().Next(1000), New Random().Next(1000), New Random().Next(1000), New Random().Next(1000)) Return rect Catch ex As Exception MsgBox(ex.ToString) Return New Rectangle(0, 0, 0, 0) End Try End Function This code will …

Member Avatar
Member Avatar
+0 forum 2

I used `memcpy` to copy the contents of one pointer to another pointer assigned to new memory. Later in the program I get runtime errors as if I were attempting to operate on a pointer pointing to nothing. While debugging, I saw that the original and the the copied pointer had different addresses but they acted as if they were one, for example If I set a property of the copied pointer to 'a' the original would also get set to 'a'. In this case I delete the copied pointer and the original gets deleted too as if they pointed …

Member Avatar
Member Avatar
+0 forum 4

Im having this weird runtime error whenever I attempt to copy a specific member of an array block. I get this from the output: ASSERT failure in QHash: "Iterating beyond end()", file tools/qhash.cpp, line 293 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. I redid the code so i could specify what seems to be causing the problem. //"Heading" is a QString someClass *pointerFromArrayBlock = &theArray[10]; cout<< pointerFromArrayBlock->Heading() <<endl;//runs fine QString test = pointerFromArrayBlock->Heading();//causes crash someClass *pointer_NOT_FromArray = new someClass(/*some parameters*/); cout<< value_NOT_FromArray->Heading() <<endl;//runs fine QString test2 = value_NOT_FromArray->Heading(); //runs fine

Member Avatar
Member Avatar
+0 forum 8

I have no idea how it will be created plz help me as long experience I have forgotten due to my illness. Write a program to determine if the digits in a three digit number are all odd, all even, or mixed odd and even. Your program should prompt the user to input a three digit number. If the digits in the three number are all odd, write “ the number contains all odd digits”, if the digits are all even, write “the number contains all even digits”, if the number contains both even and add digits then print : …

Member Avatar
Member Avatar
+0 forum 4

How to display odd and even numbers from a queue link list? hello everyone i really need some help right now on this program. what this program is supposed to do is copy 11 22 44 77 33 99 66 into a linked list that behaves like a queue. the program should display the queue, display the odd numbers, display the even numbers. display queue should look like this 11 22 44 77 33 99 66 display odd numbers should look like this 11 77 33 99 display even numbers should look like this 22 44 66 so far i …

Member Avatar
Member Avatar
+0 forum 3

I need to design an application that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard. This is what I have so far. public static void main (String[] args) { int odd=0, even=0, zero=0; Scanner scan = new Scanner(System.in); int num = scan.nextInt(); String numS = Integer.toString(num); int digits = numS.length(); for (int i = 0; i < digits; i++) { if (numS.indexOf(i) == 0) { zero++; } else if (numS.indexOf(i) % 2 == 0) { even++; } else { odd++; } } System.out.println("The number of odd digits are: " …

Member Avatar
Member Avatar
+0 forum 3

Just in the news: A Miami police officer fatally shot a naked man who refused to stop chewing on the face of another naked man — even after being shot once by the officer — on a busy downtown highway ramp. Have you read any other strange news lately?

Member Avatar
Member Avatar
+0 forum 3

Can some one help me with my programming project, it is supposed to loop. If the number is even output comes out even and vise-versa. Can someone please tell me what is wrong with my code. Errors "3 errors found: File: C:\Users\Kaamil\evenodd test.java [line: 1] Error: The public type NumberEvaluator must be defined in its own file File: C:\Users\Kaamil\evenodd test.java [line: 3] Error: Duplicate method evenOdd(int) in type NumberEvaluator File: C:\Users\Kaamil\evenodd test.java [line: 8] Error: Duplicate method evenOdd(int) in type NumberEvaluator" Code. public class NumberEvaluator { public void evenOdd(int num) { } public void evenOdd(int num) { if (num % …

Member Avatar
Member Avatar
+0 forum 17

I have to find factors of 1-10 then count all factors and find if they are odd/even. I know how to find if they are even or odd i just can't count how many factors for each number. #include <iostream.h> #include <stdlib.h> int main() { int num, icntA, icntB, icntC, sub = 0.0; int total = 0.0; cout << "Please enter a positive maxiumum integer value you wish to find divisors: \n"; cin >> num; for(icntA = 1; icntA <= num; icntA++) { for(icntB = 1; icntB <= num; icntB++) { if(icntA % icntB == 0) cout << icntB << …

Member Avatar
Member Avatar
+0 forum 1

I need help with a lab I'm doing. In this lab you have to show the number of odd digits a number has, for example the number 4135 would have three odd digits. I've already done a lab where it tells you if a number is odd or even but I don't know how to change it and make it to do what it needs to. This is my code for the odd or even lab: /** * It reads and number and determines if that number is even or add. */ import java.util.Scanner; public class Odd_or_Even { public static …

Member Avatar
Member Avatar
+0 forum 1

HI, I'm writing a code for the very first time, and I'm completely stuck. Some guidance would be great. I'm writing a C program that reads integars from file "integars.dat". The program should show how many numbers you have entered, how many among them were even, and how many were odd. Also the average of integer numbers that were odd. It should be done using nested loops, ifs whiles fors, as its a beginners program. It does read in the integars from the FILE, and counts them properly , except it doesnt count the odd and even integars. [CODE]#include <stdio.h> …

Member Avatar
Member Avatar
+0 forum 6

heres my C code this was easy: -Chris g [CODE=c]#include <stdlib.h> #include <stdio.h> extern int numodd( int array[], int size ) ; int main( int argc, char * argv[] ) { int numarray[] = { 2, 3, 1025, 3024, 4057, -3, -1025, -3578 } ; int size = sizeof(numarray) / sizeof( int ) ; int result ; result = numodd( numarray, size ) ; printf( "Number of odd numbers: %d\n", result ) ; exit( 0 ) ; }[/CODE] ARM CODE: [CODE].global numodd .text numodd: stmfd sp!, {v1-v6, lr} @load from memory mov v1, #0 mov v1, a2 @store mov v2, …

Member Avatar
Member Avatar
+0 forum 1

Hi i am just new to VB.NET and our teacher told us to experiment on for loop in a ODD SUM Program you need to add all odd numbers from Input One to Input Two like that but i can't stop it from adding continuously for example i input the first number 1 and the second 10 if i click the button one time the output should be 25 but when i click again the button it becomes 50 its wrong i can't terminate the process help me [CODE] Dim oddOne As Integer Dim oddTwo As Integer oddTwo = Val(txtInputTwo.Text) …

Member Avatar
Member Avatar
+0 forum 1

In this program i am trying to find numbers that are multiples of 7,11, or 13, also if the total of the numbers is even or odd also the square root value of each number also if there are any prime numbers in the list [CODE]#include<iostream> #include<iomanip> #include<fstream> #include<cmath> #include<conio.h> // Associating program identifiers with external file names #define in_file "data.txt"//input file name #define out_file "result.txt"//output file name using namespace std; void multiple(int); void even_odd(int); void square_root(double); void prime(int); int temp_a; double temp_c; int total; int num; ifstream ins;// associates ins as an input stream ofstream outs;// associates outs as …

Member Avatar
Member Avatar
+0 forum 5

Hi folks! :) I'm here with a problem of Assembly 8086 (x86) (NASM). I´m trying calculate the sum of all numbers, which are odd, lowers than X (X = number defined by user) Already solved the problem in C # and C + +, but i need the Assembly Code. In C#: [CODE="C#"] int num = 0; int res = 0; int all = 0; int soma = 0; num = Convert.ToInt32(Console.ReadLine()); while (all < num) { all++; res = all % 2; if (res == 1) { soma += all; } else { continue; } } Console.WriteLine(soma);[/CODE] In C++: …

Member Avatar
Member Avatar
+0 forum 1

Hello! I am new user of this forum, and I want to ask you for ideas for finding the probability of winning in pre-flop, post-flop etc... For example, there are 3 players on the table (2 opponents). A (spade) A(heart) (1st opponent's cards) A (club) 8 (club) (your cards) 7 (club) 8 (heart) (2nd opponent's cards) Your percent of winning is: 9.89 4.97 chance of equal splitting the pot I know how to solve the problem with brute-forcing method and Random function but I want to work smart and not hard. I want to program this in Java or C++. …

Member Avatar
Member Avatar
+0 forum 9

The End.