wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PROGRAMMING IN C

Total questions: 13

Worksheet time: 7mins

Name
Class
Date
1.

is a collection of multiple data items, all of the same data type, accessed using a common name.

a)

data

b)

Array

c)

Structure

d)

pointer

2.

Eg :int arr[5]={1,2,3,4,5};

Above example is of___

a)

array

b)

declaration of array

c)

initialization of two dimentional array

d)

compile time Initialization of one dimentional array

3.

Eg : int arr[5]; for(i=0;i<5;i++) {

scanf(“%d”,&arr[i]); }

above code is example of___

a)

array

b)

two dimentional array

c)

runtime Initialization of one dimentional array

4.

Initialization can be done like : char str[4]={'x','y','z','\0'};

OR

char message[10] = "Hello";

a)

array

b)

string

c)

integer

d)

Character Array

5.

Initialization can be done like : int arr[4]={10,20,30,40};

a)

Array

b)

Integer Array

c)

character array

d)

String

6.

___array is a collection of similar type of data elements arranged in the form of rows & columns.

E.g. Array can be declared as int arr[3][3];

a)

Multi-dimensional array

b)

one dimensional array

c)

Two dimensional array

d)

string array

7.

An array with more than one dimensionis called as____

a)

string

b)

pointer

c)

array

d)

Multi-dimensional array

8.

#include <stdio.h>

struct student {

char name[20];

char c[20]; // Assuming 'c' stands for class

int per; // Assuming 'per' stands for percentage

};

int main() {

struct student s[3];

int i;

// Input loop

for(i = 0; i < 3; i++) {

printf("\nEnter details for student %d:\n", i+1);

printf("Name: ");

scanf("%19s", s[i].name); // Limiting input to prevent buffer overflow

printf("Class: ");

scanf("%19s", s[i].c);

printf("Percentage: ");

scanf("%d", &s[i].per);

// Clear input buffer

while(getchar() != '\n');

}

// Output loop

printf("\nStudent Details:\n");

printf("Name\t\tClass\tPercentage\n");

printf("--------------------------------\n");

for(i = 0; i < 3; i++) {

printf("%-15s %-10s %d%%\n", s[i].name, s[i].c, s[i].per);

}

return 0;

}

What is the purpose of the struct student definition in the program?

a)

To create a loop for student data

b)

To define a custom data type for storing student details

c)

To initialize an array of students

d)

To print student information

9.

How many student records can the array struct student s[3]; store?

a)

1

b)

2

c)

4

d)

3

10.

Declare a structure student with element roll-no and name.

a)

struct student

int roll_no;

char name[20];

b)

struct student {

int roll_no;

char name[20];

};

c)

struct student {

int roll_no;

char name[20];

}

d)

struct student {

char name[20];

};

11.

Define array. List its type..? select correct ans.?

a)

Array is a fixed-size sequential collection of elements of the same type

b)

Array is a fixed-size sequential collection of elements of the same type.

Types: 1. One dimensional

Multi dimensional

c)

Array is a fixed-size sequential collection of elements of the same type.

1. One dimensional

2.Two dimensional

3.Multi dimensional

d)

Array is a fixed-size sequential collection of elements of the same type.

1. One dimensional

12.

Define structure. Give one example of structure declaration.?select correct ans.?

a)

Definition of Structure: Structure is a collection of variables of similar or different data types which is represented by a single name.

Example:

struct bill {

int consumer_id;

char address[50];

float amount;

};

b)

Structure is a collection of variables of similar or different data types which is represented by a single name.

c)

struct bill {

int consumer_id;

char address[50];

float amount;

};

d)

struct bill {

char address[50];

float amount;

};

13.

#include <stdio.h>

int main() {

int a[5], i, sum = 0;

printf("Enter 5 array elements:\n");

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

{

scanf("%d", &a[i]);

}

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

{

sum += a[i];

}

printf("Sum = %d\n", sum);

return 0;

}

select correct output..?

a)

Enter 5 array elements:

10 20 30 40 50

Sum = 150

b)

10 20 30 40 50

Sum = 150

c)

Enter 5 array elements:

10 20 30 40 50

d)

Enter 5 array elements:

10 30 40 50

Sum = 150