기본 콘텐츠로 건너뛰기

2017의 게시물 표시

C++ A8 with C++ standardArray

#include <iostream> #include <cstddef> #include <array> using namespace std; //@Writer 5396952 Hyeonmin LEE int main(){  const size_t arrSize = 1000;  array <bool, arrSize> arr;  int count = 0;  /*  c++ standard library array template  array <dataType, size> name;  size_t = unsigned int, good data type to represent array subscription  included in std namespace and is in header <cstddef>  */  for(size_t i = 0; i < 1000; i++)  {   arr[i] = true;  }  for(size_t i = 2; i < 1000; i++)  {   if (arr[i] == true)   {    for(size_t j = i + 1; j < 1000; j++)    {//loop checks if there is a number devidable by 2, and by the numbers after     if(j % i == 0)     {      arr[j] = false;     }    }   }  }    for(int i = 2; i < 1000; i++)  {   if(arr[i] == true)   {    count++;    cout << count << ". " << i << " is prime number" << endl;   }  } return 0; } //뭘봐 눈깔아

C++ A8

#include <iostream> using namespace std; //@Writer 5396952 Hyeonmin LEE int main(){  bool arr[1000];  int count = 0;  for(int i = 0; i < 1000; i++)  {   arr[i] = true;  }  for(int i = 2; i < 1000; i++)  {   if (arr[i] == true)   {    for(int j = i + 1; j < 1000; j++)    {//loop checks if there is a number devidable by 2, and by the numbers after     if(j % i == 0)     {      arr[j] = false;     }    }   }  }    for(int i = 2; i < 1000; i++)  {   if(arr[i] == true)   {    count++;    cout << count << ". " << i << " is prime number" << endl;   }  } return 0; } /*I'm thinking to use it for my JAVA assignment if it's possible^^ got to know that JAVA doesn't have unsigned int.. java is weird */

JAVA Integer to binary with 민경~~~

package java_a5; // @author hi123 import java.io.*; import java.util.Scanner;//to use scanner //import java.long.Integer; why?? public class JAVA_A5 {     public static void main(String[] args) {         Scanner scan = new Scanner(System.in);     System.out.println("Enter the integer");     int num = scan.nextInt();     //scannerObjectName.nextInt = gets int from user      System.out.println("Binary is " + Integer.toBinaryString(num));           System.out.println("Numer of 1 bits is " + Integer.bitCount(num));     } } //yeahhhh~~~~

About Bitwise Operator

AND operation (&) = true when each operand is true. OR operation (|) = true when at least one operand is true XOR operation (~) = when two operand is different, it's true Bitwise Compliment = 보수연산. changes the absolute value to opposite. Left Shift = move bites as much as operand to left  ex) a = 0011 1100  a<<2 = 1111 Right Shift = to right  ex) a>>2 = 1111 Unsiged Right Shift (>>>) = unsigned shift operator  fill zero in leftmost bit and do shift From A6 notification //im  not sure for unsigned shift operator but do not wanna work on it now ^^ will come back when i want Chao!!

JAVA exercise 0610

//@writer Min import java.util.Scanner; public class NewClass {     public static void main(String[] args){         Scanner scan = new Scanner (System.in);                 System.out.println("Enter your age as an integer");                 while(! scan.hasNextInt() ){ //hasNextInt = returns 1 when the scanner gets next as int             String garbage = scan.nextLine( );//it calls the object scan, activate scanning line             //gets next line of input, since the data type is STRING!!             System.out.println("\n Enter as INTEGER please");         }       int age =   scan.nextInt( );             System.out.println("Your age is " + age);     } } //어예~~!!!

JAVA exercise 0601

//package exercise; import java.util.Scanner; // @author Min public class Exercise {     /**      * @param args the command line arguments      */     public static void main(String[] args) {      final int SENTINEL = -1;      int number;           Scanner scan = new Scanner(System.in); //Scanner() << in () there must be method to use through or exact variable to use      //declaring Scanner object, the name is scan, taking System.in as parameter      System.out.println("Enter an integer, -1 to end");           number = scan.nextInt();      //it calls memberfuntion of scan, it takse nextint      while(number != SENTINEL){          System.out.println(number);                   System.out.println("Enter an integer, -1 to end");          number = scan.nextInt();      }      System.out.println("Sentinel vaule detected. goodbye!");     }     } //Hello JAVA!!! sorry to hate you but let's be friend from now!!

C++ A6 submitted file

#include <iostream> #include <random> #include <iomanip> #include <chrono> #include <math.h> //@writer 5396952 Hyeonmin LEE using namespace std; int guessNum(int , int*); int guessGame(); int main() {  while(1){         if (guessGame() == -1){             break;         }     } return 0; } int guessNum(int number) { int count = 0; int input = 1;  while(1) {   count ++;      cin >> input;   if(!cin || !(input <=1000 && input >= 1)) {          cin.clear();          cin.ignore(1001, '\n');          cout << "Invalid data type or out of range!" << endl;    cout << "Please enter right value." << endl;      }       if (input < number) {          cout << "Too low. Try again." << endl;   };      if (input > number) {         cout << "Too high. Try again." << endl;      }         if(input == number){     

C++ fg0610

#include <iostream> #include <iomanip>//able to use setw #include <random>//contains random number generate feature in c++11 #include <ctime> using namespace std; int main(){  default_random_engine engine{(static_cast <unsigned int> (time (0)))};// time(0) is same with time(NULL)  //static cast makes the variable to keep the same data type through whole program.  //engine class generates random number.  uniform_int_distribution <unsigned int>randomInt{1 , 6};  //uniform_int_distribution makes set of random number's distribution between.  char wait;  for (unsigned int count = 1; count <= 10; count++){   cout << setw(10) << randomInt(engine);     if(count != 0 && count %5 == 0){    cout << endl;   }  }  cin >> wait;   return 0;  }

C++ A5 submitted header file

#include <cmath> class FindPytha{  private :  double sqrHypo = 0;  double check = 0;  double hypo = 0;  public :   double getSqrHypo(int side1, int side2){   sqrHypo = (side1 * side1) + (side2 * side2);   return sqrHypo;   }     double getHypo(double sqrHypo){    hypo = sqrt(sqrHypo);    check = round(hypo);       if(check == hypo){         return hypo;    }    else {     return 1;      };   } };

C++ A5 submitted main()

#include <iostream> #include "findPytha.h" using namespace std; //@writer 5396952 Hyeonmin LEE int main(){  FindPytha findPytha;  int side1 = 0;  int side2 = 0;  int hypo = 0;  int pythaSum = side1 +side2 + hypo;  int num = 0;  double sqrHypo = 0;  int i = 0;  int j = 0;   while(side1 <= 500){    side1++;    side2 = side1;    while(side2 <= 500){     side2 ++;     sqrHypo = findPytha.getSqrHypo(side1, side2);     hypo = findPytha.getHypo(sqrHypo);       if( hypo != 1 && hypo <= 500) {      num ++;      cout << num << ". " << side1 << " " << side2 <<" " << hypo << "\n";     }      }   } } //there was big difference to put side2=side1, i don't know why it is necessary.... still I failed to make my own loop but I'm enough proud of my header file! 질투와 승부욕은 배움의 좋은 채찍이기도 하면서 1도 도움이 안 될 때가 있다. 원래 배움이란 주고 받고 하면서 서로 배우는 것이다. 나눔에 인

C++ A4 commented header file

// Try to not put any special characters in your file names (+, spaces or such) // For class files (header and cpp file), it is a good to give them the same name as the Class (here Account.h and Account.cpp) // Think about ALWAYS putting the header code into these things, as it will protect your code from double/multi inclusion (VERY IMPORTANT!!! EVEN MORE SO IN BIGGER PROJECTS!!!) #ifndef __ACCOUNT_HPP__ #define __ACCOUNT_HPP__ #include <iostream> // BAD PRACTICE!!! AND ESPECIALLY NOT IN A HEADER PLEASE! There are A LOT of things in std, so if for example another library has a function with the same name, it can cause important problems!! // See cpp file for an alternative form //using namespace std; // Always begins with a Capital Letter!!! // Also, prefer to put your code in the appropriated cpp files, it is a lot cleaner, readable and maintainable class Account { private :  int cstNum; // cst = customer  int cstBal;//balance  int cstChrg;//charge  int cstCredit;  int cst

C++ A4 commented main()

#include <iostream> #include "C++_A4_MIN.h" //writer 5396952 Hyeonmin LEE // using namespace std; is less problematic in an cpp file, as it is restricted to only this file // I still prefer to write std::cout and such, it is more readable and at least you are sure you use the functions from the right library // Here another way to do it: using on the single components you want to use (a bit like in Java) using std::cin; using std::cout; using std::endl; int main(int argc, char** argv) {  int num = 0;  // you have to use double values here, or you wont be able to read decimals number with std::cin  double bal = 0;  double chrg = 0;  double credit = 0;  double creditLimit = 0;     // you don"t need the "class" keyword before the class name     // BONUS: you don't need the "struct" keyword either when declaring a struct in C++ (in C you need it so it is a bit confusing :x)  Account account;  while (true) {   std::cout << "Enter

C++ A4 submitted header file

#include <iostream> using namespace std; class Customer{  private :   int cstNum; // cst = customer   int cstBal;//balance   int cstChrg;//charge   int cstCredit;   int cstCreditLimit;    public :   Customer(){//consturctor    cstNum = 0;    cstBal = 0;    cstChrg = 0;    cstCredit = 0;    cstCreditLimit = 0;   }   void setNum(int num){    cstNum = num;     }     void setBal(double bal){    cstBal = (int)bal * 100;   }     void setChrg(double chrg){    cstChrg = (int)chrg * 100;   }     void setCredit(double credit){    cstCredit = (int)credit * 100;   }     void setCreditLimit(double creditLimit){    cstCreditLimit = (int)creditLimit * 100;   }     double getNewBalance(){    return ((double)cstBal - (double)cstCredit + (double)cstChrg) * 0.01;   }   void getExceed(){    double newBalance = getNewBalance();    double creditLimit = cstCreditLimit / 100.0; //explicit transform       if(creditLimit < cstCreditLimit){     std::cout << "new balance is" << new

C++ A4 submitted main()

#include <iostream> #include "customer.h" //writer 5396952 Hyeonmin LEE , helped by sascha using std::cin; using std::cout; using std::endl; int main(int argc, char** argv) {  int num = 0; //to get decimal input, will calculate it in member funtion in integer  double bal = 0;  double chrg = 0;  double credit = 0;  double creditLimit = 0;  while (1){   Customer customer;   std::cout << "Enter customer number. (or -1 to end)" << std::endl;   std::cin >> num;     if(std::cin.fail()){    return 0; //while's condtion is 1, this return 0 ends while loop   }     if(num == -1){    return 0; //end main funtion   }   customer.setNum(num);     std::cout << "Enter beginning balance." << std::endl;   std::cin >> bal;   customer.setBal(bal);     std::cout << "Enter total charge." << endl;   std::cin >> chrg;   customer.setChrg(chrg);     std::cout << "Enter total credits." <&l

Mystery...?!

#include <iostream> using namespace std; int main(){  int x = 1;  while ( x <= 10){   cout << (x % 2 == 1 ? "odd" : "even") << endl;   x++;  }  return 0; } //그댄 내 머리 위으 ㅣ우산~~!!

POWER calculator (ex04_08)

