Can someone fix this ASAP ... I need it for my project

0 jenson francis · February 18, 2015
Question :
W.A.P which will use 1-D arrays as parameter of a function.
Solution:

#include<iostream.h>
#include<conio.h>
int pal(int b[30])
{int n,z,x;
for(int i=0;b!='\0';i++)
       n=i;
       if(n%2==0)
            {
                 for(int j=0,q=n-1;j<n/2;j++,q--)
                {x=b[j];
                  z=b[q];
                  b[j]=z;
                  b[q]=x;
                  }
        if(n%2!=0)
                {
                         int k=n+1/2;
                {for(int j=0,q-1=n;j<k-1;j++,q--)
                {x=b[j];
                z=b[q];
                b[j]=z;
                b[q]=x;
                       } 
                } 
 }
cout<<"\nThe reversed string is : ";
cout.write(b,30);
;}
void main()
{system("cls"); 
char a[30];
cout<<"Enter any word :";
cin.line(a,30);
  pal(a);
getch();


}
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Jay Deshaun · February 19, 2015
Please put it in code tags before posting...
Try this and tell me what you get:
#include<iostream.h>
#include<conio.h>
int pal(int b[30]){
    int n,z,x;
    for(int i=0;b!='\0';i++)
        n=i;
    if(n%2==0){
        for(int j=0,q=n-1;j<n/2;j++,q--){
            x=b[j];
            z=b[q];
            b[j]=z;
            b[q]=x;
        }
        if(n%2!=0){
            int k=n+1/2;
            for(int j=0,q-1=n;j<k-1;j++,q--){
                x=b[j];
                z=b[q];
                b[j]=z;
                b[q]=x;
            }
        }
    }
    cout<<"\nThe reversed string is : ";
    cout.write(b,30);
}
void main(){
    system("cls");
    char a[30];
    cout<<"Enter any word :";
    cin.line(a,30);
    pal(a);
    getch();
}
0 jenson francis · February 19, 2015
In function `int pal(int*)': 
 16 C:\Users\ADMIN\Documents\parameter array2.cpp expected init-declarator before '-' token 
16 C:\Users\ADMIN\Documents\parameter array2.cpp expected `,' or `;' before '-' token 
16 C:\Users\ADMIN\Documents\parameter array2.cpp name lookup of `q' changed for new ISO `for' scoping 
8 C:\Users\ADMIN\Documents\parameter array2.cpp   using obsolete binding at `q' 
25 C:\Users\ADMIN\Documents\parameter array2.cpp no matching function for call to `std::basic_ostream<char, std::char_traits<char> >::write(int*&, int)' 
 note C:\Dev-Cpp\include\c++\3.4.2\bits\ostream.tcc:360 candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<char>] 
 note C:\Dev-Cpp\include\c++\3.4.2\bits\ostream.tcc:360 At global scope: 
27 C:\Users\ADMIN\Documents\parameter array2.cpp `main' must return `int' 
 C:\Users\ADMIN\Documents\parameter array2.cpp In function `int main(...)': 
31 C:\Users\ADMIN\Documents\parameter array2.cpp 'struct std::istream' has no member named 'line' 
32 C:\Users\ADMIN\Documents\parameter array2.cpp cannot convert `char*' to `int*' for argument `1' to `int pal(int*)' 



these are the errors my friend
  • 1

C++

107,275 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator