I am playing with Java and want to do a simple while loop that keeps going until the users does a <ctrl> z.
I have something like this
public static void main(String[] args) {
//declare vars
boolean isEvenResult;
int num;
//create objects
Scanner input = new Scanner(System.in);
EvenTester app = new EvenTester(...
I read this question and its answer in a book. But I didn't understand the book's justification.
Have a look:
Question:
Will the following code compile?
int main()
{
char str[5] = "fast enough";
return 0;
}
And the answer was:
Yes.The compiler never detects the
error if bounds of an array are
exceeded.
I cou...
Hello,
How do u push Items to the front of the array, ( like a stack ) without starting at MAXSIZE-1? I've been trying to use the modulus operator to do so..
bool quack::pushFront(const int nPushFront)
{
if ( count == maxSize ) // indicates a full array
{
return false;
}
else if ( count == 0 )
{
...
.section .data
msgI:
.ascii "x = y\n"
msgI_end:
msgM:
.ascii "x > y\n"
msgM_end:
msgL:
.ascii "x < y\n"
msgL_end:
.section .text
.globl main
main:
movl $5, %eax #x = 5
movl $5, %ebx #y = 10
cmp %ebx, %eax
je IGUAL
jg MAYOR
jl MENOR
IGUAL: #Esta seccion de cogido se ...
C function to rotate a string by a given number to the right or to the left. When a character is rotated past the end or the beginning of a string depending on the direction, it should wrap around
...
Hi
I have to pass the address of a member fn taking one argument to the std::for_each. how do i do this?
class A{
void load()
{
vector<int> vt(10,20);
std::for_each(vt.begin(), vt.end(), &A::print);
//It didnt work when i tried mem_fun1(&A::print)
}
void print(int a)
{
cout<<a;
}
};
Thanks
...
Strange programming problems as of now..As you can see below i have assigned intFrontPtr to point to the first cell in the array. And intBackPtr to point to the last cell in the array...:
bool quack::popFront( int &popFront )
{
//items[count-1].n = { 9,4,3,2,1,0 };
nPopFront = items[0].n;
if ( count >= maxSize ) return fa...
Write a program that shows a frame with three buttons labeled "Red", "Green", "Blue" and a
label containing an icon showing a circle that is initially Red. As the user clicks the buttons, the fill color of the circle should change. When you change the color, you need to invoke the repaint method on the label. the call to repaint ensures...
What is the difference between a character array and string?
...
I'm working on my compiler homework and I have the following question:
Consider the following grammar:
lexp -> number : (op lexp-seq)
op -> + | - | *
lexp-seq -> lexp-seq lexp | lexp
This grammar can be thought of as representing simple integer arithmetic expressions in LISP=like prefix form. For example the expression 34-3*4...
Here is what I understand so far:
PASS BY VALUE
Passing by value means a copy of an argument is passed.
Changes to that copy do not change the original.
PASS BY REFERENCE
Passing by reference means a reference to the original is passed.
changes to the reference affect the original.
REF Keyword
REF tells the compiler that the objec...
#include<stdio.h>
int main() {
int a = 1;
switch (a) {
int b = 20;
case 1:
{
printf("b is %d\n", b);
break;
}
default:
{
printf("b is %d\n", b);
break;
}
}
return 0;
}
...
I'm developing a program for class that reads a matrix and then prints it with an identity matrix. Then step by step I have to reduce it into its identity matrix while applying the same calculations onto the identity matrix and therefore getting the inverse of that matrix.
I'm stuck at the row reducing section of the code. I'm trying t...
First yes, this is a homework project for my Perl class. I am not looking for the answer (although that would be sweet). As I understand it I need to use a BFS and a regular expression to organize my data for use. I need some direction on this one. How do I use a BFS? Do I use a massive stack and go through each item in the stack? ...
If we get the sound from microphone with two channels, to calculate the frequency spectrum we:
calculate the fast fourier transform of all the data input?
calculate the fast fourier transform of each left and right channel and then make a average of both?
calculate the fast fourier transform of each left and right channel and get the b...
I'm writing a program with java that uses bitwise operations to: (1) generate and display all power-of-two numbers in the range +128 to -128, and (2) display an arbitray user-input integer. Have to provide two methods- main and display.main method should declare int number = 128, include a while loop that loops while number is >= -128, c...
Hi,
I have the following class :
public abstract class Step {
public abstract <S,T> S makeAStep(S currentResult, T element);
}
and I'm trying to Implement it so it will take two int's and return the sum of them , something like this :
public class sumOfInts extends Step {
public <Integer,Integer> Integer makeAStep(Integer cu...
If I have an array and I need to display how many times the number '12' is created. I'm using a function to go about this. What resources should I look into to find how to exactly tease out this one number and display how many times it is in the array/list? Any help would be greatly appreciated.
...
I have a program that is supposed to read in values from user into a vector. My function is then supposed to keep a running sum and start from element 1 and compare element 2 to the sum(this point it is just element 1). Move to the next element, add element 2 to the sum and see if element 3 is greater than the sum of elements 1 and 2. ...
import java.util.Scanner;
public class SW {
/**
* @param args
*/
public static void main(String[] args) {
int length;
int width;
int number;
int perimeter;
int area;
Scanner input = new Scanner( System.in );
System.out.println("1. Dimensions of the rectangle");
System.out.println("2. Perimeter of the rectangle");
System.out...