Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Conversion problems.Please help

Conversion problems.Please help

Scheduled Pinned Locked Moved Managed C++/CLI
helpcsharpc++visual-studioalgorithms
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benibo
    wrote on last edited by
    #1

    This is my code,it has a few bugs and i have looked over them for hours on end but i am at my wits end,please help a brother out.I have to turn this thin in tomorrow at 9.00AM. //Benibo Ajumogobia //@02087650 //Project 2 //19/09/04 #include "stdafx.h" #using using namespace System; void total (int __gc[]);//Function declaration void sort (int __gc[]); void change (int __gc[], int); int _tmain() { //Declaration of Array int size __gc[] = {40,30,25,15,100,70,95,24,33,26,14,99}; Console::WriteLine(S"The Originalnumbers in the array are:"); for (int i = 0; i< size; i++ ) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); void total(size); int even = 0;//declaring even and odd numbers int odd = 0; for(int k = 0; k<= size;k++) { if (size[k] % 2== 0) even = even + 1; else odd = odd + 1; } Console::WriteLine(S"The number of Even Numbers is: {0}",even.ToString()); Console::WriteLine(S"The number of Odd Numbers is: {0}",odd.ToString()); //begin sorting sort(size); Console::WriteLine(S" Numbers in the array in ascending order"); for (int i=0; i <= size; i++) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); Console::WriteLine(S"Please press enter to close"); String *exit = Console::ReadLine(); return 0; }// end main //calculate sum void total(int b __gc[]) { int sum = 0; for (int i = 0; i<= b; i++) sum = sum + b[i]; Console::Write(S"The total is:{0}", sum.ToString()); Console::WriteLine(); int avg = sum/12; Console::WriteLine(S"The average is: {0}", avg.ToString()); } //sort numbers void sort (int c __gc[]) { for (int pass = 1; pass<=c; pass++) for (int i = 0; i < c - 1; i++) if (c[i]>c[i+1]) change (c, i); } //Function to change numbers void change(int d __gc[], int first) { int temp; temp = d[first]; d[first] = d[first + 1]; d[first + 1] = temp; } This are the errors that i got and i was able to resolvce some but this ones persist: c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2446: '<' : no conversion from 'int __gc[]' to 'int' c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2693: '<' : illegal comparison for references to a __gc array c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(29): error

    C 2 Replies Last reply
    0
    • B benibo

      This is my code,it has a few bugs and i have looked over them for hours on end but i am at my wits end,please help a brother out.I have to turn this thin in tomorrow at 9.00AM. //Benibo Ajumogobia //@02087650 //Project 2 //19/09/04 #include "stdafx.h" #using using namespace System; void total (int __gc[]);//Function declaration void sort (int __gc[]); void change (int __gc[], int); int _tmain() { //Declaration of Array int size __gc[] = {40,30,25,15,100,70,95,24,33,26,14,99}; Console::WriteLine(S"The Originalnumbers in the array are:"); for (int i = 0; i< size; i++ ) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); void total(size); int even = 0;//declaring even and odd numbers int odd = 0; for(int k = 0; k<= size;k++) { if (size[k] % 2== 0) even = even + 1; else odd = odd + 1; } Console::WriteLine(S"The number of Even Numbers is: {0}",even.ToString()); Console::WriteLine(S"The number of Odd Numbers is: {0}",odd.ToString()); //begin sorting sort(size); Console::WriteLine(S" Numbers in the array in ascending order"); for (int i=0; i <= size; i++) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); Console::WriteLine(S"Please press enter to close"); String *exit = Console::ReadLine(); return 0; }// end main //calculate sum void total(int b __gc[]) { int sum = 0; for (int i = 0; i<= b; i++) sum = sum + b[i]; Console::Write(S"The total is:{0}", sum.ToString()); Console::WriteLine(); int avg = sum/12; Console::WriteLine(S"The average is: {0}", avg.ToString()); } //sort numbers void sort (int c __gc[]) { for (int pass = 1; pass<=c; pass++) for (int i = 0; i < c - 1; i++) if (c[i]>c[i+1]) change (c, i); } //Function to change numbers void change(int d __gc[], int first) { int temp; temp = d[first]; d[first] = d[first + 1]; d[first + 1] = temp; } This are the errors that i got and i was able to resolvce some but this ones persist: c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2446: '<' : no conversion from 'int __gc[]' to 'int' c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2693: '<' : illegal comparison for references to a __gc array c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(29): error

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why do you need to use managed C++ ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • B benibo

        This is my code,it has a few bugs and i have looked over them for hours on end but i am at my wits end,please help a brother out.I have to turn this thin in tomorrow at 9.00AM. //Benibo Ajumogobia //@02087650 //Project 2 //19/09/04 #include "stdafx.h" #using using namespace System; void total (int __gc[]);//Function declaration void sort (int __gc[]); void change (int __gc[], int); int _tmain() { //Declaration of Array int size __gc[] = {40,30,25,15,100,70,95,24,33,26,14,99}; Console::WriteLine(S"The Originalnumbers in the array are:"); for (int i = 0; i< size; i++ ) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); void total(size); int even = 0;//declaring even and odd numbers int odd = 0; for(int k = 0; k<= size;k++) { if (size[k] % 2== 0) even = even + 1; else odd = odd + 1; } Console::WriteLine(S"The number of Even Numbers is: {0}",even.ToString()); Console::WriteLine(S"The number of Odd Numbers is: {0}",odd.ToString()); //begin sorting sort(size); Console::WriteLine(S" Numbers in the array in ascending order"); for (int i=0; i <= size; i++) Console::Write(S" {0}", size[i].ToString()); Console::WriteLine(); Console::WriteLine(S"Please press enter to close"); String *exit = Console::ReadLine(); return 0; }// end main //calculate sum void total(int b __gc[]) { int sum = 0; for (int i = 0; i<= b; i++) sum = sum + b[i]; Console::Write(S"The total is:{0}", sum.ToString()); Console::WriteLine(); int avg = sum/12; Console::WriteLine(S"The average is: {0}", avg.ToString()); } //sort numbers void sort (int c __gc[]) { for (int pass = 1; pass<=c; pass++) for (int i = 0; i < c - 1; i++) if (c[i]>c[i+1]) change (c, i); } //Function to change numbers void change(int d __gc[], int first) { int temp; temp = d[first]; d[first] = d[first + 1]; d[first + 1] = temp; } This are the errors that i got and i was able to resolvce some but this ones persist: c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2446: '<' : no conversion from 'int __gc[]' to 'int' c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(24): error C2693: '<' : illegal comparison for references to a __gc array c:\Documents and Settings\bkajumogobia\My Documents\Visual Studio Projects\Scrap code\Scrap code\Scrap code.cpp(29): error

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        You don't have conversion problems, you've put a function declaration inside a class, and you've attempted to use the array in the stop test of multiple for loops. You need array->Count instead of array in every instance, and then everything will be fine, except for that function declaration, which needs to be moved above _tmain, instead of inside it. Oh, you also use <= instead of < in your for loops. Arrays are zero indexed. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        B 1 Reply Last reply
        0
        • C Christian Graus

          You don't have conversion problems, you've put a function declaration inside a class, and you've attempted to use the array in the stop test of multiple for loops. You need array->Count instead of array in every instance, and then everything will be fine, except for that function declaration, which needs to be moved above _tmain, instead of inside it. Oh, you also use <= instead of < in your for loops. Arrays are zero indexed. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

          B Offline
          B Offline
          benibo
          wrote on last edited by
          #4

          Thanks,i was able to resolve the issues that you highlited and it worked just fine.Thank you very much.

          B 1 Reply Last reply
          0
          • B benibo

            Thanks,i was able to resolve the issues that you highlited and it worked just fine.Thank you very much.

            B Offline
            B Offline
            BAIJUMAX
            wrote on last edited by
            #5

            Hi benibo, I remember U .U r the Guy who pasted home work last time.i solved the problem with good intension but i got mail from MR.Chris...... the great "NAUGHTY PROFESSOR" specifying some 'Blablabla' comments . I appreciate you since u have the intension to do home work. and u found "codeproject".some people won't. So Try To Write Code without any help.any where u stuck understand that part[ Not The Entire Code u Wrote].and post U R Question. by baijumax:-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups