Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 9-Dec-12 19:03pm
Edited 9-Dec-12 19:26pm
krumia11.9K
v3
Comments
Krunal Rohit at 10-Dec-12 0:05am
   
and the problem isss.. ????
AnkitGoel.com at 10-Dec-12 0:17am
   
:D
krumia at 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:
 
Identifier ****** is not defined
ThatsAlok at 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
Quirkafleeg at 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
0 OriginalGriff 7,215
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
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