Intra

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Q1-What happens if you try to compile and run this program?

#include <stdio.h>
int main(){
int a[]={10,20};
int * p = a;

printf("%d ", *p);


p ++;
printf("%d",*p);
return 0;
}

Select one:
a. Compilation error
b. 10 20
c. 10 and unpredictable value
d. 20 10
Q2-What will be the output of the following C program?
Assume that size of char type is 1 byte and size of pointer
is 8 bytes.
#include <stdio.h>
#include <string.h>
int main(){
char* string = "Hello World";
printf ("%ld, %ld", strlen(string), sizeof(string));
}
Select one:
a. 12, 12
b. 11, 12
c. 11, 8
d. 11, 11
e. 12, 8
Q3-What will be the output of the following C program?
#include<stdio.h>
int main()
{
int x = 3;
float y = 3.0;
if(x == y)
printf("x and y are equal");
else
printf("x and y are not equal");
return 0;
}
Select one:
a. x and y are not equal
b. Unpredictable
c. No output
d. x and y are equal
Q4-What will be the output ?

#include<stdio.h>
int main ()
{
printf("\n%d %d\n", 10&20,10/20);
}

Select one:
a. 0 0
b. 10 0
c. 10 10
d. 0 30
e. 20 20
Q5-What is the output of this C code?

#include <stdio.h>
int main()
{
char p;
char b[10] = {1,2, 3,4, 5, 6, 9, 8};
p = (b +1)[5];
printf("%d", p);
return 0;
}
Select one:
a. 6
b. 5
c. 9
d. None of the above
Select one:
Q6-What will be the output of the following C program? a. 7 0.300000
#include<stdio.h> 1 0.300000
int main() 5 0.400000
{ 1 0.200000
9 0.600000
int a[5],*p,i; b. 7 0.400000
float b[5],*q; 9 0.600000
for(i=0;i<5;i++) 5 0.200000
{ 1 0.300000
1 0.300000
a[i]=1; b[i]=0.3;
c. 1 0.300000
} 7 0.400000
p=&a[3]; 1 0.300000
q=&b[3]; 5 0.200000
*p=5; 9 0.600000
d. 1 0.300000
*(p-1)=7; 7 0.400000
*(p+1)=9; 5 0.200000
*q=.2; 9 0.600000
*(q-1)=.4; 1 0.300000
*(q+1)=.6; e. 1 0.300000
1 0.300000
for(i=0;i<5;i++) 7 0.400000
printf("\n%d %f",a[i],b[i]); 5 0.200000
} 9 0.600000
Q7-Which of the following condition checks will
print 10 twice (afficher 10 deux fois)?

void main(){
int a=10;
if(________)
printf("\n%d",a);
else
printf("\n%d %d",a,a);
}
Select one:
a. None of the above
b. a==10
c. printf("\n%d",a)
d. a <= 10
Q8-Having the following array int X[ ] = {4,1, 3, 2};
which of the following approaches is invalid to acces its
elements?

Select one or more:


a. *(X+i)
b. X[i]
c. X+i
d. &X[i]
e. *&X[i]
Q9- How many times the below loop will be executed?

#include<stdio.h>
void main () {
int x,y ;
for (x=5;x>=1;x--)
{
for(y=1;y<=x;y++)
printf("%d\n",y);
}
}
Select one:
a. 14
b. 10
c. 11
d. 13
e. 15
Q10-What is the output of this C
code?
'a' hex:61 oct:141 dec:97

#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
Select one:
a. run time error
b. a
c. a.0000000
d. 97.000000
Q11-Find the output, we assume that code ASCII of 'a' is 97:

