C++ :: Program To Print Out All Booms - Minesweeper Field (recursion)

Apr 4, 2013

I'm required to write a program to print out all booms allowed requests below:

1. User will enter the address of the cell and its value.
2. Print out all booms.

How to solve it by using recursion.

View 4 Replies


ADVERTISEMENT

C++ :: Recursion - How To Print To The Screen Value Of N After It Has Been Multiplied

Mar 20, 2013

How to print to the screen the value of n after it has been multiplied.

For example: if I use cout << "n: " << n << " power: " << power << "
"; I

can see the variable "power" decrementing by 1, but I don't see the variable "n" incrementing with its new value after it has been multiplied by n * n.

#include <iostream>
using namespace std;
typedef unsigned short int USHORT;
typedef unsigned long int ULONG;

ULONG Getpower(USHORT n, USHORT power);

[Code] .....

View 2 Replies View Related

C :: Print Triangle Pattern Using One Loop And Recursion?

Dec 18, 2013

Q.print triangle pattern using one loop and recursion

eg: 5

Code:

#include <stdio.h>#include <conio.h>
void pattern(int n,int N) {
int i,c=1;

[Code]....

View 8 Replies View Related

C# :: Field Initializer Cannot Reference The Non-static Field / Public Var

Apr 12, 2015

So I have this class

class DataBase
{
// Change the connection path here to your own version of the database
public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|UberDatabase.mdf;Integrated Security=True;");
public DataBase()
{
}
}

And in the same namespace as this class I have a form that calls it like so:

DataBase dBase = new DataBase();
SqlCommand trythis = new SqlCommand("Register", dBase.con);

However, I'm getting the field initializer error on dBase.con. I'm not sure why, but when I call the database from another file (program.cs) it works fine this way.

View 8 Replies View Related

C :: How To Continue Minesweeper Game

Oct 24, 2013

I am just now in my first programming class for learning C language and I am stuck on one of my homework assignments. I am not asking you to write the code for me or anything because I want to learn by doing it myself but all I am asking for is some pointers to where I am messing up. My program is already finished for what she asked for but I am trying to do an extra credit where she wants us to have the user decide how big the gameboard is and how many mines to hide in it. Really I know that I need to use srand() and rand() but I am not sure how to use them to randomly place mines and without placing mines on top of others.

Code:

//Program 3 "Minesweeper" by Casey Samuelson
//10-17-2013
//This program will imitate the game Minesweeper.
//Agorithum

[Code]....

View 4 Replies View Related

C++ :: Minesweeper - Function Always Returns The Same

Jun 24, 2013

For a Homework i need to make some kind of Minesweeper but i have one Probleme one of my functions always return teh same and i cannot fin out why here is the code:

bool setzen(int x, int y){
if(feld[x][y]!=3){
return mine=false;
}

[Code]....

Thats the Part where Everything happens but the Function "bool setzen" always returns false and i dont know why.

View 6 Replies View Related

C/C++ :: Factorial Program With Recursion

Nov 9, 2014

I put some checks in factorial program, I am confused how 27, 40 50 is coming in output and ans is 10.

#include<stdio.h>
int fact(int n) {
if(n==1) {
printf("hello1 %d
",n);
return 1;

[code].....

View 2 Replies View Related

C :: Program For Counting Vowels In A String Using Recursion

Jul 31, 2014

program for counting vowels in a string using recursion ?

View 12 Replies View Related

C/C++ :: Program That Complete Binary Number Using Recursion

Mar 12, 2015

So Im trying to make a program that completes a binary number and I have to use Recursion. Heres an example:

1] ./binary_string.out 01x0
0100
0110

2] ./binary_string.out xx
00
01
10
11

Here's what I got so far but Im stuck and I don't know what's wrong/what to do.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* convertString(char *c,int len);
int main(int argc,char *argv[]) {
int i,length;
char *cs;

[Code] ....

View 2 Replies View Related

C++ :: Program That Uses Recursion To Find Longest Increasing Sequence From A Grid In File

Mar 25, 2013

Any examples of a c++ program that uses recursion to find the longest increasing sequence from a grid in a file. Like

2 4 6 8
10 12 14 16
18 20 22 24

I have to use a structure named Point and a structure named Sequence.

const int MAXROWS = 4;
const int MAXCOLS = 4;
const int MAXFILENAME = 255;
// Structure used to define a point (x,y) in the grid.
typedef struct {
int x, y;

[Code] .....

View 1 Replies View Related

C++ ::  can't Get Program To Print Only Available Seats

May 1, 2014

I can't get my program to print only AVAILABLE SEATS; instead it prints Both Available and Taken.

//Program allows you to delete and add seats to the Airplane. Also to upload seat settings as a text file.
#include <iostream>
#include <fstream> //file stream for text file
#include <string>
using namespace std;

[code].....

View 6 Replies View Related

C++ :: A Program To Print Big Letters?

Nov 28, 2013

I need help writing a program where I use small letter to write names in Big letters. (I dont know if you understand what i mean). Follow link to description.

[URL]

View 6 Replies View Related

C++ :: Program To Print Sum Of Even And Odd Numbers

Apr 14, 2013

I am writing a program that prints the sum of even and odd numbers and here is my code

#include <iostream>
using namespace std;
const int SENTINEL = -999;

int main() {
int integers = 0;
int even = 0;
int odd = 0;

[Code] ....

Nut now in the output it adds -999 to the odd numbers ....

View 3 Replies View Related

C :: Program To Print The Length Of A String

Oct 20, 2013

Well what the title says, but I can't get it done. This is what I got

Code:
#include <stdio.h>#include <string.h>
int main(void)
{
char word;
int count;
printf("Enter a word.

[Code] ....

View 4 Replies View Related

C :: Program To Print Letters In Given Notation

Feb 11, 2014

I have to develop script in C to print the alphabets in given notation.

Please check the attachment.

View 4 Replies View Related

C++ :: Print Asterisks To Correspond To Program

Mar 16, 2014

i have to make two functions one recursion that ask the user to enter number of rows and i use recursion to tell him how many pins there are ex. user enters 5 there are 15 pins. I did this function now i need a function that prints an asterisk triangle for my recursion function so for 15 it should look like this

*
* *
* * *
* * * *
* * * * *

i tried many times but can't make it descend like that i can only get like a right triangle..the hard part is that it goes with the users number so if they enter 3 for example it should be 3 rows.

int pins(int n){
if(n==0){
return 0;

[code]....

View 1 Replies View Related

C++ :: Program To Print Out X / Y Click Coordinates?

Jan 16, 2013

I use the AS/400 warehouse system, and I need to be able to automate typing one letter in several different locations to speed things up.

My thoughts are:
1. Find out how to make a program that will determine x, y coordinates of mouseclicks, and then use software to use macros to change information.
2. Build a program that will complete a single process by repeating set mouse clicks and keystrokes.

We recieve HUGE transfers from a warehouse across the country, and have to change the first character of the name of bin locations - and after a few pages it gets VERY tedious.

View 4 Replies View Related

C++ :: Program Must Print Out 5 Random Numbers

Feb 10, 2014

The program must print out 5 random numbers, from 1 to 45 and 100 different sequence.. Now I want each number of sequence to be different and not the same....

for example

1,2,3,4,5
6,7,8,9,10
....
...
..

here is my code:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main () {
int xRan1;

[Code] ....

View 2 Replies View Related

C/C++ :: Make Program To Print Out String

Nov 24, 2014

I'm trying to make a program in C where the user enters a string and it prints a word for example (name) in lowercase then the same word again but in capitals and lowercase like this (NnAaMmEe).

my code is below;

#include<stdio.h>
#include<ctype.h>
int main()

[Code].....

View 1 Replies View Related

C/C++ :: Program To Print Out Binary Value Of 16 Bit Number

Sep 22, 2013

Write a program to print out the binary value of a 16 bit number.

Create integers i, count, and mask.

Set 'i' to a hex value of 0x1b53.

Set mask to a value of 0x8000. Why?

print a line to show the hex value of i and then the leader for the binary value like this: Hex value = 1b53 Binary=

Use a for loop to loop 16 times and print 16 digits, using count as the loop counter

To test for each digit value, bitwise and 'i' with 'mask'

when the result for the bitwise and is true, print the number '1'

when the result for the bitwise and is false, print the number '0'

then shift mask one place to the right

print a new line and then quit

Use prtscrn and make a hard copy of the code with the console output.

Extra: use the modulus of count and print a space after every 4th digit to make the binary easier to read

The output should look like this: Hex value = 1b53, Binary= 0001 1011 0101 0011

so far this is what i have

#include <stdio.h>
#include <stdlib.h>  
int main() {
    int i, count, mask;
    //   1B53  0001 1011 0101 0011
    //   8000  1000 0000 0000 0000
    i = 0x1b53;

[Code] ....

it is telling me that there is an "else" without previous "if", also is the program that I wrote correct?

View 3 Replies View Related

C :: Program To Print All Of Prime Numbers To Screen

May 29, 2013

I'm trying to write a program that prints all of the prime numbers to the screen. I'm getting angry because it only prints EVERY number. I think it has something to do with the bool change not being able to leave the for-loop but how to fix it.

Code:
#import <stdio.h>
#include <stdbool.h>
int main(void){
printf("
The Primes Are: 1");

[Code] ....

View 3 Replies View Related

C :: Program Doesn't Print Data From Socket

May 7, 2014

I created a basic socket server, which listensing for incoming udp data. When I run the netcat program, I get a response:

Code:
$ nc -luv 1732
Connection from 10.50.11.12 port 1732 [udp/*] accepted
(?@??8?? ??.?n?5
(?@??8?? ??.?n?5|?>)
(?@??8?? ??.?n?5|?>)
^C |?>)

But with my c program it doesn't give the response. It should say something like "here is the message: " and then give a message.

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>

[Code] .....

View 2 Replies View Related

C++ :: How To Make A Program That Print Out Factors Of Integer

Oct 26, 2013

I want to make a simple program that will print out the factors of an integer. My program right now only outputs "The prime factors of 221 are 221, 221, 221, 221"... Where it should be "The prime factors of 221 are 1, 13, 17, 221"

#include <cstdio>
int factorsOf(int x);
//function
int main() {
int x = 221;
printf("The factors of 221 are ");

[Code]...

View 3 Replies View Related

C++ :: Print Out Number Of Twin Primes Program

Jul 27, 2014

This program prints out the total number of up to 100,000. How to do is to print out the number of twin primes up to 100,000. Is it as simple as adding an if statement "if(primesList[j] - i == 2)"?

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
int primesCount = 0;

[Code] ......

View 4 Replies View Related

C++ :: Program To Print Upper Half Of Matrix

Jan 3, 2015

This is a program to print upper half of the matrix.

#include <iostream>
using namespace std;
int upperhalf(int n, int apu[n][n]) {
cout<<"The upper half of the matrix is :

[Code] ....

the compiler is giving these errors:-

sh-4.2# g++ -o main *.cpp
main.cpp:4:31: error: use of parameter outside fun
ction body before ']' token
int upperhalf(int n, int apu[n][n])

[Code] ....

I dont know where i am wrong.

View 3 Replies View Related

C++ :: Program To Print Longest Common Subsequence?

Sep 12, 2014

I found this implementation on a website for printing the longest common subsequence. But it gives wrong answers for some reason even though the code seems right to me.

Here is the code:

#include <iostream>
int lcs(char *X, char *Y, int m, int n)
{
int L[m+1][n+1];
for(int i = 0; i<=m; i++)

[code].....

What is wrong with this code?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved