In: Computer Science
/*----------------------------------------------------------------------\
|psuedo code:
|
| sem := 50 (max marks of sem)
|
| final := 100 (max marks of final twice of
semester) |
|
|
| i := 0
|
| while i<15:
|
| testscore[i] := get the value of
test score |
| i := i + 1
|
|
|
| loop over i=0 for 15 times to add score:
|
| total := total +
testscore[i]
|
|
|
| avg := total / 15
|
|
|
| return avg
|
|----------------------------------------------------------------------*/
#include<stdio.h>
int main(){
int i=0, j=0;
float maxsem = 50;
float score[15], avg, total=0;
while(i<15){
printf("Enter test score for test
%d: ", i+1);
scanf("%f", &score[i]);
if(score[i]>maxsem &&
i<14){
printf("Max.
score for sememster test is 50.\n");
}
else if(score[i]>(2*maxsem)
&& i==14){
printf("Max.
score for final test is 100.\n");
}
i++;
}
while(j<15){
total += score[j];
j++;
}
avg = total/i;
printf("Average score: %.2f\n", avg);
return 0;
}
/*--------------------------------------------------------------\
|psuedo code:
|
| x := get the value of x
|
| y := get the value of y
|
|
|
| if y == 0 :
|
| display("Unable to perfomr the
division") |
| else :
|
| z := x/y
|
| display("Result: z")
|
|
|
|--------------------------------------------------------------*/
#include<stdio.h>
int main(){
float x, y, z;
printf("Enter the value of x: \n");
scanf("%f", &x);
printf("Enter the value of y: \n");
scanf("%f", &y);
if (y == 0){//checking the value of Y equals to 0
or not
printf("Unable to perform the
division.\n");//display err msg
}
else{
z = x/y;//performing division
printf("X divided by Y equals :
%f\n", z);//display result
}
return 0;
}