#include<stdio.h>
int main() {
char c='a';
switch(c) {
case 97: printf("97"); break;
case 'a': printf("98"); break;
case 99: printf("99"); break;
default: printf("default");
}
}
Select one:
a. error
b. 97
c. 'a'
d. 98
Q12-What will be the output of the following C program?
#include <stdio.h>
int main(){
int A[] = {1, 2, 3, 4, 5);
printf (”%d", *(A + 2));
return 0;
}
Select one:
a. 1
b. 3
c. 5
d. Compile error
e. 2
f. 4
Q13-What will be the output of the following C program?

int i = 20;
printf("%x", i);
what is the output?

Select one:
a. 24
b. 14
c. 20
d. x14
Q14 -What is prototype of a function in C

Select one:
a. It is the return type of a function
b. It is declaration of a function
c. It is the return data of the function
d. It is a datatype
Q15-How do you differentiate function declaration from function definition?

Select one or more:


a. Function declaration need not mention names of formal parameters
b. Function declaration doesn't contain code
c. Function definition must always come after main() function.
d. Function declaration doesn't mention return type

Q15-Comment différenciez-vous la déclaration de fonction de la définition de fonction?

Sélectionnez un ou plusieurs:
a. La déclaration de fonction n'a pas besoin de mentionner les noms des paramètres formels,
b. La déclaration de fonction ne contient pas de code.
c. La définition de fonction doit toujours venir après la fonction main ().
d. La déclaration de fonction ne mentionne pas le type de retour.
Q16-Find the output:

int main()
{
int c,a=25;
c= printf("%d",a);
printf(" %d",c);
return 0;
}
Select one:
a. 1
b. 25 1
c. 2
d. error
e. 25 2
Q17- how many times this abc will be printed
#include<stdio.h>
int main(){
int x;
for(x=-1; x<=10; x++){
if(x < 5)
continue;
else
break;
printf("abc");
}
return 0;
}
Select one:
a. Infinite times
b. 11 times
c. 0 times
d. 10 times
Q18-What is the output of this C code?

#include <stdio.h>
int main()
{
int a,b,c;
c=scanf("%d%d",&a,&b);// assume a=5
b=6
printf("%d",c);
return 0; Select one:
} a. 2
b. 6
c. 5
d. compile time error
Q19-What will be the output of following statements ?

char x[] = "hello hi";


printf("%d%d",sizeof(*x),sizeof(x));

Select one:
a. 19
b. 88
c. 18
d. 29
Q20-what is output of this program?
#include<stdio.h>
int main(){
int i=0;

for(; i<=5; i++);


printf("%d", i);
return 0;
}
Select one:
a. 1 2 3 4 5 6
b. 1 2 3 4 5
c. 0 1 2 3 4 5
d. 6
e. 0 1 2 3 4
Q21-What will be the output ?

#include<stdio.h>
int main ()
{
printf("%d",'B' < 'A' );
}

Select one:
a. 1
b. 0
c. None of these
d. Error
Q22- What will be the output of the following program code?
Note: \b is the backspace character (The "Left Arrow" key=backspace key)

#include<stdio.h>
int main (void)
{
printf("\n abc\b\b\binfo world");
return 0;
}
Select one:
a. abc info world
b. info world
c. strxfrm
d. strcut
Q23- What is going to be the result of the following code?
#include<stdio.h>
int main(){
double number = 3.14;
double *sPtr = &number;
*sPtr *= 2;
printf("%lf\n",number);
double **dPtr = &sPtr;
**dPtr *= 3;
Select one:
printf("%lf\n",number);
a. 6.280000
retourn 0; 18.840000
} b. 18.780000
5.140000
c. 18.840000
6.280000
d. 5.140000
18.630000
e. It throws an Error
Q24-What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("a=%d, b=%d, c=%d", a, b,c);
}
Select one:
a. a = 2, b = 2, c = 1
b. a = 2, b = 1, c = 2
c. a = 1, b = 1, c = 2
d. a = 1, b = 2, c = 1
Q25-Find the output:

#include <stdio.h>
int main() {
int a = 1;
printf("size of a is %d, ", sizeof(++a));
printf("value of a is %d", a);
return 0;
}
Select one:
a. None of the above
b. size of a is 4, value of a is 1
c. size of a is 5, value of a is 1
d. size of a is 2, value of a is 1
e. size of a is 4, value of a is 2
Q26- How many times "CSE GURUS" is printed?

#include<stdio.h>
int main()
{
int i = -5;
while (i <= 5)
{
if (i >= 0)
break;
else { Select one:
i++; a. 10 times
continue; b. 0 times
} c. Infiniite times
printf("CSE GURUS"); d. 5 times
}
return 0;
}
Q27-What is the output of this C code?

#include <stdio.h>
int main()
{
int c;
c=printf("%d",printf("%d",printf("1234")));
return 0;
}