#include <iostream> using namespace std; void cal_power (); bool ask_re(); int main(){ do{  cal_power(); } while(ask_re() == true); return 0; } void cal_power(){  int i = 0;  unsigned int result = 1;  unsigned int base = 0;  unsigned int power = 0;  cout << "Enter the base." << endl;  cin >> base;  cout << "Enter the power." << endl;  cin >> power;  while (i < power){//as long as the counter is same or smaller than power   result *= base;   i ++;  }  cout << power << " power of " << base << " is" << result <<endl;//display the result } bool ask_re(){  char response;  cout << "Enter \"y\" to do again, \"n\" to end" << endl;  cin >> response;  if(response == 'y')   return true;  else if (response == 'n')   return false; //Ay YEAHHHH get swifty~~~~~~

Guessing Game~! by C++

#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void guessGame(); bool isCorrect(int, int); int main(){  srand (time (0));  guessGame();  return 0; } void guessGame(){  int answer;  int guess;  char response;  do{   answer = 1 + rand() % 10; // make constant random value from 1 to 100   cout << "Guess number between 1 and 10" <<endl;   cin >> guess;       while( !isCorrect(guess, answer)) // as long as the return value is false, continue    cin >> guess; // condition itself calls funtion     cout << "\n Congrat!! wanna play new guess?" << endl;   cout << " \"y\"to start \"n\" to end" << endl;   cin >> response;   } while (response == 'y');  } //isCorrect returns true if the guess is right //if g does not equal a, displays hint bool isCorrect(int g, int a){  if (g == a){   return true;  }  if (g < a){   cout << &quo

Password checking program

#include <stdio.h> #include <string.h> int main() {  int i;  char candi[20] = {0};  int is_lower = 0;  int is_upper = 0;  int is_digit = 0;  int is_special = 0;   while(1){  printf("Make a password : ");  scanf("%s", candi);    for(i = 0; i < strlen(candi); i++){       if((candi[i]>='a')&&(candi[i]<='z'))     is_lower += 1;          if((candi[i]>='A')&&(candi[i]<='Z'))     is_upper += 1;          if((candi[i]>='0')&&(candi[i]<='9'))     is_digit += 1;          if((candi[i]>='!')&&(candi[i]<='/'))     is_special += 1;    }       if((is_lower >= 1)&&(is_upper >= 1)&&(is_digit >= 1)){    printf("Enough password");    return 0;   }   else if ((is_lower >= 1)&&(is_upper >= 1)&&(is_digit >= 1)&&(is_special >= 1)){    printf("St

Conditional review

#include <stdio.h> int main() {     int i;     for(i=0;i<5; i++)     {         if(!(i%2)) //only multiples of 2 is printed.         {             printf("%d", i);         }     }         return 0; }    

Review 12/06/2017

#include <stdio.h> void changeValue (int *arr, int size); //* is nessesary here int main() {     int i, arr[100]={0};     for (i=0; i<100; i++)     {      arr[i]=(i+1)*3;     changeValue (arr, 99);     printf("arr[%d]=%d \n", i, arr[i]);     }     return 0; } void changeValue (int arr[], int size) {     int i;     for (i=0; i<100; i++)     {         if((arr[i]%7==0)||(arr[i]%2==0))         {         arr[i]=0;         }     } }

Student score average and total calculation using funtion

#include <stdio.h> void returnTotalAndAvg(int *arr, float *total, float *avg); //formal parameter int main() {     float total=0, avg=0;     int num_std=0, i=0;     printf("Put the number of students.\n");     scanf("%d", &num_std);         int arr[num_std]={0};         for(i=0; i<num_std; i++)     {         printf("Put the score of student num.%d.\n", i+1);         scanf("%d", &arr[i]);         returnTotalAndAvg (arr, &total, &avg);//argument     }     printf("Total is %f, average is %f", total, avg);     return 0; } void returnTotalAndAvg(int *arr, float *total, float *avg)//formal parameter {     static int i=0;     *total=*total+*(arr+i);     *avg=*total/(i+1);     i++;     } //argument is the exact data to send to funtion. for array, only array name. //for pointer, ex)&value //for value, write a value name ^^

[C Example] Student Score Average Calculator

