Recent

20 พฤศจิกายน 2560

C-การหาผลบวก 2 จำนวน


PROBLEM : การหาผลบวกของจำนวนเต็ม 2 จำนวน 
SOLVING : วิเคราะห์ปัญหา
OUTPUT : 
  1.   ผลบวก
INPUT :
  1.     จำนวนเต็ม 2 จำนวน
PROCESS :
  1. เริ่ม
  2. กำหนดให้  sum = ผลบวก
  3. กำหนดให้  x, y เป็นจำนวนเต็ม
  4. รับค่า x,y
  5. คำนวณ   sum = x+y
  6. แสดงผล  sum
  7. จบ

FLOWCHART: เขียนผังงาน



C-PROGRAM : เขียนโปรแกรม

//Program By : Krupong.net
//Program DATE : 20/11/2017
#include <stdio.h>
int main ()
{
   int x,y,ans;
  //Input
  printf("Input value x:");
  scanf("%d",&x);
  printf("Input value y:");
  scanf("%d",&y);
  //Process
  ans=x+y;
  //Output
  printf("Ans = %d",ans);
}


Download
http://www.codeblocks.org/downloads/26

0 ความคิดเห็น:

แสดงความคิดเห็น