logo
down
shadow

what the problem in this program? it doesn't use the second number, and doesn't print the last line?


what the problem in this program? it doesn't use the second number, and doesn't print the last line?

By : WF AB
Date : November 20 2020, 07:00 PM
hop of those help? The while loop keeps looping until both count < num2 and finalSum <= num1 become false. So, if only your count < num2 condition becomes false (i.e. count >= num2), the program will continue until both conditions become false.
You should use } while (count < num2 && finalSum <= num1); (if I understand correctly what you trying to achieve)
code :


Share : facebook icon twitter icon
Why the print new line doesnt work?

Why the print new line doesnt work?


By : Ruslan Migirov
Date : March 29 2020, 07:55 AM
With these it helps Only the last call is to println... and println adds a newline at the end of what it's printing. Do if you want a newline before the final Do3 you'd want something like:
code :
if (x==3){
    System.out.println();
    System.out.println("Do"+x);
}
Program doesnt show most frequent number

Program doesnt show most frequent number


By : Danial Hussain
Date : March 29 2020, 07:55 AM
This might help you Problem: I am trying to find most frequent six numbers in an array of random integers but I am only finding my loop count. , This should work for you:
code :
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define SIZE 50

int main() {

    //Access
    int numbers[SIZE+1], randomNumbers, count, innerCount;
    int pcPassword = 2, userPassword = 0, frequentNumber[6], frequentNumberCount[6];
    printf("Enter password:");
    scanf("%d", &userPassword);

    if(pcPassword != userPassword) {
        printf("Wrong Password");
        exit(0);
    }

    printf("How many random Numbers do you want:\n>");
    scanf(" %d", &randomNumbers);

    //initlaized
    for(count = 0; count <= SIZE; count++)
        numbers[count] = 0;

    //Random Numbers
    srand(time(NULL));
    for(count = 0; count < randomNumbers; count++)
        numbers[rand() % 50 + 1]++;

    //Print
    for(count = 1; count <= SIZE; count++) {
        if((count-1) % 6 == 0)
            printf("\n");
        printf("%4d -> %3d", count, numbers[count]);
    }


    //initlaized
    for(count = 0; count < 6; count++) {
        frequentNumber[count] = 0;
        frequentNumberCount[count] = 0;
    }


    //Get frequent numbers
    for(count = 1; count <= SIZE; count++) {
        for(innerCount = 0; innerCount < 6; innerCount++) {

            if(numbers[count] > frequentNumberCount[innerCount]) {
                if(innerCount+1 <= 5)
                    frequentNumber[innerCount+1] = frequentNumber[innerCount];

                frequentNumber[innerCount] = count;
                frequentNumberCount[innerCount] = numbers[count];
                break;
            }

        }

    }

    //Print
    printf("\n\nThe 6 most frequent numbers are:\n");
    for(count = 0; count < 6; count++)
        printf("%d. -> Number: %3d Count: %3d\n", count+1, frequentNumber[count], frequentNumberCount[count]);

    return 0;

}
2     //Password
1200  //Random Numbers
Enter password:2
How many random Numbers do you want:
>1200

   1 ->  23   2 ->  21   3 ->  24   4 ->  24   5 ->  25   6 ->  28
   7 ->  22   8 ->  22   9 ->  25  10 ->  27  11 ->  27  12 ->  20
  13 ->  14  14 ->  29  15 ->  28  16 ->  20  17 ->  22  18 ->  20
  19 ->  29  20 ->  25  21 ->  35  22 ->  21  23 ->  24  24 ->  23
  25 ->  21  26 ->  24  27 ->  12  28 ->  33  29 ->  23  30 ->  17
  31 ->  33  32 ->  21  33 ->  24  34 ->  23  35 ->  33  36 ->  21
  37 ->  22  38 ->  28  39 ->  30  40 ->  18  41 ->  16  42 ->  29
  43 ->  24  44 ->  29  45 ->  30  46 ->  20  47 ->  19  48 ->  26
  49 ->  18  50 ->  28

The 6 most frequent numbers are:
1. -> Number:  21 Count:  35
2. -> Number:  28 Count:  33
3. -> Number:  31 Count:  33
4. -> Number:  35 Count:  33
5. -> Number:  39 Count:  30
6. -> Number:  45 Count:  30
Why doesnt this snippet of code print the number normally?

Why doesnt this snippet of code print the number normally?


