Вы находитесь на странице: 1из 7

Section A

1. float V;
const float 𝑛 = 3.142;
int r;

printf(“enter value for r : “);


scanf(“%d”,&r);
V = (4/3)* n * pow(r,3);

printf(“Volume = %.3f”, V);

2. #include<stdio.h>
void main()
{
int ball[100];
int red=0;
int blue=0;
char color;
int count=0;

while (count<5)
{
printf("Enter ball color, R for RED Or B for BLUE : ");
scanf(" %c", &color);

if (color=='R')
red=red+1;
if (color == 'B')
blue=blue+1;

count++;
}
printf("RED = %d, BLUE = %d", red, blue);
}
3.
BEGIN

ENTER PETROL REFILL IN LITRES


(-1 TO END)

WHILE (LITRE!=-1)

ENTER DISTANCE IN KM

MILEAGE PERFORMANCE = KM/LITRE

TOTAL MILEAGE PERFORMANCE += MILEAGE PERFORMANCE

COUNT++

ENTER PETROL REFILL IN LITRES


(-1 TO END)

AVERAGE MILEAGE PERFORMANCE =

TOTAL MILEAGE PERFORMANCE / COUNT

PRINT AVERAGE MILEAGE


PERFORMANCE

END
4 (a) char letter [ 5 ] = { “N”, “S”, “E”, “A”, “W”};

4 (b) int number [ 9 ] = {1,4,7,10,13,16,19,22,25};

4 (c) int matrix [3][4];

5 (a) struct footBallPlayer


{ char name [25];
int yearsofexperience;
int age;
int weight;
};

5 (b) struct footBallPlayer


{ char name [25];
int yearsofexperience;
int age;
int weight;
} player [6];

5 (c) for (i=0; i<6; i++)


{
printf (“Name: “);
scanf (“%s”, &player[i].name);
printf (“Years of Experience: “);
scanf (“%d”, &player[i].yearsofexperience);
printf (“Age: “);
scanf (“%d”, &player[i].age);
printf (“Name: “);
scanf (“ %d”, &player[i].weight);
}
6 (a)

BEGIN

READ SECOND(S)

HOURS=SECOND/3600

BALANCEHOUR = SECOND%3600

MINUTES=BALANCEHOUR/60

SECONDS=BALANCEHOUR%60

PRINT HOURS : MINUTES : SECONDS

END

6 (b)

void convertFromSecond (int Second)


{
int hour, bal, minute;
printf("Second : ");
scanf("%d", &second);
hour=second/3600;
bal=second%3600;
minute=bal/60;
second=bal%60;
printf("Hour : %d, Minute : %d, Second : %d", hour, minute, second);
}
7

#include<stdio.h>

void main()
{

int scienceScore[]={15,18,12,15,17,9,12,16};
int average,eqcount=0,count=0,total=0,i,j,k;
printf("scienceScore[]={15,18,12,15,17,9,12,16} \n");

for(i=0; i<8; i++)


{
total=total+scienceScore[i];
}
average=total/8;
printf("Average : %d\n", average);

for(j=0; j<8; j++)


{
if (scienceScore[j]<average)
count++;
}

printf("Number of array elements that has the value less than average : %d \n",count);

for(k=0; k<8; k++)


{
if (scienceScore[k]==average)
eqcount++;
}

if (eqcount!=0)
printf("Yes, the same value exists!");
else
printf("No, the same value does not exist!");
}

Вам также может понравиться