English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

Q.1 If i want to display the % sign ina printf statment, what can I do?
for examp: i want to display 8.2% in the screen.

Q2 If I have a memory constant called TAX in main , can I use it directly in the function that I created. The compiler said there is error when I use the constant like this..

2006-10-16 04:49:36 · 1 個解答 · 發問者 ? 1 in 電腦與網際網路 程式設計

1 個解答

Q.1
double a=8.2;
printf("%.1f%%\n",a);

Q.2
Method 1: define TAX to be replaced by 15.0 by the C precompiler

#define TAX (15.0)
double abc(){
double a=TAX*100;
return a;
}
int main(....){
printf(....., abc());
}

method 2: put TAX as a global variable (visible by all modules)

#include .....
double TAX;
double abc(){
double a=TAX*100;
return a;
}
int main(....){
TAX=15.0;
printf(....., abc());
}


method 3: use TAX as a formal parameter

double abc(double x){
double a=x*100;
return a;
}
int main(....){
double TAX=15.0;
printf(....., abc(TAX));
}

2006-10-16 05:13:30 · answer #1 · answered by p 6 · 0 0

fedest.com, questions and answers