By : haydarov
Date : March 29 2020, 07:55 AM
Hope that helps unsigned long is not always sufficiently large. With 32 bits it can occupy integers from 0 up to and including 232-1, which is about four billions. 9'110'865'112 is nine billions and would thus not fit into unsigned long.
Try outputting sizeof unsigned long and see what you get.
Why doesnt my program print the data it receives instead of the address?

Why doesnt my program print the data it receives instead of the address?


By : Armitha Reddy
Date : March 29 2020, 07:55 AM
wish of those help Maybe Try to use System.out.println("The state is " + Arrays.toString(input));
Because printing input is equivalent to printing input.toString(); and this print the memory address of the array.
Golang: Hello world doesn't print to screen and program doesnt exit

Golang: Hello world doesn't print to screen and program doesnt exit


By : Abhishek Dabholkar
Date : March 29 2020, 07:55 AM
around this issue I ran into this same problem on a Windows 10 system. Running go run main.go would not print anything, while go build main.go followed by .\main.exe would work correctly and print out "hello, world".
The problem was due to the Comodo antivirus software quarantining the go.exe process as part of its Auto Containment feature. I believe the go run command compiles and tries to load the executable binary code of main.go into the same process, which triggers the Auto Containment to isolate the output of the application.
Related Posts Related Posts :
  • C++ - Unicode Newline
  • Program crashing with 'std::out_of_range' error
  • Use signed or unsigned char in constructing CString?
  • Parallel execution policies in C++ 17
  • C++ Class Templates (Queue of a class)
  • Convert image into useable byte array in C?
  • pointer to preallocated memory as an input parameter and have the function fill it
  • Animated Image in Win32
  • error on compiling statically linked library created in Qt
  • How to easily pass a very long string to a worker process under Windows?
  • Can a class add friend classes at runtime in C++?
  • C++ priority queue in ascending order by specific method for objects
  • Initialize and declare dynamically multiple variables of random entities in a loop in C++
  • Serializing, integer without libaries , getting weird results
  • Function pointers with default parameters in C++
  • Compilation errors with RapidXML
  • Bad_alloc exception when using new for a struct c++
  • count specific things within a code in c++
  • How to extract 48*48 icon image from resource of an executable file?
  • C++ Convert string (or char*) to wstring (or wchar_t*)
  • C++ include .h includes .cpp with same name as well?
  • Any way in C++ to forward declare a function prototype?
  • boost graph adjacency_list, retrieving a node's parents
  • Copy method optimization in compilers
  • Need to format character precedence in Strings
  • Cross-Platform Camera API
  • sizeof continues to return 4 instead of actual size
  • String search algorithm used by string::find() c++
  • Two-phase lookup: can I avoid "code bloat"?
  • Strongest cipher available to use with C/C++?
  • Why does my program occasionally segfault when out of memory rather than throwing std::bad_alloc?
  • Firefox XULRunner or TriXul?
  • Does GetSystemInfo (on Windows) always return the number of logical processors?
  • Where is the difference between these code? Shouldn't output be the same?
  • What does it mean mean by "Expected a statement" in C++
  • keybd_event is not working right =(
  • What native C++ profiling tool do you suggest?
  • how to copy char * into a string and vice-versa
  • C++ write to front of file
  • Delphi conversion of C++ header for DVP7010B video card DLL?
  • I keep Getting Control reaches end of non-void function. What am I doing wrong?
  • How to have struct members accessible in different ways
  • Am I abusing Policies?
  • Modern equivalent of BoundsChecker for Visual Studio 2008
  • exposing subcontrols from the custom widget plugin in QT
  • How to execute a function called many times, only once !
  • How to use Ptrace on Linux to print Call Stack of Other Processes of C++
  • BOOST.IOstreams: trouble to write to bzip2
  • C++ MIDI file reading library
  • exchanging 2 memory positions
  • C++ infix to prefix conversion for logical conditions
  • Can memory be leaked when using vector of pointer in c++?
  • Mixing policy-based design with CRTP in C++
  • how to check if the OS is Windows or Debian in c++?
  • Searching LPSTR string
  • Qt Linker Error: "undefined reference to vtable"
  • Differences between template class implemenations in C++ on Linux and MSVC Win32
  • C++ Performance/memory optimization guidelines
  • Appending a vector to a vector
  • identifier "operator + =" is not defined
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk