You are on page 1of 2

Computer Assignment-2

Name- Ankit Kumar Sec-F


Roll no.- 19 BCE 047
Sno- 10

Q1)

#include<stdiod.h>
#include<math.h>
#include<conio.h>
void main()
{ clrscr(); int n,i; float top,p,t; printf("Enter size of
array="); //to enter size of series scanf("%d",&n);
printf("The series is:-"); for(i=1;i<=n;i++) //to
print series
{
t=(pow(3,i)); if(i==n)
printf("1/%f",t); else
printf("1/%f+",t);
} p=pow(3,n); //to print sum of
series top=(1-(1/p))/2; printf("\n\nsum of series=
%f",top); getch();
}

Q2)

#include<stdio.h>
#include<conio.h>
void main()
{ clrscr(); int a[100],n,max,min,i; printf("enter lenght of
array (maximum=100)="); scanf("%d",&n); printf("\
nenter elements of array="); for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
max=a[0]; for( i=0;i<n;i++) maximum
value
{
if(a[i]>max)
max=a[i];
}
min=a[0];
for(i=0;i<n;i++)

{ if(a[i]<min
) min=a[i];
}
printf("\nmin number entered is=%d",min); //to print max and minimum value
printf("\nmax number entered is=%d",max); getch();

You might also like