Join Us on Facebook Follow us on Twitter Add to Circles

Sunday, December 28, 2014

Ex7:សរសេrរថ្មីដើម្បីធ្វើការជំនួស statement for


គេមានកម្មវិធីតូចមួយដូចខាងក្រោម៖
សរសេរcode ជំនួសដោយប្រើ

a) ប្រើ statement do… while
b) while…
ដើម្បីធ្វើការជំនួស 





Code
a) #include<stdio.h>
#include<conio.h>
Void main()
{
Int i=0,n,m,sum=0;
Printf(“Enter m=”);scanf(“%d”,&m);
Do
{
Printf(“Enter n=”);scanf(“%d”,&n);
Sum+=n;i+=1;
}while(i<m);
Printf(“sum=%d”,sum);
Getch();
}
b) .#include<stdio.h>
.#include<conio.h>
.void main()
.{
.int n,m,sum=0;
.printf(“Enter m=”);scanf(“%d”,&m);
.while(i<m)
.{
.printf(“Enter n”);scanf(“%d”,&n);
.sum+=n;i+=1;
.}
.printf(“sum=%d”,sum);
.getch();

}




No comments:

Post a Comment