What's new

Closed variable tutorial

Status
Not open for further replies.

rev01

Addict
Joined
Feb 23, 2017
Posts
21
Reaction
2
Points
71
Age
28
C++ has set of keyword such as You do not have permission to view the full content of this post. Log in or register now.
those word that been in this keyword can't be use as variable
speaking of variable you can't* use two character variable such as OT(overtime), etc..
perhaps you could use three or four to be sure two variable is still possible...
I still prefer 3/more variable

Code:
#include <iostream>
using namespace std;
*// either global call
*//int funds; *// you can input value through Int funds=123; but you have to delete cin.
*//int purchase; 
*//int totalvalue;
int main(){
*// either within call

int funds;
int purchase;
int totalvalue;

cout << "Input Funds" << endl;
cin >> funds;
cout << "Input Price" << endl;
cin>> purchase;

totalvalue=funds-purchase;
return 0;
}
 
Boss, C++ newbie me. Confused lang ako tungkol sa "you can't* use two character variable such as OT(overtime), etc.."

Yung short program ko na may 1 or 2-char variable at function name, gumana naman.

C++:
#include <iostream>

void ab(const char* c) {
    std::cout << "Hello from 2-char function name" << std::endl;
}

int main(int argc, char* argv[]) {
    char n[] = "Hello world";
    for (char& c : n) {
        std::cout << c << " " << std::flush;
    }
    std::cout << std::endl;
    ab(n);
    return 0;
}

Tapos copy-paste ko yung code mo pero ayaw ma-compile
Code:
user@debian10:~/programming/cpp$ c++ rev01.cpp && ./a.out
rev01.cpp:7:1: error: expected unqualified-id before ‘int’
 int main(){
 ^~~
user@debian10:~/programming/cpp$ [CODE]
 
Boss, C++ newbie me. Confused lang ako tungkol sa "you can't* use two character variable such as OT(overtime), etc.."

Yung short program ko na may 1 or 2-char variable at function name, gumana naman.

C++:
#include <iostream>

void ab(const char* c) {
    std::cout << "Hello from 2-char function name" << std::endl;
}

int main(int argc, char* argv[]) {
    char n[] = "Hello world";
    for (char& c : n) {
        std::cout << c << " " << std::flush;
    }
    std::cout << std::endl;
    ab(n);
    return 0;
}

Tapos copy-paste ko yung code mo pero ayaw ma-compile
Code:
user@debian10:~/programming/cpp$ c++ rev01.cpp && ./a.out
rev01.cpp:7:1: error: expected unqualified-id before ‘int’
int main(){
^~~
user@debian10:~/programming/cpp$ [CODE]


yung dereferencing na ampersand sa "char& c" pagkakaalam ko invalid ata to. sa assignment lang ata pwede to , example int *p = &address; pero sa paggawa ng variable pointer lang or array pwede i-append
 
Status
Not open for further replies.

Similar threads

Back
Top