KEMBAR78
Cprogram Exam | PDF | Computer Programming | Software Engineering
0% found this document useful (0 votes)
6 views6 pages

Cprogram Exam

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Cprogram Exam

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Name: Phalla Sophorndara

Exercise

1. Variable ជាកន្លែងសម្រាប់ផ្ទុកទិលនល័យ។

Control statement អាចអអាយអយើងបញ្ចូលអៅstructឬLoop។

Loop statement ជាការកំណត់អអាយCode អដើរដន្ដលៗ មិលឈប់។

Function ជាBlock Code សម្រាប់អៅអេលម្រតូវការវា លិងអ្វើការជាក់លាក់។

2. Array ជាការអម្របើរកសាតម្មែអម្រចើលកនុងអអេរមួយ ជំលួសអអាយការម្របកាសអអេរដាច់អដាយន្ែកសម្រាប់

តម្មែលីមួយៗ។

លំហាត់អលុវតតល៍

១.#include<stdio.h>

int main()

int code;

char name[20];

int qty;

double price;

float total;

float payment;

int discount;

printf("Input Code : \n");


scanf("%d",&code);

printf("Input name : \n");

scanf("%s",&name);

printf("Input qty : \n");

scanf("%d",&qty);

printf("Input price : \n");

scanf("%lf$",&price);

printf("Input discount: \n");

scanf("%d",&discount);

total= qty*price;

printf("==============================================\n");

if(total>1 && total<=10)

discount=10;

else if(total>10 && total<=20)

discount=20;

else if(total>20 && total<=30)

discount=30;

else if(total>30 && total<=40)

discount=40;

else if(total>40 && total<=50)

discount=50;
else if(total>50 && total<=60)

discount=60;

else

discount=70;

payment=total-total*discount/100;

printf("==============================================\n");

printf("Code :%d\n",code);

printf("name :%s\n",name);

printf("qty :%d\n",qty);

printf("price :%.2lf$\n",price);

printf("discount :%d\n",discount);

printf("total :%.2lf$\n",total);

printf("payment :%.2lf$\n",payment);

return 0;

}
3. Pointer អម្របើសម្រាប់រកសាទុកអអេរ។

Structure អម្របើសម្រាប់ដាក់អអេរជាអម្រចើលន្ដលពាក់ពាល់គ្នាអៅកន្លែងមួយ។

4.Exercise Structure

#include<stdio.h>

struct student{

int id;

char name[30];

float Crograming;

float Math;

float English;

float Fundamental;

float khmerHistory;

float Economy;

float Average;
float total;

char grade[30];

int year;

char class[30];

};

int main()

int n, i;

printf("Please Enter Number Student \n");

scanf("%d",&n);

struct student stu[n];

for(i=0;i<n;i++){

printf("\n=============================\n");

fflush(stdin);

printf("Enter ID :");

scanf("%d", stu[n].id);

printf("Enter Name :");

scanf("%s", stu[i].name);

printf("Enter Cprogram :");

scanf("%.2lf",stu[i].Crograming);

printf("Enter Math :");

scanf("%.2lf",stu[i].Math);

printf("Enter English :");

scanf("%.2lf",stu[i].English);

printf("Enter Fundamental :");


scanf("%.2lf",stu[i].Fundamental);

printf("Enter khmerHistory :");

scanf("%.2lf",stu[i].khmerHistory);

printf("Enter Economy :");

scanf("%.2lf",stu[i].Economy);

stu[i].total = stu[i].Crograming + stu[i].Economy +stu[i].English +

stu[i].Fundamental+stu[i].khmerHistory + stu[i].Math;

stu[i].Average= stu[i].total/3.0;

return 0;

You might also like