Click here to Skip to main content
13,192,426 members (48,890 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
#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 9-Dec-12 18:03pm
Updated 9-Dec-12 18:26pm
krumia12K
v3
Comments
Krunal Rohit 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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

#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;
}
  Permalink  
v2
Comments
sajeesh.c 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.171017.2 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100