#include <stdio.h> //p.230 int main() {     int num_stu=1, score,i, min=1000, max=-1000;     float sum;         do     {     printf("Put a number of students(from 2 to 25) : ");     scanf("%d", &num_stu);     }         while(num_stu<=1 || num_stu>25); //if the condition inside() is false, stop     for (i=1; i<=num_stu; i++)     {         do         {         printf("\nPut the %d (st/th) student's score.\n", i);         scanf("%d", &score);         if(max<=score)    max=score;         if(min>=score)    min=score;         sum+=score;         }             while (score<0 || score>101);     }             printf("The average of student's score is %f.\n", (float)sum/num_stu);     printf("maximum : %d, minimum : %d", max,min);             return 0; }

Pythagoras theorem

#include <stdio.h>//p.228 int main() {     int height, baseline, hypotenuse;         printf("height, baseline, hypotenusev\n");     for(height=1; height<=100; height++)         {         for(baseline=1; baseline<=100; baseline++)             {                    for(hypotenuse=1; hypotenuse<=100; hypotenuse++)             {                 if((hypotenuse*hypotenuse)==baseline*baseline+height*height)                 {                     printf("%d %d %d\n", height, baseline, hypotenuse);                 }             }         }     }     return 0; }

Multiples table from 2 to 9

#include <stdio.h>// p.219 int main() {     int i, line;             for(i=2; i<=9; i++ )     {         for(line=1; line<=9; line++)         {             printf("%d*%d = %d ", i, line, i*line);         }         printf("\n"); }     return 0; }

Finding 3's multiples using while

#include <stdio.h> int main() {     int i;     int num1=1;     int num2=1;         printf("Put two number to find 3's multiples between.(numbers>0)\n");     scanf("%d %d", &num1, &num2);         i = num1;         if(num1<=0 || num2<=0)         {         printf("Put two number which are bigger than 0.\n");         scanf("%d , %d", &num1, &num2);     }             while(i<=num2)     {         if(i%3==0)         {             printf("%d ", i);         }         i++;     }         return 0; }

수열 ㅎㅎ

#include <stdio.h> //교과서 p.216 int main() {     int received, i, suyeol=0;     printf("정수를 입력하시오.");     scanf("%d", &received);         for (i=1; i<=received ; i++)     {         suyeol=i*i+suyeol;      }          printf("%d의 수열 값은 %d이다.", received, suyeol);     return 0; }

Number sum until 0 put

#include <stdio.h> int main() {     int num;     int sum=0;         printf("Put an integers to add.(put 0 to stop.)\n");         do     {            scanf("%d", &num);         sum=sum+num; }     while(num!=0);             printf("The sum of numbers is %d.", sum);     return 0; }

Matching dice 7

#include <stdio.h> int main() {     int num1, num2, dice;         for (num1=1; num1<=6; num1++)     {         for (num2=1; num2<=6; num2++)         {             if(num1+num2==7)             {                 printf("%d %d \n", num1, num2);             }         }     }     return 0; }

Finding minimum

#include <stdio.h> #include <limits.h> int main(void) {     int num, minvalue = INT_MAX;         printf("Put an integers to compare. (ctrl=z to stop)\n");         while(scanf("%d", &num) != EOF)     {         if (num < minvalue)             minvalue = num;     }     printf("The minimum value is %d", minvalue);         return 0; }

Finding aliquot using For

#include <stdio.h> int main() {        int i, received, result;     printf("Put a number to find a aliquot.\n");     scanf("%d", &received);         printf("Aloquots of %d is...\n", received);         for(i=1; i<=received; i++)     {         if(100%i==0)         {             printf("%d ", i);         }     }             return 0; }

Factorial using For

#include<stdio.h> int main() {     int i=1, received=1;     long result=1;         printf("Put an integer to factorial.\n");     scanf("%d", &received);         for(i=1; i<=received; i++)     {         result*=i;     }     printf("%d! is %d.", received, result);     return 0; }

Which integer is bigger-Min

