목차
프로그램 4.1
프로그램 4.2.1
프로그램 4.3
프로그램 4.4
프로그램 4.5
프로그램 4.6
프로그램 4.7
프로그램 4.8
프로그램 4.9
프로그램 4.10
▤ 프로그램 4.11
▤ 프로그램 4.12
▤ 프로그램 4.13
▤ 프로그램 4.14
▤ 프로그램 4.15
▤ 프로그램 4.16
▤ 프로그램 4.17
▤ 프로그램 4.18
▤ 프로그램 4.19
▤ 프로그램 4.20
▤ 프로그램 4.21
▤ 프로그램 4.22
▤ 프로그램 4.23
▤ 프로그램 4.24
▤ 프로그램 4.25
▤ 프로그램 4.26
▤ 프로그램 4.27
프로그램 4.2.1
프로그램 4.3
프로그램 4.4
프로그램 4.5
프로그램 4.6
프로그램 4.7
프로그램 4.8
프로그램 4.9
프로그램 4.10
▤ 프로그램 4.11
▤ 프로그램 4.12
▤ 프로그램 4.13
▤ 프로그램 4.14
▤ 프로그램 4.15
▤ 프로그램 4.16
▤ 프로그램 4.17
▤ 프로그램 4.18
▤ 프로그램 4.19
▤ 프로그램 4.20
▤ 프로그램 4.21
▤ 프로그램 4.22
▤ 프로그램 4.23
▤ 프로그램 4.24
▤ 프로그램 4.25
▤ 프로그램 4.26
▤ 프로그램 4.27
본문내용
KILO);
return(0);
}
▤ 프로그램 4.18
/* Program to bitwise AND, OR, NAND, NOR and EX-OR two hexadecimal values */
#include
intmain(void)
{
int value1, value2;
/* &- bitwise ANDoperator*/
/* |- bitwise ORoperator*/
/* ^- bitwise EX-ORoperator*/
/* ~- bitwise NOToperator*/
printf("Enter two hex values >>> ");
scanf("%x %x",&value1,&value2);/* 16진수 입력 */
printf("Values ANDed is %x\n",value1 & value2);
printf("Values ORed is %x\n",value1 | value2);
printf("Values Ex-ORed is %x\n",value1 ^ value2);
printf("Values NANDed is %x\n",~(value1 & value2));
printf("Values NORed is %x\n",~(value1 | value2));
return(0);
}
▤ 프로그램 4.19
/*Program to display a decimal integer in hexadecimal*/
/*and octal */
#include
intmain(void)
{
int value;
puts("Enter integer value (-32768 to 32767) >> ");
scanf("%d",&value);
printf("Decimal = %d, Octal = %o, Hex = %x\n",value,value,value);
return(0);
}
▤ 프로그램 4.20
/* Program to display a hexademical value as demical*/
/*and octal */
#include
intmain(void)
{
int value;
puts("Enter hexadecimal value");
scanf("%x",&value);
printf("Decimal = %d, Octal = %o, Hex = %x\n",value,value,value);
return(0);
}
▤ 프로그램 4.21
/* Program to ASCII code to character */
#include
intmain(void)
{
int value;
puts("Enter ASCII code (greater than 33)>");
scanf("%d",&value);
printf("Code = %d, character = %c\n",value,value);
return(0);
}
▤ 프로그램 4.22
/* Program to determine equivalent resistance */
/* of two resistors in parallel */
#include
int main(void)
{
float R1,R2,Requ;
puts("Enter R1 and R2");
scanf("%f %f",&R1,&R2);
Requ=1.0/(1.0/R1+1/R2);
printf("Parallel resistance is %f",Requ);
return(0);
}
▤ 프로그램 4.23
/* Program to determine current flowing in */
/* a resistor using Ohms law */
#include
int main(void)
{
float current,voltage,resistance;
printf('Enter voltage and resistance>> ');
scanf("%f %f",voltage,resistance);
current=voltage/resistance;
printf("Current is ",current," amps\n");
return(0);
}
▤ 프로그램 4.24
/* Program to OR two hex values */
#include
int main(void)
int val1,val2,val3;
{
printf("Enter two hex values>> ");
scanf("%d %d",&val1,&val2);
val3= val1 & val2;
printf("%x OR %x = %x\n",val1,val2,val3);
return(0);
}
▤ 프로그램 4.25
/*Program to determine power dissipated in*/
/*a resistor with an applied a.c. waveform*/
#include
intmain(void)
{
float Vmax,Vrms,R,power;
printf("Enter peak voltage and resistance>> ");
scanf("%f %f",&Vmax,&R);
Vrms=Vmax/sqrt(2);
power=(Vrms*Vrms)/R;
printf("Power is %6.2f\n watts",power);
return(0);
}
▤ 프로그램 4.26
#include
int main(void)
{
int y;
/* let this be a lesson to use parenthesis */
y = -3 + 6 * 3 - 2; printf("%d \n",y);
y = 3 + 4 % 5 - 6; printf("%d \n",y);
y = -4 * 3 % - 6 / 5 ; printf("%d \n",y);
y = ( 7 + 6 ) % 5 / 2 ;printf("%d \n",y);
return(0);
}
▤ 프로그램 4.27
#include
int main(void)
{
intx=4, y ,z;
x *= 3 + 2 ;printf("%d\n",x);
x *= y = z = 4 ; printf("%d \n", x);
x++ ; printf("x = %d \n",x);
return(0);
}
return(0);
}
▤ 프로그램 4.18
/* Program to bitwise AND, OR, NAND, NOR and EX-OR two hexadecimal values */
#include
intmain(void)
{
int value1, value2;
/* &- bitwise ANDoperator*/
/* |- bitwise ORoperator*/
/* ^- bitwise EX-ORoperator*/
/* ~- bitwise NOToperator*/
printf("Enter two hex values >>> ");
scanf("%x %x",&value1,&value2);/* 16진수 입력 */
printf("Values ANDed is %x\n",value1 & value2);
printf("Values ORed is %x\n",value1 | value2);
printf("Values Ex-ORed is %x\n",value1 ^ value2);
printf("Values NANDed is %x\n",~(value1 & value2));
printf("Values NORed is %x\n",~(value1 | value2));
return(0);
}
▤ 프로그램 4.19
/*Program to display a decimal integer in hexadecimal*/
/*and octal */
#include
intmain(void)
{
int value;
puts("Enter integer value (-32768 to 32767) >> ");
scanf("%d",&value);
printf("Decimal = %d, Octal = %o, Hex = %x\n",value,value,value);
return(0);
}
▤ 프로그램 4.20
/* Program to display a hexademical value as demical*/
/*and octal */
#include
intmain(void)
{
int value;
puts("Enter hexadecimal value");
scanf("%x",&value);
printf("Decimal = %d, Octal = %o, Hex = %x\n",value,value,value);
return(0);
}
▤ 프로그램 4.21
/* Program to ASCII code to character */
#include
intmain(void)
{
int value;
puts("Enter ASCII code (greater than 33)>");
scanf("%d",&value);
printf("Code = %d, character = %c\n",value,value);
return(0);
}
▤ 프로그램 4.22
/* Program to determine equivalent resistance */
/* of two resistors in parallel */
#include
int main(void)
{
float R1,R2,Requ;
puts("Enter R1 and R2");
scanf("%f %f",&R1,&R2);
Requ=1.0/(1.0/R1+1/R2);
printf("Parallel resistance is %f",Requ);
return(0);
}
▤ 프로그램 4.23
/* Program to determine current flowing in */
/* a resistor using Ohms law */
#include
int main(void)
{
float current,voltage,resistance;
printf('Enter voltage and resistance>> ');
scanf("%f %f",voltage,resistance);
current=voltage/resistance;
printf("Current is ",current," amps\n");
return(0);
}
▤ 프로그램 4.24
/* Program to OR two hex values */
#include
int main(void)
int val1,val2,val3;
{
printf("Enter two hex values>> ");
scanf("%d %d",&val1,&val2);
val3= val1 & val2;
printf("%x OR %x = %x\n",val1,val2,val3);
return(0);
}
▤ 프로그램 4.25
/*Program to determine power dissipated in*/
/*a resistor with an applied a.c. waveform*/
#include
intmain(void)
{
float Vmax,Vrms,R,power;
printf("Enter peak voltage and resistance>> ");
scanf("%f %f",&Vmax,&R);
Vrms=Vmax/sqrt(2);
power=(Vrms*Vrms)/R;
printf("Power is %6.2f\n watts",power);
return(0);
}
▤ 프로그램 4.26
#include
int main(void)
{
int y;
/* let this be a lesson to use parenthesis */
y = -3 + 6 * 3 - 2; printf("%d \n",y);
y = 3 + 4 % 5 - 6; printf("%d \n",y);
y = -4 * 3 % - 6 / 5 ; printf("%d \n",y);
y = ( 7 + 6 ) % 5 / 2 ;printf("%d \n",y);
return(0);
}
▤ 프로그램 4.27
#include
int main(void)
{
intx=4, y ,z;
x *= 3 + 2 ;printf("%d\n",x);
x *= y = z = 4 ; printf("%d \n", x);
x++ ; printf("x = %d \n",x);
return(0);
}
소개글