Select one:
a. 123444
b. 123434
c. 123441
d. compile time error
Q28
#include<stdio.h>
int main() Select one:
{ a. Output1:8 d. Output1:8
Output2:4 Output2:4
int a[]={6,2,8,4,9},*p,n; Output3:8 Output3:8
p=a+2; Output4:4 Output4:8
n=*p; Output5:2 Output5:2
Output6:4 Output6:4
printf("\nOutput1:%d",n); Output7:3 Output7:8
n=*++p; Output8:8 Output8:3
printf("\nOutput2:%d",n); b. Output1:8 e. Output1:8
n=*(--p); Output2:4 Output2:4
Output3:8 Output3:8
printf("\nOutput3:%d",n); Output4:8 Output4:8
n=*p--; Output5:2 Output5:4
printf("\nOutput4:%d",n); Output6:4 Output6:2
Output7:3 Output7:3
n=(*p)++; Output8:8 Output8:8
printf("\nOutput5:%d",n); c. Output1:4 f. Output1:8
n=++(*p); Output2:8 Output2:4
printf("\nOutput6:%d",n); Output3:8 Output3:8
Output4:8 Output4:4
n=--*p; Output5:2 Output5:2
printf("\nOutput7:%d",n); Output6:4 Output6:4
n=*(++p); Output7:3 Output7:3
Output8:8 Output8:8
printf("\nOutput8:%d",n);
}
Q29-In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h

Select one:
a. During execution
b. During preprocessing
c. During editing
d. During linking
Q30-What will be the output of the following C program?
#include <stdio.h>
int main(){
int A[] = {1, 2, 3, 4, 5};
printf ("%d", ++A);
return 0;
}

Select one:
a. 1
b. Compile error
c. 2
d. 5
e. 4
f. 3
Q31- What is the output of this C code?
#include<stdio.h>
int main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i)
{
case 0: i += 5;
case 1: i += 2;
case 5:i += 5;
default:i += 4; break; Select one:
} a. 16 21
printf("%d ", i); b. 7 12 17 22
} c. Compiler Error
return 0; d. 5 10 15 20
}
Q32- What is the output of this C code?

#include <stdio.h>
int main()
{
int a,b,c;
c=printf("hai%d",scanf("%d%d",&a,&b)); //we assume that the user enters a=5 b=6 as the
input
printf("%d",c);
return 0;
}

Select one:
a. compile time error
b. hai34
c. hai22
d. hai24
Q33-Which of the following statements is invalid to
allocate memory dynamically in C?

Select one or more:


a. int *H = (int*)malloc(n*int);
b. int *H = (int*)malloc(n*sizeof(int));
c. int *H = (int)malloc(n*sizeof(int));
d. int H = (int*)malloc(n*sizeof(int));
e. int *H = (*int)malloc(n*sizeof(int));
Q34-Find output.
#include<stdio.h>
int main()
{
int a=25;
printf("%o %x",a,a);
return 0;
}

Select one:
a. 12 42
b. 025 0X25
c. 25 25
d. 31 19
Q35 -Which of the following is true about pointer?

Select one or more:


a. A pointer may be pointing to null
b. All pointers occupy same amount of memory
c. All pointers contain address of a memory location
Q36-What will be output if you will compile and execute the following
c code?

#include<stdio.h>
#include<string.h>
int main()
{
printf("%d %d",sizeof("string"),strlen("string"));
return 0;

}
Select one:
a. 6 7
b. 7 7
c. 6 6
d. 7 6
Q37-What will be output if you will compile and execute the following c code?

#include <stdio.h>
int main()
{
if(printf("CQUESTIONBANK"))
printf("I KNOW C");
else
printf("I KNOW C++");
}
Select one:
a. I KNOW C
b. I KNOW C++
c. CQUESTIONBANKI KNOW C
d. CQUESTIONBANKI KNOW C++
Q38-
#include <stdio.h>
int main()
{
int y[4] = {6, 7, 8, 9};
int*ptr = y + 2;
printf("%d\n", ptr[1]);
}
What is printed when the sample code above is executed?

Select one:
a. 7
b. 8
c. 6
d. 9
Q39-what is output of this program?

#include<stdio.h>
int main()
{
int a = 500, b = 100, c=300;
if(!a >= 400)
b = 300;
c = 400;
printf("b = %d c = %d\n", b, c);
return 0; Select one:
a. b = 100 c = garbage
} b. b = 300 c = 200
c. b = 100 c = 400
d. b = 300 c = garbage
Q40-What is the output of following program code:

#include<stdio.h>
int main() {

float x = 10.7,i;

i = (int) x;
printf("%f",i);
return 0;
}
Select one:
a. 10.700000
b. 10
c. garbage value (une valeur aléatoire)
d. 10.000000

You might also like