NEW
Font size
WorksheetsC Programming
Total questions: 20
Worksheet time: 8mins
What is a pointer in C and how is it declared?
A pointer in C is simply a variable that holds a string.
A pointer in C is declared using the syntax 'type *pointerName;'. For example, 'int *ptr;' declares a pointer to an integer.
A pointer in C is declared with the syntax 'pointerName : type;'.
A pointer in C is declared using 'type &pointerName;'.
Explain the concept of dynamic memory allocation in C.
Dynamic memory allocation in C is done using static arrays.
Dynamic memory allocation in C is managed automatically by the compiler.
Dynamic memory allocation in C is the process of allocating memory at runtime using functions like malloc and free, allowing for flexible memory management.
Memory allocation in C is only possible at compile time.
Explain how to pass a pointer to a function in C.
You must declare the function without any parameters.
You declare the function with a pointer parameter and pass the address of the variable.
Pointers cannot be used as function parameters in C.
You can only pass variables by value in C.
How can you check if a file has been opened successfully in C?
Check if the file size is greater than zero.
Verify the file extension matches the expected type.
Ensure the file is located in the correct directory.
Check if the file pointer is NULL after fopen().
Find error/ output in following code
How many times " placement Questions" will print.
int main
{
int x;
for ( x=1;x <=10; x++)
{
if ( x < 5)
Continue;
else
break;
Printf (" placement Question ");
{
return 0;
}
Infinite time
11 times
0 time
10 times
Find error/ output in following code
int main ()
{
Static int num = 8;
printf ( " %d" , num = num -2 );
if (num != 0)
main ();
}
8 6 4 2
4 6 8 0
2 4 6 0
6 4 2 0
Find the output in following code
int main ()
{
int a,b ;
a= b= 4 ;
b =a++;
Printf ( " %d %d %d %d", a++, --b, ++a, b--);
}
5 3 73
5 4 5 3
6 2 6 4
6 3 7 4
What is the Priority among (*, /, %), (+, -) and (=) C Operators.?
(*, /, %) > (+, -) < (=)
(*, /, %) < (+, -) < (=)
(*, /, %) > (+, -) > (=)
(*, /, %) < (+, -)
Who invented C programming language ?
Thompson Ritchie
Dennis Gosling
Dennis Ritchie
James Thompson
How many number of pointer (*) does C have against a pointer variable declaration?
1
2
3
None of these
#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}
12
8
4
0
#include <stdio.h>
num birds {SPARROW, PEACOCK, PARROT};
num animals {TIGER = 10, LION =15, RABBIT=11, ZEBRA=12};
int main()
{
num birds m = TIGER;
int k;
k = m;
printf("%d\n", k);
return 0;
}
10
11
12
15
#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
if (a > b && a > c)
printf("%d", a);
else if (b > a && b > c)
printf("%d", b);
else
printf("%d", c);
return 0;
}
0
1
2
3
#include <math.h>
int main()
{
double principal = 2300;
double rate = 7;
double time = 4;
double amount
= principal * ((pow((1 + rate / 100), time)));
double CI = amount - principal;
printf("Compound Interest is : %lf", CI);
return 0;
}
712.456
713.598
714.830
715.563
#include <math.h>
#include <stdio.h>
int main()
{
int N = 102301;
int ans = 0;
int i = 0;
while (N != 0) {
if (N % 10 == 0)
ans = ans + 1 * pow(10, i);
else
ans = ans + (N % 10) * pow(10, i);
N = N / 10;
i++;
}
printf("%d", ans);
return 0;
}
112310
112311
112334
112312
#include <stdio.h>
int main()
{
int arr[5] = { 15, 25, 35, 45, 55 };
printf("Element at arr[2]: %d\n", arr[2]);
printf("Element at arr[4]: %d\n", arr[4]);
printf("Element at arr[0]: %d", arr[0]);
return 0;
}
Element at arr[1]: 45
Element at arr[2]: 25
Element at arr[0]: 15
Element at arr[2]: 33
Element at arr[3]: 55
Element at arr[0]: 45
Element at arr[2]: 35
Element at arr[3]: 55
Element at arr[1]: 15
Element at arr[2]: 35
Element at arr[4]: 55
Element at arr[0]: 15
#include <stdio.h>
#include <string.h>
struct student {
char name[20];
int roll_no;
char address[50];
char branch[50];
};
int main()
{
struct student obj;
strcpy(obj.name, "sridharan ");
obj.roll_no = 29;
strcpy(obj.address, " kesari puram ");
strcpy(obj.branch, "Computer Science And Engineering");
printf("Name: %s\n", obj.name);
printf("Roll_No: %d \n", obj.roll_no);
printf("Address: %s\n", obj.address);
printf("Branch: %s", obj.branch);
return 0;
}
name: sridharan
Roll_No: 29
Address: kesari puram
Name: sridharan
Roll_No: 29
address: kesaripuram
Name: sridharan
roll_No: 29
Addres: kesari puram
Name: sridharan
Roll_No: 29
Address: kesari puram
Input/output function prototypes and macros are defined in which header file?
conio.h
stdlib.h
stdio.h
dos.h
Output :
37 53
38 64
34 56
What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 2000?
2002
2035
2047
2052
