0% found this document useful (0 votes)
14 views9 pages

05 09 23 - Class06

Amo

Uploaded by

218a1a05c3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views9 pages

05 09 23 - Class06

Amo

Uploaded by

218a1a05c3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Problem Solving Through

Programming in C
Tutorial Session 6
Prof. Anupam Basu Siddhant Mohapatra
Dept. of Computer Science & Engg. PMRF Scholar
IIT Kharagpur IIT Madras

05-09-2023
Arrays
An integer array (An integer takes two bytes of memory) of
size 15 is declared in a C program. The memory location of
the first byte of the array is 2000. What will be the location
of the 13th element of the array?

a) 2013
b) 2024
c) 2026
d) 2030

a) 20 12 14
b) 10 20 14
c) 10 12 20
d) Compiler error

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 2


Arrays

a) 3
b) 4
c) No output
a) IIT KGP d) Compilation error
b) IIT MADRAS
c) Nothing is printed
d) Compilation error

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 3


Arrays

a) 3 followed by garbage values


a) Garbage value
b) 3 0 0
b) 0
c) 3 1 1 c) 5
d) Syntax error d) 6

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 4


Arrays

a) 5
b) 6
c) 9
d) 10

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 5


Arrays
Which of the following statements finds the minimum value in an integer array named "myArray" in C?

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 6


Miscellaneous

a) 0
b) 1
c) 5
d) Runtime error

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 7


Arrays
Write a C program to delete an element from a specified location of an array.

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 8


Arrays
Write a C program to delete an element from a specified location of an array.
#include<stdio.h>
int main() {
int num, i, pos;
scanf("%d", &num); //Size of array
int array[num];
for (i = 0; i<num; i++) {
scanf("%d", &array[i]);}
scanf("%d", &pos); // Accepts the Position of the element to be deleted
while (pos<num) {
array[pos - 1] = array[pos];
pos++;}
num--; // No of elements reduced by 1 as 1 element is deleted

for (i = 0; i<num; i++)


printf("%d\n", array[i]);
return (0);}

05-09-2023 PROBLEM SOLVING THROUGH PROGRAMMING IN C 9

You might also like