0% found this document useful (0 votes)
83 views9 pages

Technical Test-02 Prog in C

The document contains a technical test with 14 multiple choice questions about C programming concepts such as arrays, strings, pointers, file handling, macros etc. Each question is followed by 4 answer options and the correct answer is not provided.

Uploaded by

Manmeet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views9 pages

Technical Test-02 Prog in C

The document contains a technical test with 14 multiple choice questions about C programming concepts such as arrays, strings, pointers, file handling, macros etc. Each question is followed by 4 answer options and the correct answer is not provided.

Uploaded by

Manmeet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1|Page TECHNICAL TEST-02 : 29 APRIL 2021

1 What would be the output of the following a) 3,1 b) 2,2


code? c) 4,1 d) 3,2
main() ________________________________________
{
static char arr[]=”university”; 4 What would be the output of the following
printf(“%d”,*(arr+strlen(arr))); code?
} void main()
{
a) Error b) 10 char *i=’A’;
c) Not determined d) 0 char *j=”B”;
________________________________________
clrscr();
2 What would be the output of the following printf(j);
code? printf(i);
main() }
{
static char str[] = {86.’V’,86,86,86}; a) B,A b) B, Garbage Value
char *var; c) Garbage Value, A
int I; d) Garbage Value, Garbage Value
var = str; ________________________________________
for(i=0;i<=4;i++)
{ 5 which of the following statement is valid for
if(*var) string copy?
printf(“%c”,*var);
var++; char *str, *ptr;
} i) while(*str)
} {
*str=*ptr;
a) 86V868686 b) VVVVV ++str = ++ptr;
b) Error d) No Output }
ii) while(*str)
________________________________________ {
*++str = *++ptr;
3 What would be the output of the following };
code? iii) while(*ptr)
{
void main() *str = *ptr;
{ ++ptr;
int arr[2][3][4]= { { ++str;
{1,2,3,4},{5,6,7,8},{8,7,6,5}}, };
{{4,3,2,1},{5,6,7,8},{1,2,3,4}}};
a) i b) ii
printf(“%d%d\n”,arr[1][2][3], *(*(*(arr+1)+2))); c) iii d) none
}
________________________________________
1
2|Page TECHNICAL TEST-02 : 29 APRIL 2021

printf(“mul=%d, char=%d”,(int)((int)*arr-48),j);
6 What would be the output of the following }
code?
a) Mul=2, char=4 b) mul=4,
void main() char=2
{ c) mul=4, char=4 d) mul=2, char=2
int **i;
int *j=0; ________________________________________
i = &j;
clrscr(); 9 What would be the output of the following
code?
if( NULL != i && NULL != *i) main()
printf(“Hello”); {
getch(); FILE *fptr;
} char ch;
clrcsr();
a) error b) Hello
c) Not Determined d) No Output fptr=fopen(“myfile.txt”,’r’);
(Logically Wrong) if(fptr == NULL)
{
________________________________________ puts(“failed to open”);
exit();
7 What would be the output of the following }
code? else
void main() puts(“file opened successfully”);
{ fclose(fptr);
char *p = “UNIVERSITY’; }
clrscr();
a) Failed to open
printf(“%c”,++*(p++)); b) file opened successfully
getch(); c) No Message Displayed
} d) Error

a) No Output b)Error ________________________________________


c) N d) V
10 What would be the output of the following
________________________________________ code?
main()
8 What would be the output of the following {
code? FILE *fptr;
void main() char ch;
{ clrcsr();
char *arr =”20”;
int j = ( (int)(*arr-48)) * ( (int)(*arr-48)); fptr=fopen(“myfile.txt”,”r”);
clrscr(); if(fptr == NULL)
2
3|Page TECHNICAL TEST-02 : 29 APRIL 2021

{
puts(“failed to open”); ________________________________________
exit();
} 12 What would be the output of the following
while( (ch=getc(fp) ) != EOF) code?
putch(ch); main()
fclose(fptr); {
} char *src;
Clrscr();
a) Failed to open
b) Logical error src = (char*) malloc(printf(“ABCDEFGHI,”));
c) No Output printf(“%d”,sizeof(src));
d) Syntax error }
a) ABCDEFGHI, 10
________________________________________ b) ABCDEFGHI, 2
c) ABCDEFGHI, 9
11 What would be the output of the following d) No Output
code? ________________________________________
#include<stdio.h>
#include<conio.h> 13 What would be the output of the following
#include<string.h> code?
#include<stdio.h>
void main() #ifdef var
{ int know=0;
char string; #endif
char *n;
clrscr(); main()
{
string=”This is C Programming”; int value=0;
n= (char *) malloc(2*sizeof(char)); printf(%d,%d”,know,value);
string=”This is C Programming”; }
n = string;
a) 0,0
printf(“Original String is %s”,n); b) 0, error
strcpy(n,strrev(n)); c) Error, 0
d) Error, error
printf(“\nReversed String is %s”,n);
getch(); ________________________________________
}
14 What would be the output of the following
a) No output code?
b) Syntax error #include<stdio.h>
c) Original string is This is C programming #include<conio.h>
Reversed string is gnimmgorp C si siht
d) Logical error #define AND &&
3
4|Page TECHNICAL TEST-02 : 29 APRIL 2021

#define OR || 2 #include <complex>