#include <stdio.h> //Min own version int main(void) {     int num1, num2, max;         printf("Put two different integers.");     scanf("%d %d", &num1, &num2);     if(num1==num2)     {         printf("Put DIFFERENT two integer.\n");     }             else if(num1>num2)     {         printf("%d is bigger than %d\n", num1, num2);     }         else if (num1<num2)     {         printf("%d is bigger than %d\n", num2, num1);        }     return 0; }

Which integer is bigger-book

#include <stdio.h> //Text book example version int main() {     int num1, num2, max;         printf("Put two different integers.");     scanf("%d %d", &num1, &num2);         if(num1>num2)     {     max = num1;     }         else if (num1<num2)     {     max = num2;        } printf("The max is %d.\n", max);    return 0; }

Size of

#include <stdio.h> int main() {     printf("short %d\t\n", sizeof(short));     printf("int %d\t\n", sizeof(int));     printf("long %d\t\n", sizeof(long));     printf("longlong %d\t\n", sizeof(long long));     printf("float %d\t\n", sizeof(float));    //longlong (x) long long(o)     printf("double %d\t\n", sizeof(double)); //date type of sizeof = %d     printf("long double %d\t\n", sizeof(long double));     return 0; }

Relational operator examples

#include <stdio.h> //False>>0, true>>1 are printed out int main(void) {     int num1, num2;         printf("Put two integers.");     scanf("%d %d", &num1, &num2);         printf("Result of %d == %d = %d\n", num1, num2, num1 == num2); //Are they same?     printf("Result of %d != %d = %d\n", num1, num2, num1 != num2); //Are they different?     printf("Result of %d > %d = %d\n", num1, num2, num1 > num2); //Is num1 bigger than num2?     printf("Result of %d < %d = %d\n", num1, num2, num1 < num2); //Is num1 smaller than num2?     printf("Result of %d >= %d = %d\n", num1, num2, num1 >= num2);     printf("Result of %d <= %d = %d\n", num1, num2, num1 <= num2); return 0; }

Odd or even?

#include <stdio.h> int main(void) {     int num;     printf("Put the integer.");     scanf("%d", &num);         if (num==0)     printf("Put another number but not 0.\n");             else if(num%2==0)     {         printf("The integer is even.\n");     }     else if(num%2==1)     {         printf("The integer is odd.\n");     }     return 0; }

Multiplication table

#include <stdio.h> int main() {     int num=0, i=1, com=1;     printf("Put a number to see multiple table!\n");     scanf("%d", &num);     com=num;         while(i<10)     {         printf("%d * %d is %d.\n", num, i, num*i);     ++i; } return 0; }

Leap or not?

#include <stdio.h> int main() {     int year;         printf("Input the year.\n");     scanf("%d", &year);         if((year%100!= 0) && ((year%4==0) || (year%400==0 && year%100 != 100)))     {         printf("%d is a leap year.\n", year);     }         else //else if (x), if there is no more condition to attacth after one if.     {         printf("%d is not a leap year.\n", year);     }         return 0;     }

Judging score

#include <stdio.h> //broken but I don't know why.....8ㅅ8 int main() {    char credit;     printf("Input your credit.(in captical letter)");     scanf("%c", credit);         switch('credit') {         case 'A':             printf("Perfect!");             break;         case 'B':             printf("great!");             break;            case 'C':             printf("Nice!");             break;         default :             printf("Is it a CREDIT...?!\n nah kidding, do your best next time!");             break; }     return 0; } //I don't want to judge anyone's score but my text book does :'(

Finding multiples

#include <stdio.h> int main() {    int num, i=0, multiples=0, limit;     printf("Put a number.\n");     scanf("%d", &num);     printf("Between 1 and\n");     scanf("%d", &limit);     while (i<=limit)     {    i++;         if(i%num==0)         {         multiples+=i;            }         ;     }         printf("Sum of all multiples of %d between 1 and %d is %d", num, limit, multiples);     return 0; }

[C Example]Factorial

