Dek-D.com ใช้คุกกี้เพื่อพัฒนาประสบการณ์ของ
ผู้ใช้ให้ดียิ่งขึ้น เรียนรู้เพิ่มเติมที่นี่
ยอมรับ

รบกวนเขียน Flowchart จากโปรแกรมภาษาซี 6 ข้อค่ะ

ตั้งกระทู้ใหม่
ตั้งกระทู้ใหม่
ข้อ 1. เขียนโปรแกรมที่ให้ผู้ใช้พิมพ์ตัวเลข N ที่เป็นจำนวนเต็มและคำนวณผลรวมของค่าจาก 6 ยกกำลัง 3 ไปยัง N กำลัง 3
#include<stdio.h>
#include<conio.h>
int main(){
    int n;
    int sum=0;
    printf("\nEnter number: ");
    scanf("%d",&n);
    if(n<=6){
    for(int i=6; i>=n; i--){
    sum += (i*i*i);
    }
}
    if(n>6){
    for(int i=6; i<=n; i++){
    sum += (i*i*i);
    }
}
    printf("Sumary: %d",sum);
    return 0;
}
--------------------------------------------------
ข้อ 2. เขียนโปรแกรมให้ผู้ใช้พิมพ์เลขจำนวนเต็มระหว่าง 0 และ 20 และคำนวณ N+24 ถ้าผู้ใช้พิมพ์ค่าผิดให้โปรแกรมพิมพ์คำว่า "ERROR" และสามารถพิมพ์ค่าอื่น
#include<stdio.h>
#include<conio.h>
int main()
{
    int num,y;
    printf("\nPrint the number: ");
    scanf("%d",&num);
    if(num>=0&&num<=20){
    printf("\nPrint the number: ");
}
    else{
    printf("\nERROR");
}
    y=num+24;
    printf("%d",y);
getch();
return 0;
}
---------------------------------------------------
ข้อ 3 เขียนโปรแกรมให้ผู้ใช้พิมพ์เลขจำนวนเต็มและคำนวณเลขจำนวณเต็ม โปรแกรมจะคำนวณตามเมนูต่อไปนี้
1. Multiply by 6
2. Subtract 2
3. Add 5
4. Quit
โปรแกรมให้ผู้ใช้พิมพ์ค่าระหว่าง 1 ถึง 4 หากผู้ใช้พิมพ์ค่าตั้งแต่ 1 ถึง 3 การดำเนินการคำนวณ, จำนวนเต็มจะถูกเขียนและเมนูจะปรากฏขึ้นอีกครั้ง หากผู้ใช้เลือกเมนู 4, โปรแกรมจบการทำงาน
#include<stdio.h>
#include<conio.h>
void main()
{
    int input,x,y,sum=0;
    clrscr();
    printf("Please Enter Valur Number 1\n");
    scanf("%d",&x);
    printf("Please Enter Valur Number 2\n");
    scanf("%d",&y);

    printf("\n\n\nPlease Select Your Number 1-4\n");
    printf("1.Multiply (number1*number2)\n2.Subtract (number1-number2)\n3.Add (number1+number2)\n4.Quit\n\n\n\n\n\n");
    scanf("%d",&input);
    switch(input)
    {
    case 1: sum=x*y;
    printf("Miltiply = \t%d",sum);
    break;
    case 2: sum=x-y;
    printf("Subtract = \t%d",sum);
    break;
    case 3: sum=x+y;
    printf("Add = \t%d",sum);
    break;
    case 4: break;
    }
    getch();
    }
---------------------------------------------------
ข้อ 4. เขียนโปรแกรมที่ให้ผู้ใช้กรอกข้อมูลจำนวนเต็มบวก เมื่อผู้ใช้พิมพ์จำนวนเต็มลบให้แสดงคำว่า "ERROR" และให้ผู้ใช้พิมพ์จำนวนเต็มบวกอื่น เมื่อผู้ใช้พิมพ์ค่า 0 ซึ่งหมายความว่าค่าสุดท้ายได้รับการพิมพ์และโปรมแกรมจะต้องคำนวณค่าเฉลี่ย ของจำนวนเต็มบวก หากผู้ใช้พิมพ์ค่า 0 ลงไปเป็นตัวแรก โปรแกรมจะแสดง "NO AVERAGE"
#include<stdio.h>
#include<conio.h>
int main()
{
    float x,y,z,mean;
    printf("\nPrint the number: ");
    scanf("%f",&x);
    printf("\nPrint the number: ");
    scanf("%f",&y);
    printf("\nPrint the number: ");
    scanf("%f",&z);
    if(x>0){
    printf("\nPrint the number: ");
}
    else{
    printf("\nNO AVERAGE");
}
    if(y<0){
    printf("\nERROR");
}
    if(z<0){
    printf("\nERROR");
}
    mean=(x+y+z)/3;
    printf("\nMean of value = %f",mean);
    getch();
    return 0;
}
---------------------------------------------------
ข้อ 5 เขียนโปรแกรมที่ให้ผู้ใช้สามารถพิมพ์ค่าของ Num แล้วแสดงตามภาพนี้
ถ้าพิมพ์ Num = 1
แสดง *

ถ้าพิมพ์ Num = 2
แสดง **
*

ถ้าพิมพ์ Num = 3
แสดง ***
**
*
#include<stdio.h>
main(){
    printf("Enter integer :");
    int row,i,j;
    scanf("%d",&row);
    for(i=0; i<row; i++){
    for(j=0; j<row - i; j++){
    printf("*");
    }
    printf("\n");
    }
    return 0;
    }
---------------------------------------------------
ข้อ 6 เขียนโปรแกรมที่ให้ผู้ใช้พิมพ์จำนวนเต็ม 10 จำนวน และแสดงค่าที่มากที่สุด
#include<stdio.h>
#include<conio.h>
int count[10],max=0;
main()
{
    for(int i=0; i<10; i++)
    {
    printf("\nEnter number: ");
    scanf("%d",&count[i]);
    if(count[i]>max)
    max=count[i];
    }
    printf("\nMax = %d",max);
    getch();
    return 0;
}

รบกวนด้วยค่ะ ไม่มีเวลาดูจริงๆ ขอบคุณค่ะ

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

>

1 ความคิดเห็น

... 22 มิ.ย. 55 เวลา 23:07 น. 1

ว่าจะเข้ามาช่วยนะแต่เห็นโจทย์แล้วไม่ใช่ว่าจะยากไรนะแปปเดียวก็ได้ เอาเวลาติดตามกระทู้ไปทำเองเหอะ

0