1. #include <stdio.h>
{
int num[10];
int min, max;
int i;
for (i = 0; i < 10; i++)
{
printf("Enter %d numbers:\n",i+1);
}
{
{
continue;
}
max = num[i];
}
return 0;
}
int
main()
{
int i;
float no[10];
float total=0,average=0;
for(i=0;i<10;++i)
{
printf("Enter the
number : ");
scanf("%f",
&no[i]);
total+=no[i];
}
average = total/10;
printf("Total is %.2f and
Average is %.2f", total, average);
return 0;
}
3. #include<stdio.h>
int
main()
{
int i, j;
int units[3][3] = {
{500,1000,300},
{10,1800,200},
{200,400,700}
};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%3i\t
", units[i][j]);
}
printf("\n");
}
return 0;
}
3.1. #include<stdio.h>
int main()
{
int i, j,total=0;
int units[3][3] = {
{500,1000,300},
{10,1800,200},
{200,400,700}
};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
total+=units[i][j];
}
}
printf("Total
units = %i", total);
return 0;
int
units[3][3]={ {500,1000,300},{10,1800,200},{200,400,700}};
int
main()
{
int sum=0;
int x,y,z=0;
for(x=0;x<3;x++)
{
for (y=0;y<3;y++)
{
sum = sum +
units[y][z];
}
printf("%d\n",sum);
sum=0;
z=z+1;
}
return 0;
}
3.3. #include <stdio.h>
int
units[3][3]={ {500,1000,300},{10,1800,200},{200,400,700}};
int main()
{
int max=units[0][1];
int x,y;
for(x=1;x<3;x++)
{
if (max <
units[x][1])
max=units[x][1];
}
if (units[1][1]==max)
printf("person
2");
else if (max==units[2][1])
printf("person
3");
else
printf("person
1");
return 0;
}
3.4. #include <stdio.h>
int
units[3][3]={ {500,1000,300},{10,1800,200},{200,400,700}};
int main()
{
int sum=0;
int x,y,z=0;
int total[3];
for(x=0;x<3;x++)
{
for (y=0;y<3;y++)
{
sum=sum+units[z][y];
}
total[x]=sum;
z=z+1;
sum=0;
}
if (total[0]<total[1])
{
if
(total[1]<total[2])
printf("person
3");
else
printf("person
2");
}
else if (total[0]<total[2])
printf("person
3");
else
printf("person
1");
return 0;
}
3.5. #include <stdio.h>
int
units[3][3]={ {500,1000,300},{10,1800,200},{200,400,700}};
int main()
{
int sum=0;
int x,y,z=0;
int total[3];
for(x=0;x<3;x++)
{
for (y=0;y<3;y++)
{
sum=sum+units[z][y];
}
total[x]=sum;
z=z+1;
sum=0;
}
if (total[0]<total[1])
{
if
(total[1]>total[2])
printf("person
3");
else
printf("person
2");
}
else if (total[0]>total[2])
printf("person
3");
else
printf("person
1");
return 0;
}
3.6. #include <stdio.h>
int
units[3][3]={ {500,1000,300},{10,1800,200},{200,400,700}};
int main()
{
int sum=0;
int x=2,y;
for (y=0;y<3;y++)
sum=sum+units[x][y];
printf("%d",sum);
return 0;
}
0 Comments
Post a Comment