Program to accept ‘n’ numbers from user, store these numbers into anarray. Find out Maximum and Minimum number from an Array(using function).


#include<stdio.h>
#include<conio.h>
void minmax(int a[5],int n);
void main()
 {
 int a[5];
 int i,n,max,min;
 clrscr();
 printf("\n entre the limit of array");
 scanf("\n %d",&n);
 printf("\n enter the array element");
 for(i=0;i<n;i++)
  {
  scanf("\n %d",&a[i]);
  }

  minmax(a,n);
  getch();
  }
  void minmax(int a1[5],int n1)
  {
  int max,min,i;
  max=a1[0],min=a1[0];
 for(i=1;i<n1;i++)
  {
  if(a1[i]>max)
   {
   max=a1[i];
   }
   if(a1[i]<min)
   {
   min=a1[i];
   }

  }
  printf("\n the largest element is %d",max);
  printf("\n the smallest element is %d",min);
 }
/* output

 entre the limit of array5

. enter the array element 67 56 1 45 234

 the largest element is 234
 the smallest element is 1  */

Write a function is Even, which accepts an integer as parameter and returns 1 if the number is even, and 0 otherwise. Use this function in main to accept n numbers and check if they are even or odd.


#include<stdio.h>
#include<conio.h>
int iseven(int num);
void main()
 {
  int num,ans;
clrscr();
printf("\n enter the value of num");
scanf("\n %d",&num);
ans=iseven(num);
if(ans==1)
{
 printf("\n number is even");
}
if(ans==0)
{
 printf("\n number is odd");
}
getch();
}
int iseven(int num1)
{
  if(num1%2==0)
    {
return 1;
}
else
{
return 0;
}
}
/* output

 enter the value of num7
number is odd */

Scooter company has serial numbers from AA0 to FF9, the other characteristics of scooter are year of manufacture, colour, horsepower. Use a structure pointer and do the following:


Scooter company has serial numbers from  AA0  to  FF9, the other characteristics of scooter are year of manufacture, colour, horsepower. Use a structure pointer and  do the  following:
a.         Retrieve all information of scooters within a range BB0 and CC9
b.         Display the oldest scooter
  
#include<stdio.h>
#include<conio.h>
void main()
 {
 struct scooter
          {
         char srno[5];
         int year;
         char color[10];   
         int hp;
           }sc[10];
int i,ch,n;
clrscr();
while(1)
{
printf("\n 1:add scooter info");
printf("\n 2:information of scooters within a range BB0 and CC9");
printf("\n 3:Display the oldest scooter");
printf("\n 4:exit");
printf("\n enter the choice");
scanf("\n %d",&ch);
switch(ch)
{
 case 1:
            printf("\n how many record u add");
                scanf("\n %d",&n);
                                                  for(i=0;i<n;i++)
                                                            {
                                                            printf("\n enter sr no");
                                                            scanf("\n %s",&sc[i].srno);
                                                            printf("\n enter year");
                                                            scanf("\n %d",&sc[i].year);

printf("\n enter color");
            scanf("\n %s",&sc[i].color);
printf("\n enter hp");

            scanf("\n %d",&sc[i].hp);
}
break;
case 2:
for(i=0;i<n;i++)
 {
            if(sc[i].srno>="bb0" || sc[i].srno<="cc9")
{
 printf("\n srno is%s",sc[i].srno);
printf("\n year is%d",sc[i].year);
printf("\n color is%s",sc[i].color);
printf("\n hp is%d",sc[i].hp);
}
}
break;
case 3:printf("\n the oldest scooter is %c",sc[0]);

                        printf("\n srno is%s",sc[0].srno);
printf("\n year is%d",sc[0].year);
printf("\n color is%s",sc[0].color);
printf("\n hp is%d",sc[0].hp);
 break;
case 4:exit(0);
}
}
getch();
}

Write a C program to calculate the sum of following series using function.Sum=1+1/x+1/x2+1/x3+1/x4+………*/


#include<stdio.h>
#include<conio.h>
#include<math.h>
void series(int x);

void main()
{
  int x;
clrscr();
printf("\n enter the value od x");
scanf("\n %d",&x);
series(x);
getch();
}
void series(int x1)
 {
   int i,limit;
   float sum=0;
   printf("\n enter the limit");
   scanf("\n %d",&limit);
  for(i=1;i<=limit;i++)
 {
  sum=sum+(1/(pow(x1 ,i)));
}
printf("\n sum of series is %f",(1+sum));
getch();
}
/* output

 enter the value od x3
 enter the limit2

 sum of series is 1.444444 */