Escolar Documentos
Profissional Documentos
Cultura Documentos
A) 10 B) 5 C) 4 D) none
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
return 0;
}
A) for B) if C) do D) while
int main()
{
int a, b = 5;
a = b + NULL;
printf(“%d”, a);
return 0;
}
A) 6 B) 5 5 C) 5 D) None
6. How to deallocate memory in *ptr without using free()?
int *ptr = (int*) malloc(10);
void main()
{
int i = 5, j = 6, z;
printf("%d", i+++j);
}
A) 12 B) 11 C) 13 D) none of these
8. What would be the equivalent pointer expression for referring the array
element a[i][j][k][l]?
A) ((((a+i)+j)+k)+l) B) *(*(*(*(a+i)+j)+k)+l)
C) (((a+i)+j)+k+l) D) ((a+i)+j+k+l)
#include<stdio.h>
void main()
{
int a[] = {10, 20, 30};
printf("%d", *a+1);
}
A) 10 B) 20 C) 11 D) 21
10. If a variable is a pointer to a structure, then which of the following operator is used to
access data members of the structure through the pointer variable?
A) . B) * C) & D) ->
12. Given b=110 and c=20, what is the value of 'a' after execution of the expression
a = b -= c *= 5?
14. Consider the following program and choose the correct one ?
void main()
{
int a, b = 2, c;
a = 2 * (b++);
c = 2 * (++b);
printf(“a = %d, c = %d”, a, c);
}
A) a = 4, c = 8 B) a = 3, c = 8 C) b = 3, c = 6 D) a = 4, c = 6
void main()
{
int i = 1, j = -1;
if((printf("%d", i)) < (printf("%d", j)))
printf("%d", i);
else
printf("%d", j);
}
A) 1 -1 1 B) 1 -1 -1 C) 1 D) complier error
void main()
{
int a = 1, b;
b = a++ + ++a + a++;
printf("%d\t%d", b, a);
}
A) 4 4 B) 5 4 C) 6 4 D) 7 4
18. Which operator from the following has the lowest priority?
int main()
{
printf(“Resonous”);
main();
return 0;
}
20. In case of a conflict between the names of a local and global variable what happens?
void main()
{
int i = 10;
printf("%d ", i);
{
int i = 20;
printf("%d ", i);
i++;
printf("%d ", i);
}
printf("%d ", i);
}
A) 10 10 11 11 B) 10 20 21 21 C) 10 20 21 20 D) 10 20 21 10
22. Which of the following function is more appropriate for reading in a multi-word string?
int main()
{
char* ptr;
*ptr = (int*)malloc(30);
strcpy(ptr, "RAM");
printf("%s", ptr);
free(ptr);
return 0;
}
#include<stdio.h>
int c[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
main()
{
int a, b=0;
for(a = 0; a < 10; ++a)
if(c[a]%2 == 1)
b += c[a];
printf("%d", b);
}
A) 20 B) 25 C) 24 D) 30
Section II: Descriptive
27. Write a C-program to finding the given number is EVEN or ODD without using Arithmetic
Operators?
30. Write a C Program to Add Two Complex Numbers by Passing Structure to a Function?