Professional Documents
Culture Documents
1DArray 1
1DArray 1
c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9]
c 79 87 94 82 67 98 87 81 74 91
77 56 4 10 34 2 Original array
56 4 10 34 2 77 After pass 1
4 10 34 2 56 77 After pass 2
4 10 2 34 56 77 After pass 3
4 2 10 34 56 77 After pass 4
2 4 10 34 56 77 After pass 5
#include <stdio.h>
int main() printf("Resultant array
{
int array[100], position, c, n, value; is:\n");
printf("Enter number of elements in array:\n");
scanf("%d", &n); for (c = 0; c <= n; c++)
printf("Enter %d elements:\n", n);
for (c = 0; c < n; c++) {
{
scanf("%d", &array[c]);
}
printf("%d\n", array[c]);
printf("Enter the location where you wish to insert an
element:\n");
}
return 0;
scanf("%d", &position);
printf("Enter the value to insert:\n");
scanf("%d", &value);
}
for (c = n - 1; c >= position - 1; c--)
{
array[c+1] = array[c];
} •
array[position-1] = value;
scanf("%d", &position);
}
for (c = position-1; c < n-1; c++)
{
}
}
array[c] = array[c+1];
• •
A. 5
B. 7
C. 4
D. 3
©LPU CSE101 C Programming
Q7
What will be the output of the following program?
#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i=2;
printf("%d",a[++i]);
return 0;
}
A. 15
B. 20
C. 25
D. 5
int main()
{
float marks[3] = {90.5, 92.5, 96.5};
int a=0;
while(a<3)
{
printf("%.2f ", marks[a]);
a++;
}
return 0;
}