PDS Combined (1 - 30)
PDS Combined (1 - 30)
Flag question
Flag question
Question 3 Make the below integer pointer point to the integer variable a
Correct
int a;
Mark 1.00 out of
int *ptr;
1.00
Flag question
Answer: ptr=&a;
Answer: printf("%d",*ptr);
Answer: Yes
Answer: NO
No. It is not correct *ptr means the value in ptr. You have to set ptr to &a and not the value in ptr
Question 7 Write the statement to set the value of a to 7 using ptr. Not directly using a.
Correct
int a;
Mark 1.00 out of
int *ptr;
1.00
ptr = &a;
Flag question
Answer: *ptr=7;
Question 8 What is the output of this program. If you think answer is an error type "ERROR"
Correct
#include <stdio.h>
Mark 1.00 out of
int main()
1.00
{
Flag question
int a,*ptr;
ptr = &a;
a = 3;
*ptr = 7;
printf("%d",a);
Answer: 7
Question 9
What is the output of this program. If error type error
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int main()
{
Flag question
int a,*ptr;
ptr = &a;
a = 3;
*ptr = 7;
printf("%d",*&*ptr);
Answer: 7
* and & cancel each other out. So *ptr is what gets printed
d. reverse
e. porting
Flag question
For example:
Input Result
7 8
Reset answer
1 #include <stdio.h>
2 int main()
3 ▼ {
4 int a;
5 int *ptr = &a;
6 scanf("%d", &a);
7 (*ptr)++;
8 printf("%d",a);
9 return 0;
10 }
7 8 8
8 9 9
Correct
Marks for this submission: 10.00/10.00.
Question 12
& is called the address operator
Correct
Flag question
Question 14 What is the output for this program if input is given as 3? If error, type ERROR
Correct
Answer: 3
Question 15 What is the output of the program if input is given as 3? If error type ERROR
Correct
#include <stdio.h>
Mark 1.00 out of
int main()
1.00
{
Flag question
int a,*ptr;
ptr = &a;
scanf("%d",*ptr);
printf("%d",a);
}
Answer: ERROR
Question 16
What is the output of this program. If error type error
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int main()
Flag question
{
int a,*ptr;
ptr = &a;
a = 3;
*ptr = 7;
printf("%d",*&*ptr);
}
Answer: 7
Finish review
SIET LMS
Answer: ptr=&i;
Question 2 Size of character and size of integer is the same. TRUE or FALSE
Correct
YES. They are different. Character is 1 byte and integer is 2 or 4 bytes depending on the computer
Yes. Both pointers store the address. Hence they are same size.
Question 4
1. #include <stdio.h>
Correct
2. int main()
Mark 1.00 out of
3. {
1.00
4. int i;
Flag question
5. int *ptr;
6. ptr = &i;
7. i = 10;
8. printf("%d",ptr);
9. return 0;
10. }
Answer: NO
Question 5
1. #include <stdio.h>
Correct
2. int main()
Mark 1.00 out of 3. {
1.00
4. int i;
Flag question
5. int *ptr;
6. ptr = &i;
7. i = 1.4;
8. printf("%d",*ptr);
9. return 0;
10. }
Answer: 1
Question 6
1. #include <stdio.h>
Correct
2. int main()
Mark 1.00 out of 3. {
1.00
4. int i;
Flag question 5. int *ptr;
6. int *ptr1;
7. ptr = &i;
8. ptr1 = ptr;
9. *ptr1 = 2.2;
10. printf("%d",*ptr);
11. return 0;
12. }
13. What is the output of the program?
Answer: 2
Question 7
1. #include <stdio.h>
Correct
2. int main()
Mark 1.00 out of 3. {
1.00
4. int i;
Flag question
5. int *ptr;
6. int *ptr1;
7. ptr = &i;
8.
9. ptr1 = ptr;
10.
11. *ptr1 = 3.3;
12. (*ptr1)++;
13. printf("%d",*ptr);
14. return 0;
15. }
Answer: 4
Question 8
1. #include <stdio.h>
Incorrect
2. int main()
Mark 0.00 out of 3. {
1.00
4. int i;
Flag question
5. int *ptr;
6. int *ptr1;
7. ptr = &i;
8.
9. ptr1 = ptr;
10.
11. *ptr1 = 7.8;
12. *ptr1++;
13. printf("%d",*ptr);
14. return 0;
15. }
16. Find the output
Answer: 7
Question 9
1. #include <stdio.h>
Correct
2. int main()
Mark 1.00 out of
3. {
1.00
4. int i;
Flag question
5. int *ptr;
6. ptr = &i;
7. i = 7.5;
8. *ptr++;
9. printf("%d",i);
10. return 0;
11. }
Answer: 7
c. Nothing is displayed
Finish review
SIET LMS
Question 1 What is the output of this program? Show one page at a time
Correct
#include <stdio.h>
Finish review
Mark 1.00 out of
int main()
1.00
{
Flag question
int *iptr;
char *cptr;
if(sizeof(iptr) == sizeof(cptr))
printf("True");
else
printf("False");
Select one:
True
False
Pointer holds an address. Whether it is integer pointer or character pointer or structure pointer, it has the same size since it just stores the
address
Answer: 2
Question 3
What is the output of this program? If error, type "Error"#include <stdio.h>
Correct
int main()
Mark 1.00 out of
1.00 {
int *a;
Flag question
int arr[] = {1,2,3,4,5};
a = (int *) arr; //same as a = &arr[0]
a+=2;
printf("%d",*a);
return 0;
}
Answer: 3
Question 4 Assuming size of integert to be 4 bytes. What would be the address integer ptr points to after the code
Correct
Assume ptr initially points to 1000000
Mark 1.00 out of
1.00 ptr = ptr + 4;
Flag question
Answer: 1000016
ptr = ptr + 16
So answer is 1000016
Question 5
Assuming size of integert to be 4 bytes. What would be the address integer ptr points to after the code
Correct
Assume ptr initially points to 1000000
Mark 1.00 out of
1.00 ptr = ptr + 4;
Flag question
Answer: 1000016
Question 6
What would be the address character ptr points to after the code. Size of char is 1.
Correct
Assume ptr initially points to 1000000
Mark 1.00 out of
1.00
Answer: 1000028
Question 7
Assuming size of int to be 4 bytes
Correct
struct tag
Mark 1.00 out of
1.00 {
int a;
Flag question
int b;
};
What would be the address struct tag ptr points to after the code
Assume ptr initially points to 1000000
ptr = ptr + 3;
Answer: 1000024
Question 8 Is the base address of the array same as the name of the array?
Correct
That is int arr[10];
Mark 1.00 out of
1.00 &arr[0] same as arr
Flag question
Select one:
True
False
The base address of the array is same as the name of the array
Answer: 12375
Answer: 138
Answer: 17345
a[i] = *(a+i)
Question 12
What is the output? If error, type "Error"
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int main()
{
Flag question
int a[5] = {1,2,3,4,5};
int *ptr=a;
ptr[3] = 7;
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
}
Answer: 12375
Question 14 Find the output of this program. If error type answer as Error
Correct
#include <stdio.h>
Mark 1.00 out of
int main()
1.00
Flag question
{
int a[5] = {1,2,3,4,5};
int *ptr=a;
ptr++;
*ptr = 3;
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
}
Answer: 13345
Question 15
Find the output of this program. If error type answer as Error
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int main()
Flag question
{
int a[5] = {1,2,3,4,5};
int *ptr=a;
a++;
a[3] = 4;
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
}
Answer: Error
Question 16
Find the output of this program. If error type answer as Error
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int main()
Flag question {
int a[5] = {1,2,3,4,5};
int *ptr=a;
ptr = ptr + 2;
ptr[1] = 5;
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
}
Answer: 12355
ptr[1] = 5;
*(ptr+1) which is address of ptr (&a[2 + 1] which &a[3])
a]3] is set to 5
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
}
Answer: 1 2 3 10 5
Answer: 0 10 20 30 40
20 bytes would have been allocated for the 5 integer pointers as given below in memory
00010002000300040005
Now the character pointer would have pointed to value 1 from the left when ptr = a was done. this is the lowest order byte in integer
Now in the loop the value is changed to i*10 so 0 is assigned
when ptr = ptr+4 is done, it points to address where the value 2 is stored
now i is 1 so i*10, 10 is assigned instead of 2
same continues till the last element
Answer: 1 2 3 4 20
Answer: Error
Finish review
SIET LMS
You should have an integer pointer as the function argument whose name is l
int main()
{
int a;
mod(&a);
}
Answer: 7
Question 4
What is the output of the code below?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int mod( int a)
Flag question {
a=7;
}
int main()
{
int a=38;
mod(a);
printf("%d",a);
}
Answer: 38
Question 5
What is the output of the code below?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int mod( int *a)
Flag question {
*a=23;
}
int main()
{
int a=3;
mod(&a);
printf("%d",a);
}
Answer: 23
int main()
{
int a=5;
mod(&a);
printf("%d",a);
}
Answer: Error
Error. It should be
*a=7;
not
a=7;
a=7; would set the address to 7 instead of the value to 7.
10 12 10
12
Reset answer
1 #include <stdio.h>
2
3 //Write swap function here. swap to swap the values in a and b
4 //No changes should be made to main function
5 ▼ void swap(int *y, int*z){
6 int temp = *z;
7 *z = *y;
8 *y = temp;
9 }
10
11 int main()
12 ▼ {
13 int a,b;
14 scanf("%d %d",&a,&b);
15 swap(&a,&b);
16 printf("%d %d",a,b);
17 }
10 12 10 12 10
12
Correct
Marks for this submission: 10.00/10.00.
a. call by value
b. call by reference
Question 9
Is the following code an example of call by value or call by reference
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 void modify(int x)
{
Flag question
x = 7;
}
int main()
{
int a = 3;
modify(a);
printf("%d",a);
}
a. call by value
b. call by reference
Question 10
Is the following code an example of call by value or call by reference
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 int modify(int a)
{
Flag question
a=8;
return a;
}
int main()
{
int a = 3;
a=modify(a);
printf("%d",a);
}
a. call by value
b. call by reference
Finish review
SIET LMS
Flag question
Question 2 When you do dynamic memory allocation using malloc/calloc in which memory segment memory gets allocated?
Correct
d. data
e. queue
Question 3
After malloc, the function used to set the entire memory region to a particular value, usually 0, is memset()
Correct
Flag question
Question 4 Which of the following header files must necessarily be included to use dynamic memory allocation functions?
Correct
c. string.h
d. math.h
e. dynmem.h
Flag question
Question 6
Which function is used to delete or release the allocated memory space?
Correct
Flag question
Answer: free()
Question 7 calloc() allocates the memory and also initializes the allocates memory to zero, while memory allocated using malloc() has random data.
Correct
False
Question 8 calloc() allocates the memory and also initializes the allocates memory to zero
Correct
Question 9
Correct A pointer that points somewhere, but not to a valid object is called dangling pointer
Mark 1.00 out of
1.00
Flag question
Question 10 The calloc() function allocates space for an array of n objects, each of whose size is defined by size. Space is initialized to all bits zero
Correct
Finish review
SIET LMS
Answer: 1
Answer: Error
#define X 1
is correct
not
#define X=1
Answer: Error
Yes it is an error. X cannot be incremented since it would have got substituted to 1 during preprocessor phase of compilation. So the code
that is getting compiled will be looking like
#include <stdio.h>
int main()
{
printf("%d",++1);
}
Answer: 4
Answer: 11
Answer: 19
Answer: 49
Answer: 36
printf("%d",SUM(3,4));
}
Answer: 7
Flag question {
printf("%d",MUL(3+1,4+1));
}
Answer: 8
It expands to 3+4*1+1 = 8
Question 11
#include <stdio.h>
Correct
#define MUL(x,y) x*y
Mark 1.00 out of
1.00 int main()
Flag question
{
printf("%d",MUL(4+1,5+1));
}
Answer: 10
It expands to 4+1*5+1
Finish review
SIET LMS
Answer: 10 20
Answer: Error
Answer: 10 20
t(pri,ntf)("%d %d",t(x,y),t(c,d));
return 0;
Answer: 10 20
Answer: 12
String concatenation works for within main or on main function itself. Answer is 1 2
Answer: itvac
String concatenation works for within main or on main function itself. Answer is 1 2
# is called the stringy operator. It converts the given input to a string.
Finish review
SIET LMS
Flag question
Flag question
Question 4 Assuming size of int is 4 bytes what is the size of this structure
Correct
#include <stdio.h>
Mark 1.00 out of
struct s
1.00
{
Flag question
int s;
int k;
};
int main()
{
printf("%ld",sizeof(struct s));
return 0;
}
Answer: 8 bytes
Question 5 struct s{
Correct int s;
Mark 1.00 out of int k;
1.00 }k;
Flag question
Is it a right way to declare a variable k of type struct s
Select one:
True
False
Yes. It is correct
Question 6
struct s{
Correct
int s;
Mark 1.00 out of
int k;
1.00
}k,l;
Flag question
Is it a right way to declare a variable k and l of type struct s
Select one:
True
False
Yes. It is correct
Question 7
struct s{
Correct
int s;
Mark 1.00 out of
int k;
1.00
};
Flag question
struct s k;
Is it a right way to declare a variable k of type struct s
Select one:
True
False
int main()
{
// What should be the code that should come here to initialize the field k in variable w to 1.
return 0;
Answer: w.k=5;
Answer: 2
Question 10
Find the output
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 struct s
{
Flag question
int rollno;
char x;
};
int main()
{
struct s t = {1,'A'};
printf("%c",t.x);
return 0;
}
Answer: A
t1.b=30;
}
write a statement to initialize field b in t1 to 30.
Finish review
SIET LMS
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 8
Question 2
What is the output of this program?
Correct
Assume size of int is 4 bytes
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
int a;
int b;
int c;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 12
Question 3
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
int a;
int b;
char c;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 12
Answer is not 9. It is 12. This is because C adds padding in structures so that every field ends in a bird boundary.
Question 4
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
int a;
int b;
char c;
int d;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 16
Question 5
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
int a;
int b;
char c;
char d;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 12
It is 12. Since the 2 integers occupy 8 bytes. The third & 4th character occupy 9th and 10th bytes. After that 2 bytes of padding are added.
Question 6
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
Flag question
struct tag
{
int a;
int b;
char c;
char d;
char e;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 12
Still occupies only 12 bytes. The first 2 integers occupy 4 bytes each. The 9th byte is occupied by char c the 10th byte is occupied by char d
and 11th byte is occupied by char e and one byte padding is done.
Question 7
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
Flag question
struct tag
{
int a;
int b;
char c;
char d;
char e;
int f;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 16
2 integers occupy 4 bytes each making it 8 bytes. The 3 characters occupy 1 byte each making it total of 3 bytes. So 8+3 = 11
One byte padding is added after this making it 12.
Finally 4 byte integer is added for f which makes the total as 16.
Question 8
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
char a;
char b;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 2
Question 9
What is the output of this program?
Correct
Assume size of int is 4 bytes and sizeof char is 1 byte
Mark 1.00 out of
1.00 #include <stdio.h>
struct tag
Flag question
{
char a[2];
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 2
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 6
#pragma pack (1) informs the compiler that it has to be a packed structure with no padding.
Question 11
What is the size of the structure
Correct
include <stdio.h>
Mark 1.00 out of
1.00 #pragma pack(1)
struct tag
Flag question
{
int a;
char b;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 5
Question 12
What is the size of the structure
Correct
include <stdio.h>
Mark 1.00 out of
1.00 #pragma pack(1)
Flag question
struct tag
{
int a;
char b;
char c;
int d;
char e;
};
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 11
int main()
{
printf("%ld",sizeof(struct tag));
return 0;
}
Answer: 13
Finish review
SIET LMS
Define a statement to declare an array of type struct tag with 10 elements with variable name t
Define a statement to declare an array of type struct tag with 25 elements with variable name x
int main()
{
// Write a statement to store the value 7 in 4th index of the array - member element a to 20
}
Answer: t[3].a = 7;
Answer: 160
Answer: 130
Given that it is packed structure each structure is 13 bytes. So total is 130 bytes
Question 6
What is the output of the program
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 #pragma pack(1)
struct tag
Flag
question {
int a;
char b;
int c;
};
Answer: 90
Given that it is packed structure each structure is 9 bytes with no padding. So total is 90 bytes
Question 7
What is the output of the code?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 #pragma pack(1)
struct tag
Flag
question {
int a;
char b;
int c;
struct
{
int x;
int y;
};
};
struct tag x[10];
int main()
{
printf("%ld",sizeof(x));
}
Answer: 170
Answer: x.dateofbirth.hr=12;
int main()
{
//type the code to set the dateofbirth sec to 40
}
Answer: x.dateofbirth.sec=60;
NOTE: Each question will be manually reviewed to ensure that you used an array of structures. So do not store it iin a
variable/array and display
For example:
Input Result
3 714017101
714017101 101
101 714017102
714017102 102
102 714017103
714017103 103
103
Reset answer
#include <stdio.h>
struct student
{
int regno;
int rollno;
};
int main()
{
int n;
struct student students[60];
scanf("%d", &n);
for (int i = 0; i < n; ++i){
scanf("%d", &students[i].regno);
scanf("%d", &students[i].rollno);
}
for (int i = 0; i < n; ++i){
printf("%d\n",students[i].regno);
printf("%d\n",students[i].rollno);
}
}
3 714017101 714017101
714017101 101 101
101 714017102 714017102
714017102 102 102
102 714017103 714017103
714017103 103 103
103
Correct
Marks for this submission: 10.00/10.00.
Finish review
SIET LMS
Answer: t.i=4;
Question 2
How do you set the value of member i for variable t to 4 using the pointer ptr?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 struct tag
{
Flag question
int i;
int j;
};
int main()
{
struct tag t;
struct tag *ptr;
ptr = &t;
// how do you set the value of member i for variable t to 4 using the pointer ptr?
}
Answer: ptr->i=4;
Answer: 6
int main()
{
struct tag t1,t2;
struct tag *pt1;
struct tag *pt2;
t1.i = 4;
t1.j = 5;
pt1 = &t1;
pt2 = &t2;
*pt2 = *pt1;
printf("%d %d",t2.i,t2.j);
}
Answer: 45
Answer: 67
Flag question
Input Result
5 5
6 6
Reset answer
1 #include <stdio.h>
2 ▼ struct tag {
3 int i;
4 int j;
5 };
6
7 int main()
8 ▼ {
9 int i,j;
10 struct tag t;
11 struct tag *pt1;
12 scanf("%d %d",&i,&j);
13 //Write code to make the pointer to point to t and then assign the values for i and j using the ptr
14 pt1 = &t;
15 pt1->i = i;
16 pt1->j = j;
17 printf("%d\n%d",pt1->i,pt1->j);
18 }
5 5 5
6 6 6
7 7 7
8 8 8
Correct
Marks for this submission: 10.00/10.00.
printf("%d %d %d %d %d %d",t[0].i,t[0].j,t[1].i,t[1].j,t[2].i,t[2].j);
}
Answer: 10 20 0 0 30 40
int main()
{
struct tag t;
struct tag *ptr;
ptr=&t;
*ptr.i = 10;
*ptr.j = 20;
printf("%d %d",t.i,t.j);
}
Answer: Error
int main()
{
struct tag t;
struct tag *ptr;
ptr=&t;
(*ptr).i = 10;
(*ptr).j = 20;
printf("%d %d",t.i,t.j);
Answer: 10 20
ptr->i++;
ptr->j++;
printf("%d %d",t.i,t.j);
}
Answer: 11 21
Finish review
SIET LMS
int main()
{
union tag x;
x.j = 0;
x.i = 10;
printf("%d",x.j);
return 0;
}
Answer: 10
Question 2
What is the output of the below code?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 struct tag
{
Flag
question int i;
char c;
int j;
};
int main()
{
struct tag x;
x.j = 0;
x.i = 10;
printf("%d",x.j);
return 0;
}
Answer: 0
Question 3
What is the output of the below code?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 union tag
Flag
{
question int i;
char c;
int j;
};
int main()
{
union tag x;
x.c = 'A';
x.i = 10;
printf("%d",x.c);
return 0;
}
Answer: 10
int main()
{
union tag x;
x.i = 10;
x.j = 20;
printf("%d",x.k);
return 0;
}
Answer: 20
Answer: 20
In this case 16 bytes are allocated one for each integer given that it is an array. Each of i[0] to i[3] have separate 4 bytes.
So it will not overwrite each other.
int main()
{
union tag k;
k.i = 0x01020304;
printf("%d",k.a[0]);
printf("%d",k.a[1]);
printf("%d",k.a[2]);
printf("%d",k.a[3]);
return 0;
Answer: 4321
Question 7
What is the output?
Correct
#include <stdio.h>
Mark 1.00 out of
1.00 union tag
{
Flag
question int i;
int j;
};
int main()
{
union tag k;
k.i = 7;
k.j = 8;
printf("%d",k.i);
return 0;
Answer: 8
Question 8 Each member in the union is allocated a unique memory location. True/False?
Correct
Flag
question
Question 9 Each member in a structure is allocated a unique memory location. True or False?
Correct
Answer: 16
No. All share the same memory location. So the value of 4 will be there in both i and j and hence answer is 16.
Finish review
SIET LMS
Question 1 Most appropriate sentence to describe unions is Show one page at a time
Correct
d. Union should have the same data type while structures can have different data types
Question 2
A single structure can have different data types
Correct
Flag
question
b. False
b. struct temp{};
struct temp s;
main(){}
c. struct temp s;
struct temp{};
main(){}
Question 4
Find the output
Correct
Question 5
Find the Output
Correct
Answer: Error
Question 6
Find the output
Correct union details
Mark 1.00 out of {
1.00 int data;
char value[4];
Flag
question }det;
int main()
{
det.data=0X01020304;
printf("%d %d %d %d",det.value[0],det.value[ 1],det.value[2],det.value[3]);
}
Output is ____
____
____
____
Answer: 4321
Question 7
Find the output
Correct
#include<stdio.h>
Mark 1.00 out of
1.00 struct Point
Flag {
question int x, y, z;
};
int main()
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
Answer: 201
Question 8
Find the Output
Correct Assume the program is executed in 64-bit compiler
Mark 1.00 out of union test
1.00 {
int x;
Flag
question char arr[8];
int y;
};
int main()
{
printf("%d", sizeof(union test));
return 0;
}
Output is ____
Answer: 8
Question 9
Find the output
Correct Assume the program is executed in 64-bit compiler
Mark 1.00 out of struct {
1.00 short s[5];
union {
Flag
question float y;
long z;
}u;
} t;
int main()
{
printf("%d", sizeof(t));
return 0;
}
Output is 24 bytes
Blank 1
Formula Editor
Question 10
Find the output
Correct struct tag
Mark 1.00 out of {
1.00 char a1:1;
char a2:1;
Flag
question char a3:1;
char a4:1;
char a5:1;
char a6:1;
char a7:1;
char a8:1;
}t;
int main()
{
printf("%d bytes",sizeof(t));
return 0;
}
Output is ___bytes
Answer: 1
Question 11
Find the output
Correct
Answer: 110
Question 12
Find the output
Correct
Answer: 110
Question 13
What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
Correct #include <stdio.h>
Mark 1.00 out of union uTemp
1.00 {
double a;
Flag
question int b[10];
char c;
}u;
Output is 40
Question 14
Find the output
Correct #include <stdio.h>
Mark 1.00 out of struct p
1.00 {
unsigned int x : 2;
Flag
question unsigned int y : 2;
};
int main()
{
struct p p;
p.x = 3;
p.y = 4;
printf("%d\n", p.y);
}
Output is ___
Answer: 0
Question 15
What will be the output of the following C code (Assuming size of int and float is 4)?
Correct #include <stdio.h>
Mark 1.00 out of union
1.00 {
int ival;
Flag
question float fval;
} u;
void main()
{
printf("%d", sizeof(u));
}
Output is ____
Answer: 4
Question 16
What will be the output of the following C code?
Correct #include <stdio.h>
Mark 1.00 out of struct student
1.00 {
};
Flag
question void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
Output is 0
Question 17
What will be the output of the following C code?
Correct #include <stdio.h>
Mark 1.00 out of struct student
1.00 {
int no;
Flag
question char name[20];
};
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
Output is hello
Question 18
What will be the output of the following C code?
Correct #include <stdio.h>
Mark 1.00 out of void main()
1.00 {
struct student
Flag
question {
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
Output is ____
Answer: 8
Question 19
What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
Correct #include <stdio.h>
Mark 1.00 out of union uTemp
1.00 {
double a;
Flag
question int b[10];
char c;
}u;
Output is 40
Finish review
SIET LMS
Question 1 Write a program to read the content of the file input.txt and print the output
Correct
The file contains a set of integers one in each line.
Mark 10.00 out
Read and the content and display the integer one line at a time for given N rows
of 10.00
For example:
Flag question
Input Result
3 10
20
30
4 10
20
30
100
Language c
1 #include <stdio.h>
2 ▼ int main(){
3 FILE *fp;
4 int n;
5 fp = fopen("input.txt", "r");
6 scanf("%d",&n);
7
8 ▼ for(int i=0; i<n; i++){
9 int num;
10 if(fscanf(fp, "%d", &num) == 1)
11 printf("%d\n",num);
12
13 }
14 fclose(fp);
15 }
3 10 10
20 20
30 30
4 10 10
20 20
30 30
100 100
Correct
Marks for this submission: 10.00/10.00.
Question 2 Write a program to read the content in a file input.txt and display the output
Correct The input in the file is a set of names one in each line
Mark 10.00 out
of 10.00 Answer: (penalty regime: 0 %)
Flag question
Language c
1 #include <stdio.h>
2
3 ▼ int main() {
4 FILE *filePointer;
5 char name[100];
6 filePointer = fopen("input.txt", "r");
7 ▼ while (fgets(name, sizeof(name), filePointer) != NULL) {
8 printf("%s", name);
9 }
10 fclose(filePointer);
11
12 return 0;
13 }
14
15
Correct
Marks for this submission: 10.00/10.00.
Question 3 Write a program to read a given string from keyboard and store it in a file. Read the sentence from the file and display
Correct
Correct
Marks for this submission: 10.00/10.00.
Finish review
SIET LMS
d. worst
d. average
Question 4 4 Algorithms have the following Big-O complexities. Which one is the best (shortest execution time)?
Correct
d. O(1)
Question 5
Algorithms have the following Big-O complexities. Which one is the best (shortest execution time)?
Correct
c. O(N * N)
d. O(N)
Question 6 What is the best case complexity for Linear Search? It is Ω(____)?
Correct
Flag question
Flag question
Question 8
Searching for the first element in a linear search represents which compexity?
Correct
d. average case
Question 9
Searching for the last element in a linear search represents which compexity?
Correct
c. average case
d. worst case
Flag question
a. O(N LOG N)
b. O(N)
c. O(LOG N)
d. O(1)
Question 11
What is the worst case complexity of the below algorithm
Correct
for(i=1;i<=N;++i)
Mark 1.00 out of
1.00 for(j=1;j<N;++j)
a[i] = j;
Flag question
a. O(N + N)
b. O(N * N)
c. O(LOG N)
d. O(N)
Question 12 Which among the following takes the longest execution time
Correct
d. ON!) (N Factorial)
Question 13 What is the time worst case complexity of the following code
Correct main()
Mark 1.00 out of {
1.00 int i=1,n;
Flag question for(i=1;i<=n;++i)
printf("%d",i);
}
Select one:
A. O(C^(n-1)+ 1)
B. O(C^(n-1)-1)
C. O(N)
D. O(C^n)
Select one:
A. O(N/2 log(N))
B. O(N*N)
C. O(N^2 log(N))
D. O(N log(N))
Select one:
A. O(N*(2*sqrt(N))
B. O(N*(log(N)))
C. O(N*N*log(N))
D. O(N*(2*log(N)))
Finish review
SIET LMS
d. strings
Finish review
SIET LMS
12
34
45
67
Output:
Addition:
5
7
9
11
Subtraction:
-3
-3
-3
-3
For example:
Input Result
Language c
#include <stdio.h>
int main() {
int a, b, c, d;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
An unexpected error occurred. The sandbox may be down. Try again shortly.
Check
The submission was invalid, and has been disregarded without penalty.
answer
Example: Consider a matrix, { { 1, 5, 8 } , { 4, 3, 1 } , { 6, 5, 2 } }. Primary/Principal and secondary/Anti-diagonal elements are as follows, the bottom of the page.
1 2 3 4 5 6 7
Marked out of
10.00
Finish attempt ...
Flag
question
For example:
Input Result
Language c
#include <stdio.h>
int main() {
int rows, cols;
scanf("%d", &rows);
scanf("%d", &cols);
int matrix[rows][cols];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
scanf("%d\n", &matrix[i][j]);
}
}
return 0;
}
An unexpected error occurred. The sandbox may be down. Try again shortly.
Check
The submission was invalid, and has been disregarded without penalty.
1 2 3 4 5 6 7 8 9
Question 10 Write a program to find if a given matrix is a sparse matrix or not? Assume matrix size to be 3x3
Correct
A sparse matrix is one in which majority elements are zero 10 11
Marked out of
10.00 For example:
Finish attempt ...
Flag question
Input Result
1 1 0 YES
0 0 2
0 0 0
Check
1 1 0 YES YES
0 0 2
0 0 0
1 1 1 NO NO
0 0 2
0 0 2
Flag 10 11
question
For example:
Result
0 0 1 1 3 3
2 4 2 3 1 2
3 4 5 7 2 6
Reset answer
#include<stdio.h>
int main(){
int arr[4][5] =
{
{0 , 0 , 3 , 0 , 4 },
{0 , 0 , 5 , 7 , 0 },
{0 , 0 , 0 , 0 , 0 },
{0 , 2 , 6 , 0 , 0 }
};
int arr1[10],arr2[10],arr3[10],c=0;
for(int i=0;i<4;i++){
for(int j=0;j<5;j++){
if(arr[i][j] != 0 ){
arr1[c] = i;
arr2[c] = j;
arr3[c] = arr[i][j];
c++;
}
}
}
for(int i=0;i<6;i++){
printf("%d ",arr1[i]);
}
printf("\n");
for(int i=0;i<6;i++){
printf("%d ",arr2[i]);
}
printf("\n");
for(int i=0;i<6;i++){
printf("%d ",arr3[i]);
}
}
Check
Expected Got
0 0 1 1 3 3 0 0 1 1 3 3
2 4 2 3 1 2 2 4 2 3 1 2
3 4 5 7 2 6 3 4 5 7 2 6
Question 1
Finish review
Construct a singly linked list from the memory map given below.
Correct For ease of construction address is between 1000 to 1120.
Mark 10.00 out
Assume head to point to 1012.
of 10.00
Answer should be typed like 33->44->523->63->NULL
Flag question
No spaces can be typed anywhere. Only the data in the node followed by the data in next node
Answer: 36->93->883->1120->1000->NULL
Question 2 Construct the singly linked list with the given memory dump
Correct
Assume head starts at 1043
Mark 10.00 out
of 10.00 Answer should be in the format 123->345->432->443->NULL
only data elements in the link should be present
Flag question
Answer: 1120->958->999->273->123->780->1000->NULL
Question 3 Construct the singly linked list for the given memory dump. Head is pointing to memory location 1033
Incorrect
Answer should be in the form 123->234->432->NULL
Mark 0.00 out of
Each value represents the data element
1.00
Flag question
Answer: 1892->1043->1000->1000->1076->1862->NULL
Question 4
Assume head of a singly linked list is pointing to memory location 1033
Correct
Which memory location will be impacted if the following command is executed to the below memory location
Mark 1.00 out of
1.00 head.data = 33
Flag question
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and memory location would occupy at leaset 4 bytes of memory
Answer: 1033
Question 5
Assume head of a singly linked list is pointing to memory location 1033
Not answered
Marked out of
1.00
Flag question
If you display the singly linked list from head to last node after executing the following command what will be the output.
head.next.next.next=NULL;
Answer should be typed in the following format
43->72->63->71->NULL
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and memory location would occupy at leaset 4 bytes of memory
Answer:
Question 6
Assume head of a singly linked list is pointing to memory location 1033
Correct
Flag question
If you display the singly linked list from head to last node after executing the following command what will be the output.
head.next.next.data=1030;
Answer should be typed in the following format
43->72->63->71->NULL
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and memory location would occupy at leaset 4 bytes of memory
Answer: 1892->1043->1030->1000->1706->1862->NULL
Question 7
Assume head of a singly linked list is pointing to memory location 1033
Correct
Flag question
If you display the singly linked list from head to last node after executing the following command what will be the output.
head=head.next;
Answer should be typed in the following format
43->72->63->71->NULL
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and reference(pointer) would occupy at leaset 4 bytes of memory each
Answer: 1043->1000->1000->1706->1862->NULL
Question 8
Assume head of a singly linked list is pointing to memory location 1033
Not answered
Marked out of
1.00
Flag question
If you display the singly linked list from head to last node after executing the following command what will be the output.
head.next = head.next.next;
Answer:
This is how the memory would be after the head.next = head.next.next is executed
Question 9
Assume head of a singly linked list is pointing to memory location 1033
Correct
Flag question
If you display the singly linked list from head to last node after executing the following command what will be the output.
head.next = NULL
Answer should be typed in the following format
43->72->63->71->NULL
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and reference(pointer) would occupy at leaset 4 bytes of memory each
Answer: 1892->NULL
Question 10
Assume head of a singly linked list is pointing to memory location 1033
Correct
Flag question
If you display the singly linked list from head to last node after executing the following instructions what will be the output.
head.next.data = 33;
head.next.next = NULL;
Asssume the reference occupies one byte memory location and data occupies one byte of memory location
NOTE: In actual, data and reference(pointer) would occupy at leaset 4 bytes of memory each
Answer: 1892->33->NULL
Finish review
SIET LMS
Language c
1 #include<stdio.h>
2 #include<stdlib.h>
3 ▼ struct node{
4 int data;
5 struct node *link;
6 };
7 struct node *head=NULL;
8 struct node *tail=NULL;
9 ▼ void add(int val){
10 struct node *temp=(struct node*)malloc(sizeof(struct node));
11 temp->data=val;
12 temp->link=NULL;
13 ▼ if(head==NULL){
14 head=temp;
15 tail=temp;
16 ▼ }else{
17 tail->link=temp;
18 tail=temp;
19 }
20
21 }
22 ▼ void display(){
5 10 20 30 40 50 10 20 30 40 50
10
20
30
40
50
Finish review
SIET LMS
Flag 2
Finish attempt ...
question
10
20
sample output 1
10 20
For example:
Input Result
4 10 20 30 40
10
20
30
40
4 23 24 25 26
23
24
25
26
Language c
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
if (*head_ref == NULL) {
*head_ref = new_node;
return;
}
last->next = new_node;
}
int main() {
scanf("%d", &num_nodes);
printList(head);
return 0;
}
Check
4 10 20 30 40 10 20 30 40
10
20
30
40
4 23 24 25 26 23 24 25 26
23
24
25
26
4 1 2 3 4 1 2 3 4
1
2
3
4
2 10 7 20 30 40
7
9 Invalid position 9
7
Language c
Reset answer
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node* link;
};
if (position == 1) {
temp->link = *head;
*head = temp;
return 1;
}
if (prev == NULL) {
printf("Invalid position %d",position);
free(temp);
return -1;
}
temp->link = prev->link;
prev->link = temp;
return 1;
}
if (*head == NULL) {
*head = temp;
} else {
prev->link = temp;
}
prev = temp;
}
}
int main() {
int position, value;
scanf("%d", &position);
scanf("%d", &value);
init_list(&head);
int error;
error = insert(&head, position, value);
if(error == -1){
return 0;
}
print(head);
return 0;
}
Check
1 7 10 20 30 40 7 10 20 30 40
7
2 10 7 20 30 40 10 7 20 30 40
7
Input Result
5 10 20 40 50
10 20 30 40 50
30
7 1 2 3 4 5 6
1 2 3 4 5 6 7
7
3 2 3
1 2 3
1
2 30 Not in List
10 20
30
Language c
Reset answer
#include <stdio.h>
#include <stdlib.h>
struct tag
{
int data;
struct tag *next;
};
if (head == NULL) {
head = temp;
tail = temp;
} else {
tail->next = temp;
tail = temp;
}
}
if (ptr == NULL) {
printf("%d Not in List",value);
exit(1);
}
if (prev == NULL) {
// The node to be deleted is the head
head = head->next;
} else {
prev->next = ptr->next;
}
free(ptr);
}
void display()
{
struct tag *ptr = head;
while (ptr != NULL) {
printf("%d ", ptr->data);
ptr = ptr->next;
}
printf("\n");
}
int main()
{
int i, n, value, del;
scanf("%d", &n);
for (i = 0; i < n; ++i)
{
scanf("%d", &value);
add(value);
}
scanf("%d", &del);
delete(del);
display();
return 0;
}
Check
5 10 20 40 50 10 20 40 50
10 20 30 40 50
30
7 1 2 3 4 5 6 1 2 3 4 5 6
1 2 3 4 5 6 7
7
3 2 3 2 3
1 2 3
1
Question 1 What is the time complexity to count the number of elements in the linked list?
Correct
D. O( n )
Question 2 Which of the following application makes use of a circular linked list?
Correct
Question 3 Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head and tail pointer. Given the
Correct representation, which of the following operation can be implemented in O(1) time?
Mark 2.00 out of
i) Insertion at the front of the linked list
2.00
ii) Insertion at the end of the linked list
Flag question
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list
A. I,II and IV
B. I and III
D. I and II
A. ptr=(NODE*)malloc(NODE);
B. ptr=(NODE*)malloc(sizeof(NODE*));
C. ptr=(NODE)malloc(sizeof(NODE))
D. ptr=(NODE*)malloc(sizeof(NODE));
Question 6 What does the following function do for a given Linked List with first node as head? void fun1(struct node* head)
Correct
{
Mark 2.00 out of
2.00 if(head == NULL)
Mark 2.00 out of A. The insertion and deletion of a node take a bit longer
2.00
B. Implementing a doubly linked list is easier than singly linked list
Flag question
C. We can navigate in both the directions
D. It requires more space than a singly linked list
Question 9
What is 9.3 = 9.3
Correct
Finish review
SIET LMS
For example:
Input Result
10 10 40 30
20
30
40
Language c
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node* prev;
int data;
struct node* next;
};
struct node *head = NULL;
if (head == NULL) {
head = temp;
return;
}
if (head == NULL) {
printf("List is empty.\n");
return;
}
if (ptr == NULL) {
printf("Position out of bounds.\n");
return;
}
temp->next = ptr->next;
temp->prev = ptr;
if (ptr->next != NULL) {
ptr->next->prev = temp;
}
ptr->next = temp;
}
if (head == NULL) {
printf("List is empty.\n");
return;
}
if (ptr == NULL) {
printf("Node with value %d not found.\n", value);
return;
}
if (ptr->prev != NULL) {
ptr->prev->next = ptr->next;
} else {
head = ptr->next; // Update head if node to be deleted is head
}
if (ptr->next != NULL) {
ptr->next->prev = ptr->prev;
}
free(ptr);
}
void printnode() {
struct node *ptr = head;
while (ptr != NULL) {
printf("%d ", ptr->data);
ptr = ptr->next;
}
printf("\n");
}
int main() {
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
createnode(a);
appendatend(b);
appendatend(c);
insertafter(d, 1);
deletenode(20); // This should be an existing value to test
printnode();
return 0;
}
Check
10 10 40 30 10 40 30
20
30
40
For example:
Input Result
6 5x2 - 1x - 3
5 2 4 1 2 0
4
-5 1 -5 0
6 5x3 + 4x2 + 5x - 3
5 3 4 2 2 0
4
5 1 -5 0
Language c
#include <stdio.h>
#include <stdlib.h>
typedef struct {
Node* head;
Node* tail;
} DoublyLinkedList;
Node* p1 = poly1->head;
Node* p2 = poly2->head;
return result;
}
int main() {
int n1, n2;
scanf("%d", &n1);
int* poly1_terms = (int*)malloc(n1 * 2 * sizeof(int));
scanf("%d", &n2);
int* poly2_terms = (int*)malloc(n2 * 2 * sizeof(int));
display(result);
free(poly1_terms);
free(poly2_terms);
free(poly1);
free(poly2);
free(result);
return 0;
}
Check
6 5x2 - 1x - 3 5x2 - 1x - 3
5 2 4 1 2 0
4
-5 1 -5 0
For example:
Input Result
5 Stack underflow
2 PUSH 10 SUCCESSFUL
1 10 PUSH 20 SUCCESSFUL
1 20 PUSH 30 SUCCESSFUL
1 30 PUSH 40 SUCCESSFUL
1 40 PUSH 50 SUCCESSFUL
1 50 Stack overflow
1 60 50
3 POP 50
2 40
3 POP 40
2 30
3 POP 30
2 20
3 POP 20
2 10
3 POP 10
2 STACK EMPTY
3 Stack underflow
2
4
Language c
#include <stdio.h>
#include <stdlib.h>
struct stack {
struct stack* prev;
int data;
struct stack* next;
};
void pop() {
if (stack_size == 0) {
printf("Stack underflow\n");
} else {
printf("POP %d\n", head->data);
struct stack* temp = head;
head = head->next;
if (head != NULL) {
head->prev = NULL;
}
free(temp);
stack_size--;
}
}
void peek() {
if (stack_size == 0) {
printf("STACK EMPTY\n");
} else {
printf("%d\n", head->data);
}
}
int main() {
scanf("%d", &tot_stack_size);
int n;
while (1) {
scanf("%d", &n);
if (n == 1) {
int data;
scanf("%d", &data);
push(data);
} else if (n == 2) {
pop();
} else if (n == 3) {
peek();
} else {
return 0;
}
}
}
Check
Next page
SIET LMS
nimbus submin
Language c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct stack{
int data;
struct stack* next;
};
if(head == NULL){
head = temp;
}
else{
temp->next = head;
head = temp;
}
}
void pop(){
printf("%c", head->data);
free(temp);
int main(){
char str[100];
scanf("%s", str);
Check
Language c
#include <stdio.h>
int main() {
int a;
scanf("%d", &a);
int arr[100];
for(int i = 0; i < a; i++) {
scanf("%d", &arr[i]);
}
int stack[100];
int top = -1;
int result[100];
while(top != -1) {
int idx = stack[top--];
result[idx] = 0;
}
return 0;
}
Check
8 1,1,4,2,1,1,0,0 1,1,4,2,1,1,0,0
73
74
75
71
69
72
76
73
3 1,1,0 1,1,0
30
60
90
Next page
SIET LMS
For example:
Input Result
cd dir/../dir/../dir/../dir1/dir2 dir1/dir2
cd dir2 dir2
Language c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
*count = idx;
free(pathCopy);
return parts;
}
int main() {
char input[200];
fgets(input, sizeof(input), stdin);
input[strcspn(input, "\n")] = 0;
int count;
char** parts = splitPath(input, &count);
char* result[100];
int length = 0;
if (length == 0) {
printf("/");
} else {
for (int i = 0; i < length; i++) {
if (i != 0) {
printf("/");
}
printf("%s", result[i]);
}
}
printf("\n");
freeSplitPath(parts, count);
return 0;
}
Check
Flag
Finish attempt ...
question
For example:
Input Result
ab#c True
ad#c
ab#c False
abc
Language c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
stackToString(stack, result);
}
processString(s, processedS);
processString(t, processedT);
int main() {
char s[200], t[200];
scanf("%s", s);
scanf("%s", t);
if (backspaceCompare(s, t)) {
printf("True\n");
} else {
printf("False\n");
}
return 0;
}
Check
For example:
Input Result
1 20
10 30 40
1
20
2
3
1
30
1
40
2
3
4
Language c
#include <stdio.h>
#include <stdlib.h>
struct queue{
struct queue* prev;
int data;
struct queue* next;
};
if(head == NULL){
head = temp;
tail = temp;
}
else{
temp->prev = tail;
tail->next = temp;
tail = temp;
}
}
void dequeue(){
struct queue* temp = head;
head = head->next;
free(temp);
}
void display(){
struct queue* ptr = head;
while(ptr != NULL){
printf("%d ",ptr->data);
ptr = ptr->next;
}
printf("\n");
}
int main(){
int i=1;
while(i>0){
int n;
scanf("%d",&n);
if(n == 1){
int data;
scanf("%d",&data);
enqueue(data);
}
else if(n == 2){
dequeue();
}
else if(n == 3){
display();
}
else{
return 0;
}
i++;
}
}
Check
1 20 20
10 30 40 30 40
1
20
2
3
1
30
1
40
2
3
4