Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
#include <cstdlib>
#include <iostream>
#define NUM 10

using namespace std;

char city[]="Penang";
int count;

int main(int argc, char *argv[])
{
    int abc;
    count = NUM;
    abc = 5;
    do_var_fun();
    cout<<abc<<" "<<count<<" "<<pgm_var<< " " <<xyz;
    system("PAUSE");
    return EXIT_SUCCESS;
}

int pgm_var = 7;

void do_var_fun()
{
    char xyz ='A';
    xyz = 'b';
    cout <<xyz<<" "<<pgm_var <<" " <<abc<< " "<<city;
    return;
}
Posted
Updated 9-Dec-12 18:26pm
v3
Comments
[no name] 10-Dec-12 0:05am    
and the problem isss.. ????
AnkitGoel.com 10-Dec-12 0:17am    
:D
krumia 10-Dec-12 0:29am    
I strongly believe that this is your homework. Correct me if I am wrong.

The first thing you can do to spot the problem is to compile it. The compiler will give some helpful error messages. For example:

<quote>Identifier ****** is not defined
ThatsAlok 10-Dec-12 1:29am    
Agreed, these day compiler are quite advance, not 20 year back when error is at line 10 and it's pointing to line 200!

1 solution

C++
#include <cstdlib>
#include <iostream>
#define NUM 10
 
using namespace std;
 
char city[]="Penang";
int count;
int pgm_var = 7;
void do_var_fun();

int main(int argc, char *argv[])
{
    int abc;
    count = NUM;
    abc = 5;
    do_var_fun();
    cout<<abc<<" "<<count<<" "<<pgm_var<< " " <<xyz;
    system("PAUSE");
    return EXIT_SUCCESS;
}
 

 
void do_var_fun()
{
    char xyz ='A';
    xyz = 'b';
    cout <<xyz<<" "<<pgm_var <<" " <<abc<< " "<<city;
    return;
}
 
Share this answer
 
v2
Comments
[no name] 10-Dec-12 1:32am    
You can help him by providing some hint.Don't post exat answer. That reduce his program skills
Quirkafleeg 10-Dec-12 10:39am    
Agreed. C/C++ programmers should learn what "definition" and "declaration" mean - which begs the question of why create a forward declaration of "do_var_fun", when the definition could easily have been moved above "main"?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900