#include <stdio.h>
main()
{
///* Assignment 01 :: take two double values and perform the four basic operations in sequence */
double x=0;
double y=0;
double p,m,g,n;
printf("Enter two double values for the four operations.\n");
scanf("%lf",&x);
scanf("%lf",&y);
p=x+y;
m=x-y;
g=x*y;
n=x/y;
printf("x+y=%2.2lf\n,x-y=%2.2lf\n,x*y=%2.2lf\n,x/y=%2.2lf\n",p,m,g,n);
return 0;
//// Assignment 02_a :: take a letter and swap lowercase to uppercase and uppercase to lowercase
char ch_in;
printf("대문자와 소문자를 바꿔드립니다. 아무거나 한개의 문자만 입력하시오.\n");
scanf("%c",&ch_in);
if(ch_in>='A' && ch_in<='Z')
ch_in+=32;
else
ch_in-=32;
printf("%c",ch_in);
return 0;
//// Assignment 02_b
char ch_in;
char x;
printf("대문자와 소문자를 바꿔드립니다. 아무거나 한개의 문자만 입력하시오.\n");
scanf("%c",&ch_in);
x = (ch_in>='A' && ch_in<='Z') ? ch_in+32 : ch_in-32;
printf("%c",x);
return 0;
//// Assignment 03 :: take rectangle coordinates from the user and calculate the area
int x1,y1,x2,y2;
int w,h,sum;
printf("This program calculates the area.\n");
printf("Enter the x,y coordinates of the start point.");
scanf("%d,%d",&x1,&y1);
printf("Enter the x,y coordinates of the end point.");
scanf("%d,%d",&x2,&y2);
w= (x1>x2) ? (x1-x2):(x2-x1) ;
h= (y1>y2) ? (y1-y2):(y2+y1) ;
sum = w * h;
printf("The area of the rectangle defined by the two points is %d.\n",sum);
return 0;
}
#include <stdio.h>
main()
{
//// Example 1) First array example
int ar[5]={5,6,7,8,9};
int cnt=0,sum=0;
for(cnt=0;cnt<5;cnt++)
{
printf("ar[%d]:%d\n",cnt,ar[cnt]);
sum+=ar[cnt];
}
printf("sum:%d\n",sum);
//// Example 2) Take five integers, sum them all, and print the result.
int cnt=0;
int ar[5]={0},sum=0;
printf("Enter five numbers and they will be summed");
scanf("%d %d %d %d %d",&ar[0],&ar[1],&ar[2],&ar[3],&ar[4]);
for(cnt=0;cnt<5;cnt++)
{
sum+=ar[cnt];
}
printf("sum:%d\n",sum);
Example 3-1)
char str[30]={0};
Take an English-letter name as input and store it in the array -> print it normally and in reverse
Example 3-2)
//char str[10]="a376#c"; == char str[10]={'a','3','7','b','#','c'};
// from this, print only the English letters
char str[10]; take English letters and special characters as input, store them in the array above and print
on the next line, remove special characters from the input and print only English letters
Example 3-3)
char str[10]="kitri";
char buf[10];
using the two above, find the length of the string in the str array,
copy that string into the buf array, and then print it
}