#define LTE <= 3 using namespace std;
#define GTE >= 4 int main ()
5 {
main() 6 complex<double> mycomplex (20.0,
{ 2.0);
char ch = ‘0’; 7 cout << imag(mycomplex) << endl;
clrscr(); 8 return 0;
9 }
if( (ch GTE 65 AND ch LTE 90) OR (ch GTE 97
AND ch LTE 122)) a) 2
Printf (“letter”); b) 20
Else c) 40
Printf(“digit”); d) None of the mentioned
}
_______________________________________
a) Letter
b) Digit 17
c) Error What is the output of the following program?
d) No output 1 #include <iostream>
2 using namespace std;
________________________________________ 3 int main()
15 What would be the output of the following 4 {
code? 5 int a = 5;
#include<stdio.h> 6 float b;
#define CIRUM (rad) (3.14 * rad * rad); 7 cout << sizeof(++a + b);
8 cout << a;
main() 9 return 0;
{ 10 }
float rad = 1.0, cir;
cir = CIRUM(rad); a) 2 6
printf(“\n%f”, cir); b) 4 6
if(CIRUM (rad) == 6.28) c) 2 5
printf(“, correct”); d) 4 5
}
_______________________________________
a) Error
b) No output 18
c) 1.0, correct Regarding following statement which of the
d) I Quit statements is true?
e) What is the output of this program?
_______________________________________ const int pathwidth=100;
16
What is the output of this program? a. Declares a variable pathwidth with 100 as its
1 #include <iostream> initial value
4
5|Page TECHNICAL TEST-02 : 29 APRIL 2021

b. Declares a construction pathwidth with 100 as char arr[20];


its initial value int i;
c. Declares a constant pathwidth whose value for(i = 0; i < 10; i++)
will be 100 *(arr + i) = 65 + i;
d. Constructs an integer type variable with *(arr + i) = '\0';
pathwidth as identifier and 100 as value cout << arr;
return(0);
19 }
What does the following statement mean? a) ABCDEFGHIJ
int (*fp)(char*) b) AAAAAAAAAA
a) pointer to a pointer c) JJJJJJJJ
b) pointer to an array of chars d) none of the mentioned
c) pointer to function taking a char* argument and
returns an int _______________________________________
d) function taking a char* argument and returning
a pointer to int 22
What is the output of this program?
_______________________________________
#include <iostream>
20 using namespace std;
What is the output of this program? int main()
{
#include <iostream> char *ptr;
using namespace std; char Str[] = "abcdefg";
int main() ptr = Str;
{ ptr += 5;
int a = 5,b = 10,c = 15; cout << ptr;
int *arr[ ] = { &a, &b, &c}; return 0;
cout << arr[1]; }
return 0; a) fg
} b) cdef
a) 5 c) defg
b) 10 d) abc
c) 15
d) it will return some random number
23
_______________________________________ main()
{
21 char string[]="Hello World";
What is the output of this program? display(string);
}
#include <iostream> void display(char *string)
using namespace std; {
int main() printf("%s",string);
{ }
5
6|Page TECHNICAL TEST-02 : 29 APRIL 2021

1. Syntax Error 26
2. Run Time error What is the output of this program?
3. Compile time Error
4. Some address will be printed. #include <iostream>
using namespace std;
_______________________________________ int main ()
{
24 int numbers[5];
#include int * p;
main() p = numbers; *p = 10;
{ p++; *p = 20;
char s[]={'a','b','c','\n','c','\0'}; p = &numbers[2]; *p = 30;
char *p,*str,*str1; p = numbers + 3; *p = 40;
p=&s[3]; p = numbers; *(p + 4) = 50;
str=p; for (int n = 0; n < 5; n++)
str1=s; cout << numbers[n] << ",";
printf("%d",++*p + ++*str1-32); return 0;
} }
a) 10, 20, 30, 40, 50
1. 77 b) 1020304050
2. 78 c) compile error
3. 79 d) runtime error
4. Error
_______________________________________
_______________________________________
27
25 What is the output of this program?
#include
main() #include <iostream>
{ using namespace std;
char s[]={'a','b','c','\n','c','\0'}; int main()
char *p,*str,*str1; {
p=&s[3]; int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
str=p; cout << *(a[1] + 2) << *(*(a + 1) + 2) <<
str1=s; 2[1[a]];
printf("%d",++*p + ++*str1-32); return 0;
} }
a) 15 18 21
1. m b) 21 21 21
2. N c) 24 24 24
3. n d) Compile time error
4. None
_______________________________________
_______________________________________
6
7|Page TECHNICAL TEST-02 : 29 APRIL 2021

28 printf (“%d”, a[1][0]);


Q5. What will be the result of the following printf (“%d”, a[1][1]);
program ? }
#include"stdio.h" a) 2300
main() b) 2000
{ c) 0030
int a=10; d) 2030
int b=6;

if(a=3)
b++;
printf("%d %d\n",a,b++);
}

a) 10,6
b) 10,7
c) 3,6
d) 3,7
e) none

_______________________________________

29
Q10. What will be the result of the following
program ?
#include"stdio.h"
main()
{
int i=0;
for(;i++;printf("%d",i));
printf("%d",i);
}

1. 0
2. 1
3. 0 to Infinite
4. Syntax Error
_______________________________________

30
Q4. void main()
{
static int a[2][2] = {{2},{3}};
printf (“%d”,a[0][0]);
printf (“%d”, a[0][1]);
7
8|Page TECHNICAL TEST-02 : 29 APRIL 2021

Kindly submit your response at the following link:-

https://forms.gle/6HVr9yW46EbCH3Qi6

8
9|Page TECHNICAL TEST-02 : 29 APRIL 2021

You might also like