#include <stdio.h> int main() {     int i=1,num=0, sum=1;     printf("Put a number to do factorial\n");     scanf("%d", &num);         while(i<=num) {     sum*=i;     ++i; }     printf("result is %d",sum); //,value0     return 0; }

Euro change calculator

#include <stdio.h> //change calculator int main(void) {     int price;     int money;     int change;     printf("Put the total price of product.");     scanf("%d", &price);     printf("Put received money");     scanf("%d", &money);     change=money-price;     if (change>0)     {         printf("500euro = %d\n", change/500);         printf("200euro = %d\n", change%500/200);         printf("100euro = %d\n", change%500%200/100);         printf("50euro = %d\n", change%500%200%100/50);         printf("20euro = %d\n", change%500%200%100%50/20);         printf("10euro = %d\n", change%500%200%100%50%20/10);         printf("5euro = %d\n", change%500%200%100%50%20%10/5);     }         else if (change==0)     {     printf("no change is needed.\n");     }         else if (change<0)     {         printf("payment error.\n");     }         return 0; }

Days of months

#include <stdio.h> int main() {     int month, days;         printf("Put the month.");     scanf("%d", &month);         switch(month) //switch(the name of the value {         case 4:     case 6:     case 9:     case 11:         days = 30;         break;         case 2 :         days = 28;         break;                 default :         days = 30;         break; }     printf("Total days of %d is %d",month, days);     return 0; }

Conditional - volume comparing

#include <stdio.h> int main() {     int num1, num2;         printf("Put two integers to compare.\n");     scanf("%d %d", &num1, &num2);         printf("Bigger number is %d\n", (num1>num2)?num1:num2);      printf("Smaller number is %d\n", (num1<num2)?num1:num2); //(condition)?true/false to be printed     return 0;      }

Check your score!! (if practice)

#include <stdio.h> int main() {     int score;         printf("Input your score.");     scanf("%d", &score);         if(score>=90)     {         printf("A");     }         else if(score>=80)     {         printf("B");     }     else if(score>=70)     {         printf("C");     }            else if(score<70)     {         printf("Fail");     }     return 0;     }

Celsious to fahrenheit cal

#include <stdio.h> //change calculator int main(void) {     float celsious;     float fahrenheit;         printf("Put the celsious tempt.");     scanf("%f.", &celsious);         fahrenheit=celsious*(float)9/5+32;         printf("fahrenheit temp is %f", fahrenheit);         return 0; }

Arithmetic operator calculator

#include <stdio.h> int main() {     int num1, num2, expr;     char oper;         printf("Put an expression");     scanf("%d %c %d", &num1, &oper, &num2);         if(oper=='+') //charactor must be blocked by single quotes. ''     {     expr=num1 + num2;     }         else if(oper=='-')     {     expr=num1 - num2;     }         else if(oper=='/')     {     expr=num1 / num2;     }         else if(oper=='*')     {     expr=num1 * num2;     }         printf("%d %c %d is %d", num1, oper, num2, expr);         return 0; }

Area and perimeter calculator

#include <stdio.h> int main() { double r=0; double perimeter=0; double PI=3.14; double area;     printf("Put a radious");     scanf("%lf", &r);         area=PI*r*r;     perimeter=PI*2.0*r;         printf("Area of the circle is %lf.\n", area);     printf("Perimeter of the circle is %lf.\n", perimeter);     return 0;    }

Adding until the count

#include <stdio.h> p.197 int main() { int i=0,count,total=0, value=0;     printf("How much times you want to add?");     scanf("%d", &count); do {     printf("put that number~!\n");     scanf("%d", &value);     total+=value;     ++i; } while (i<count);     {     printf("%d times of added sum is %d.", count, total); }     return 0;    }

Adding from x to y

#include <stdio.h> int main() {     int i=0,num1=0, num2=0, sum=0;     printf("Put the first number and last number to add.\n");     scanf("%d %d", &num1, &num2);     i=num1;         while(i<num2+1) {        sum+=i;     ++i; }     printf("Sum from %d to %d is %d", num1, num2, sum);     return 0; }