WorksheetsTECHFEST QUALIFYING ROUND
Total questions: 20
Worksheet time: 15mins
#include int main(){
int x;
x=10,20,30;
printf("%d",x);
return 0;
}
20
10
30
ERROR
#include int main()
{
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
return 0;
}
-1
0
1
11
int main() {
int arr[] = {1, 2, 4, 5, 6};
int n = 6;
int sum = n * (n + 1) / 2;
int actual_sum = 0;
for (int i = 0; i < n - 1; i++) {
actual_sum += arr[i];
}
int missing_number = sum - actual_sum;
printf("Missing number is %d\n", missing_number);
return 0;
}
5
4
3
2
int main() {
int arr[3][3] = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
7 8 9
4 5 6
1 2 3
3 2 1
6 5 4
9 8 7
1 4 7
2 5 8
3 6 9
1 2 3
4 5 6
7 8 9
int main() {
int n;
for(n = 7; n!=0; n--)
printf("n = %d", n--);
getchar();
return 0;
}
Error
n = 7
Infinite Loop
n = 6
int main(){
int i=0;
while ( +(+i--) != 0)
i-=i++;
printf("%d",i);
return 0;
}
0
1
-1
Error
int main(){
if (printf("cIsgood"))
printf("I know c");
else
printf("I know c++");
return 0;
}
cIsgoodIknow c
Error
I know c++
cIsgoodIknowc++
int main() {
int a[] = {1, 2, 3, 4, 5};
int *p = a;
p++;
printf("%d", *(p + 2));
return 0;
}
1
3
4
5
int main() {
int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int (*p)[3] = a + 1;
printf("%d %d %d\n", (*p)[0], (*p)[1], (*p)[2]);
return 0;
}
4 5 6
Undefined behavior
7 8 9
1 2 3
int main(){
float a=3.15529;
printf("%2.1f\n", a);
return 0;
}
3.1
3.16
3.1553
3.2
#include<stdio.h>
int main()
{
printf("%%%%\n");
return 0;
}
%%%
%%
%
%%%%
int main (){
int a, b;
a = b = 4;
b = a++;
printf ("%d %d %d %d", a++, --b, ++a, b--);
}
5 3 6 3
5 3 7 3
6 3 7 3
5 4 6 3
int main (){
static int num = 8;
printf ("%d", num = num - 2);
if (num != 0)
main ();
}
642
6420
Infinite Recursion
86420
int main(){
int a = 10, b = 25;
a = b++ + a++;
b = ++b + ++a;
printf("%d %d ", a, b);
}
35 61
36 63
35 62
36 62
int main(){
int x = 24, y = 39, z = 45;
z = x + y;
y = z - y;
x = z - y;
printf("%d %d %d", x, y, z);
}
24 39 63
39 24 63
39 24 45
24 39 45
void main(){
printf("%d", printf("computer science"));
}
computer science16
16computer science
Garbage value
computer science
int main() {
char ch = 'A';
printf("%c %d\n", ch, ch);
return 0;
}
AA
A 65
Compilation Error
65 65
int main() {
char str1[] = "Hello";
char str2[] = "Hello";
if (str1 == str2)
printf("Equal\n");
else
printf("Not Equal\n");
return 0;
}
Undefined Error
Equal
Compilation Error
Not Equal
int main(){
int a = 2, b = 3;
if (a-- > 0 && ++b > 3)
{
printf("%d %d\n", a, b);
}
return 0;
}
1 4
2 4
2 3
int main() {
int a = 3, b = 2, c;
c = a++ + --b;
printf("%d %d %d\n", a, b, c);
return 0;
}
5 1 5
3 2 5
4 2 3
4 1 4
