Programming :: All Aptitude Test ::

Hassan
1.Which of the following statements are correct ?
A. 1, 2
B. 1, 2, 3
C. 2, 4
D. 1, 2

2.Which of the following statement is correct?
A. strcmp(s1, s2) returns a number less than 0 if s1>s2
B. strcmp(s1, s2) returns a number greater than 0 if s1
C. strcmp(s1, s2) returns 0 if s1==s2
D. strcmp(s1, s2) returns a number less than 0 if s1>s2

3.In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain?
A. "I am a boy\r\n\0"
B. "I am a boy\r\0"
C. "I am a boy\n\0"
D. "I am a boy\r\n\0"

4.What is the purpose of "rb" in fopen() function used below in the code?
A. open "source.txt" in binary mode for reading
B. open "source.txt" in binary mode for reading and writing
C. Create a new file "source.txt" for reading and writing
D. open "source.txt" in binary mode for reading

5.What does fp point to in the program ?
A. The first character in the file
B. The last character in the file.
C. A structure which contains a char pointer which points to the first character of a file.
D. The first character in the file

6.Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
A. Reading
B. Writing
C. Appending
D. Reading

7.To print out a and b given below, which of the following printf() statement will you use?
A. printf("%f %lf", a, b);
B. printf("%Lf %f", a, b);
C. printf("%Lf %Lf", a, b);
D. printf("%f %lf", a, b);

8.Which files will get closed through the fclose() in the following program?
A. "A.C" "B.C" "C.C"
B. "B.C" "C.C"
C. "A.C"
D. "A.C" "B.C" "C.C"

9.On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?
A. r n
B. Trh
C. err
D. r n

10.To scan a and b given below, which of the following scanf() statement will you use?
A. scanf("%f %f", &a, &b);
B. scanf("%Lf %Lf", &a, &b);
C. scanf("%f %Lf", &a, &b);
D. scanf("%f %f", &a, &b);

11.Out of fgets() and gets() which function is safe to use?
A. gets()
B. fgets()
C. gets() and fgets()
D. gets()

12.Consider the following program and what will be content of t?
A. size of "DUMMY.C" file
B. Garbage value
C. Error in fileno()
D. size of "DUMMY.C" file

13.What will be the content of 'file.c' after executing the following program?
A. B
B. B B
C. A B
D. B

14.What will be the output of the program?
A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. k == 1 is TRUE

15.What will be the output of the program ?
A. char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}
B. char *str = %c%s%c; main(){ printf(str, 34, str, 34);}
C. No output
D. char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}

16.If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of below program?
A. friend
B. frien
C. end
D. friend

17.What will be the output of the program?
A. 3.00
B. 3.15
C. 3.2
D. 3.00

18.What will be the output of the program?
A. A
B. B
C. C
D. A

19.What will be the output of the program?
A. This is PakMcqs
B. This is
C. Infinite loop
D. This is PakMcqs

20.What will be the output of the program?
A. 21
B. 23
C. Error
D. 21

21.What will be the output of the program?
A. Print the contents of file "myfile.c"
B. Infinite loop
C. Error in program
D. Print the contents of file "myfile.c"

22.What will be the output of the program?
A. %%%%%
B. %%
C. No output
D. %%%%%

23.What will be the output of the program ?
A. 1250
B. 2
C. 50
D. 1250

24.What will be the output of the program?
A. agpur
B. gpur
C. Nagp
D. agpur

25.What will be the output of the program if value 25 given to scanf()?
A. 25
B. 2
C. 1
D. 25

26.Point out the error in the program?
A. Error: in unsigned char statement
B. Error: unknown file pointer
C. No error
D. Error: in unsigned char statement

27.Point out the error in the program?
A. Error: suspicious char to in conversion in scanf()
B. Error: we may not get input for second scanf() statement
C. No error
D. Error: suspicious char to in conversion in scanf()

28.Point out the error, if any in the program?
A. Error: unrecognised Keyword SEEK_SET
B. Error: fseek() long offset value
C. No Error
D. Error: unrecognised Keyword SEEK_SET

29.What will be the output of the program?
A. No error, No output.
B. Program crashes at run time.
C. Output: Unable to open file.
D. No error, No output.

30.Point out the error in the program?
A. Error: in unsigned char declaration
B. Error: while statement
C. No error
D. Error: in unsigned char declaration


Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers