Play with C

Quiz
•
Computers
•
University
•
Hard

Computer India
Used 1+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
1. function g(int n)
{
If(n>0) return 1;
else return -1;
}
function f( int a, int b)
{
If(a>b) return g(b-a);
If(a<b) return g(a-b);
return 0;
}
If f(a,b) is called , what is returned ?
a)Always -1
b)1 if a>b, -1 if a<b, 0 otherwise
c)-1 if a>b, 1 if a<b, 0 otherwise
d)0 if a equals b, -1 otherwise
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
2. Assuming n > 2. What value does the following function compute for even n ?
int f(int n)
{
If( n equals 1) { return 1}
If(n equals 2) { return f(n-1) + n/2 }
return f(n-2) + n
}
a)1 +2 + 3 + 4 + …. +n
b)1 + (2+4+ 6+ 8+ …. +n)
c)1 + n/2 + (4 +6 + 8 + …. + n)
d)2 + 4 + 6 + 8 + ……. + n
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
3. What is the output of the following code?
int main()
{
int i = 0;
switch(i)
{
case 0 : i++;
case 1 : i+++2;
case 2 : ++i;
}
printf("%d",i++);
return 0;
}
a) 2
b) 3
c) 4
d) 5
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
4. What is the output of this program?
int main()
{
int a = 1, b = 0;
int c = a%2 ? a++ : a-- ? a=0 : ++b ? b = 2 : b++ ;
printf("%d", c);
return 0;
}
a) 1
b) 2
c) 3
d) 0
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
5. How can you write a[i][j][k][l] in equivalent pointer expression?
a) (((***(a+i)+j)+k)+l)
b) ((**(*(a+i)+j)+k)+l)
c) (*(*(*(a+i)+j)+k)+l)
d) *(*(*(*(a+i)+j)+k)+l)
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
6. What is the output of this program?
#include <stdio.h>
void test(char**);
int main()
{
char *argv[] = {"A", "B", "C", "D"};
test(argv);
return 0;
}
void test(char **p)
{
char *m;
m = (p+= sizeof(int))[-2];
printf("%s", m);
}
a) A
b) B
c) C
d) D
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
7. What will be the output of the program?
#include <stdio.h>
int main(void)
{
char p;
char buf[10]={1,2,3,4,5,6,9,8};
p=(buf+1)[5];
printf("%d",p);
return 0;
}
a. 5
b. 6
c. 9
d. None of the above
Create a free account and access millions of resources
Similar Resources on Wayground
30 questions
BUG@MASTER

Quiz
•
University
35 questions
Kuis 2

Quiz
•
University
30 questions
C Quiz 2

Quiz
•
University
30 questions
C-Language Q1

Quiz
•
University
30 questions
Coding Club_SNSCE Quiz (28-04-2023)

Quiz
•
University
25 questions
C PROGRAMMING

Quiz
•
University
25 questions
C Programing

Quiz
•
University
35 questions
CodeChef (Secret Snippet)

Quiz
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade