You are on page 1of 6

Task no 3:

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(void)
{
printf("\nraheel ahmed\n");
printf("\n16fbscsm057\n");
printf("\nsection: 2b\n");
int array[100], maximum, size, c, location = 1;
printf("\nEnter the number of elements in array\n");
scanf("%d",&size);
printf("Enter %d integers\n", size);
for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[c]);
maximum = array[0];
for ( c = 1 ; c < size ; c++ )
{
if ( array[c] > maximum )
{
maximum = array[c];
location = c+1;
}
}
printf("Maximum element is present at location number %d and it's value is %d.\n",
location, maximum);
getch();
}
Task no 4:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
printf("\nraheel ahmed\n");
printf("\n16fbscsm057\n");
printf("\nsection: 2b\n");
int array[100], maximum, size, c, location = 1;
printf("\nEnter the number of elements in array\n");
scanf("%d",&size);
printf("Enter %d integers\n", size);
loop:
for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[c]);
maximum = array[0];
for ( c = 1 ; c < size ; c++ )
{
if ( array[c] > maximum )
{
maximum = array[c];
location = c+1;
}
}
printf("Maximum element is present at location number %d and it's value is %d.\n",
location, maximum);
goto loop;
getch();

}
Task no 1:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{ int DATA[10]={45,65,13,33,22,77,55,23,43,57};
int N,LOC,MAX,K;
N=10;
K=0;
LOC=0;
MAX=DATA[0];
system("cls");
loop:
K=K+1;
if(K==N)
{
printf("\nraheel ahmed\n");
printf("\n16fbscsm057\n");
printf("\nsection: 2b\n");
printf("LOC=%d, MAX=%d", LOC,MAX);
getch();
//exit();
}
if(MAX<DATA[K])
{
LOC=K;

MAX=DATA[K];
}
goto loop; }
Task no#2
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
int DATA[10] = {22,65,1,99,32,17,74,49,33,2};
int N, LOC, MAX, K;
N = 10;
K = 0;
LOC = 0;
MAX = DATA[0];
system("cls");

while ( K < N)
{
if ( MAX < DATA[K] )
{
printf("\nraheel ahmed\n");
printf("\n16fbscsm057\n");
printf("\nsection: 2b\n");
LOC = K;
MAX = DATA[K];
}
K = K+1;
}
printf ("LOC = %d, MAX = %d", LOC,MAX);
getch();
}

You might also like