NEW
Font size
WorksheetsC program
Total questions: 54
Worksheet time: 27mins
What is a structure in C programming?
A user-defined data type that allows you to combine data items of different types
A type of loop in C programming
A built-in function in C programming
A special character in C programming
The for loop in C can only be used when the number of iterations is known in advance
False
True
What will be output?
int i=10;
int *p;
p=&i;
i+=5;
i=10, *p=10
i=15, *p=10
i=10, *p=15
i=15, *p=15
#include <stdio.h>
void fun(int*p){
*p=10;
}
int main(){
int x=5;
fun(&x);
printf("%d", x);
return 0;
}
address
error
10
5
If 2 strings are identical then what will function strcmp() returns?
-1
True
0
none of these
Comments in C are ignored by the compiler and do not affect program execute
True
False
What is the EXACT output from this code fragment?
int num=10;
if (num > 7 % 3 / 2 * 3);
printf("This is True");
else;
printf("This is False");
return 0;
This is True
This is False
How would you get the value "6" out of the following array?
int a [][]={{2;4;6;8} , {1;2;3;4}}
a[0][2]
a[2][0]
a[3][1]
a[1][3]
a[0][3]
How do you compare 2 strings in C?
strcmp(str1,str2)
str1.compare(str2)
str1 == str2
compare(str1,str2)
The modulus operator cannot be used with a long double
False
True
A pointer must be initialized before it is dereferenced
False
True
What will be printed after Execution of the following program?
void main()
{
int a[5]={11,13,56,20,5};
a[2]=?
13
56
20
null value
Each piece of data in an array is BEST described as a what?
Item
Elephant
Integer and string
Element
What would be the size of the following union declaration? (Assuming size of double=8, int=4, char=1)
#include <stdio.h>
union uTemp
{
double a;
int b[10];
char c;
8
4
40
80
The "=" operator is used for comparison in C
False
True
The "printf()" function is used to read input from the keyboard
False
True
The "const" keyword is used to declare variables whose values cannot be changed
False
True
What symbol is used in conditional operators for AND
AND
&&
&
The fastest data access is provided using ____
DRAM's
Caches
SRAM's
Registers
Arrays in C store elements in continuous memory locations
False
True
Local variables are accessible throughout the entire program
False
True
Given the code, what is in values [2][1]?
double [][] values = {{1.2,9.0,3.2},{9.2,0.5,-1.2},{7.3,7.9,4.8}}
0.5
7.3
9.2
7.9
How do you declare a structure variable of type "Student" in C?
struct Student studen1;
Student student1;
Student = student1;
int student1;
What is the output of the following printf?
int a=6,b=8;
printf("%d",a^b);
8
0
6
14
In C, strings are a built-in data types
False
True
How do you access the member variables of a structure in C?
Using the dot (.) operator
Using the asterisk (*) operator
Using the plus (+) operator
Using the hash (#) operator
The while loop checks its condition after executing the loop body
True
False
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int a=5, b=-7, c=0, d;
d=++a && ++b ll ++c;
printf("\n%d%d%d%d", a, b, c, d);
}
-6 -6 0 1
6 -6 0 0
6 -6 0 1
6 -5 0 1
Consider the declaration
char x[]="Applied_Informatics";
char *y="Applied_Informatics";
The output of puts(x) and puts(y) will be
Different
Will be the same
Error
Not related
What will be the output of the C program?
#include <stdio.h>
int main()
{
Compilation on error
1
2
25
Every C program must contain a main() function
True
False
Which line of code is correct for the statement: Add 1 variable to x
x+1
x+x
x++;
The "printf()" function automatically adds a newline character after printing output
False
True
What is right way to initialize array?
int n{} = {2,4,12,5,45,5};
int n(6) = {2,4,12,5,45,5};
int n{6} = {2,4,12};
int num[6] = {2,4,12,5,45,5};
Which BEST describes an array?
A data structure - Stores a collection of values under one name
A list - Stores a list of strings
A list - Stores a list of numbers
A data collection - Stores a structure of values under one
What will be the output of the C code?
#include <stdio.h>
int maint()
{
printf("Hello World! %d\n", x);
return 0;
}
Hello World! followed by a junk value
Hello World!
Hello World! x;
Compile error
A global variable is automatically initialized to zero if not explicitly initialized
True
False
Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
arr[7]
arr{7}
arr{6}
arr[6]
In C, function arguments are passed by value by default
True
False
What is the significance of the 'sizeof' operator in relation to structures in C?
It is used to determine the size of a structure in bytes
It is used to determine the color of the structure
It is used to calculate the sum of elements in a structure
It is used to find the maximum value in a structure
What is the value of this expression using integer arithmetic:
7/4
2
1.75
1
The 'sizeof' operator returns the size of a variable or data type in bytes
True
False
A variable declare as "int *p"; can store the address of an integer variable
True
False
____ is the user-defined datatype
float
int
array
enum
What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *s = "hello";
char *p = s;
printf("%c\t%c", p[0], s[1]);
}
h h
Run time error
h e
h l
What will be printed on the screen from this fragment:
int num=0;
printf("%d", ++num);
1
2
0
A segmentation fault can occur if a program accesses invalid memory
False
True
what is the value of y?
int x=5;
y=x++;
6
0
4
5
Toán tử tam phân nào dưới đây là đúng để tìm số lớn nhất giữa a và b?
max = (a > b) : a ? b;
if (a > b) ? a : b;
max = (a > b) ? a : b;
max = a > b ? b : a;
Biểu thức (8 >> 2) có kết quả bằng bao nhiêu?
32
2
4
0
Kết quả của phép toán (5 ^ 5) là bao nhiêu?
0
1
10
5
Giá trị của x sau khi thực hiện: int x = 10; x >>= 1;
9
20
1
Nếu x = 6 (110) và y = 3 (011), kết quả của x ^ y là bao nhiêu?
4
7
5
2
Biểu thức (a += b) tương đương với cách viết nào?
b = b + a
a + b = a
a = a + b
a = b
