Solved

Needs help in function

Posted on 2011-03-17
2
391 Views
Last Modified: 2012-05-11
Hi guys: Can any one please help me how to return the value of the response variable outside the getCharacter function ? I try it but it gives syntax error ? Thanks.

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
    {
            getCharacter()
            {
                  char response=' ';
                  cout << "Enter character-->";
                  cin >> response;
                  return response;
            }
      cout << response;
      system("pause");
      return 0;
}

0
Comment
Question by:mustish1
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 35162503
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
char      getCharacter()
            {
                  char response=' ';
                  cout << "Enter character-->";
                  cin >> response;
                  return response;
            }
int main()
    {

      cout <<  getCharacter();
      system("pause");
      return 0;
}
0
 

Author Closing Comment

by:mustish1
ID: 35162511
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 67
Hashing Algorithm 5 51
Re-position the objects 7 97
Windows and other UI names - The Proper names for the Various elements! 1 58
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now