Top Banner
Computer Programming ปปปปปปปปปปปปป ภภภภภภภภภภภภภภภภภภภภภภภภภภภ Dennis Ritchie ภภภภภ ภ.ภ. 1972 ภ ภภภภภภภภภภภภภภภภภภภภภภ ภภภภภภภภภภภภภภภภภภภภภภ UNIX ภภภภภภภภภภภภภภ ภภภภภภภภภภภภภ DEC PDP-11 ภภภภภภภภภภภภภภ ภภภภภภภภภภภภภภ B ภภภภภภภภภภภภภภภ Ken Thompon ภภภภภภภภภภภภภภภภภภภภภภภ BCPL ภภภ ภภภภภภภภภภ Martin Richards
35

Computer Programming.docx

Nov 11, 2015

Download

Documents

Aumjung Suwanan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

Computer Programming

Dennis Ritchie .. 1972 UNIX DEC PDP-11 B Ken Thompon BCPL Martin Richards

Martin Richards Ken Thom pson Dennis Ritchie

Void main() {}1. 2 2 int number1,number2,sum;

printf("please your number 1:");Scanf

#include void main(){int number1,number2,sum;printf("please your number 1:");scanf("%d",&number1);printf("please your number 2:");scanf("%d",&number2);sum = number1+number2;printf("%d + %d = %d",number1,number2,sum);}

compile &run

compile &run

Enter 2. .. . Please inser ceB.D? Int ce,543,sum;

#include void main(){int ce,ba,sum;printf("please intsert ce:");scanf("%d",&ce);sum = ce+543;printf("%d +543 = %d",ce,sum);}

compile &run

compile &run 2002 2545

3. a-z 97-122

a-z a-z 97-122

#include "stdio.h"void main (){char A = 'a';A = A + 15;printf("%c",A);}

p F11

4. // /*_______*/

Hello#include "stdio.h"void main(){char greeting[6]={ 'H','e','l','l','o','\0'};printf("Greeting message %s\n",greeting);return 0;}

5. Hello world#include "stdio.h"void main(){ char greeting[13]= "hello world"; printf("Greeting message %s\n",greeting); return 0;}

6. #include "stdio.h"//??????? include ??????????#include void main(){char s[100];printf("Input string : ");gets(s);printf("\n\nString(%s) length is (%d)\n\n",s, strlen(s));return 0;}

F11

Enter

7. x () x 1. 2 - x () x A1

h

A2

A1,A2,h,area

#include #includevoid main(){ printf("How to find the area of a trapezoid?\n"); printf("********************************************** \n"); float h,A1,A2,area; printf("Height is "); scanf("%f",&h); printf("A1 is "); scanf("%f",&A1); printf("A2 is "); scanf("%f",&A2); printf("How to do.\n"); printf("Formula=1/2*(A1+A2)*h \n"); area=(A1+A2)*h/2; printf("Area of trapezoid= %.2f",area); getch();}

#includevoid main(){float a,b,c,d,mean1;printf("input number1:");scanf("%f",&a); printf("input number2:");scanf("%f",&b);printf("input number3:");scanf("%f",&c);printf("input number4:");scanf("%f",&d);mean1=(a+b+c+d)/4;printf("%f,%f,%f,%f mean is :%f",a,b,c,d,mean1);}

F11 Enter

8. A = 100 80B+ =79 75B = 74 70C+ = 69 65C = 64 60D+ = 59 55D = 54 50

#include "stdio.h"void main(){ int score;printf("Please input your score");scanf("%d",&score);if((score>=80)&&(score=75)&&(score=70)&&(score=65)&&(score=60)&&(score=55)&&(score=50)&&(score