Join Us on Facebook Follow us on Twitter Add to Circles

Sunday, December 28, 2014

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


គេមានកម្មវិធីតូចមួយដូចខាងក្រោម

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

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








+Code
a) #include<stdio.h>
#include<conio.h>
void main()
{clrscr();
int i,n,sum=0;
do
{
printf("Enter n=");scanf("%d",&n);
sum+=n;i+=1;
}while(i<4);
printf("sum=%d",sum);
getch();
}

b) #include<stdio.h>
#include<conio.h>
void main()
{clrscr();
int n,sum=0;int i=0;
do
{
printf("Enter n=");scanf("%d",&n);
sum+=n;i+=1;
}while(i<4);
printf(" sum=%d",sum);
getch();

}

 

No comments:

Post a Comment