Krantiguru Shyamji Krishna Verma Kachchh University 2009 B.C.A Computer Application C language programming - exam paper
1. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
rem = 3.14 % 2.1; |
|
rem = modf(3.14, 2.1); |
|
rem = fmod(3.14, 2.1); |
|
Remainder cannot be obtain in floating point division. |
Which of the following special symbol allowed in a variable name?
* (asterisk) |
| (pipeline) |
||
- (hyphen) |
_ (underscore) |
How would you round off a value from 1.66 to 2.0?
ceil(1.66) |
floor(1.66) |
||
roundup(1.66) |
roundto(1.66) |
By default a real number is treated as a
float |
double |
||
long double |
far double |
Which of the following is not user defined data type?
1 : |
struct book { char name[10]; float price; int pages; }; |
2 : |
long int l = 2.35; |
3 : |
enum day {Sun, Mon, Tue, Wed}; |
1 |
2 |
||
3 |
Both 1 and 2 |
Is the following statement a declaration
or definition?
extern int i;
Declaration |
Definition |
||
Function |
Error |
Identify which of the following are declarations
1 : |
extern int x; |
2 : |
float square ( float x ) { ... } |
3 : |
double pow(double, double); |
1 |
2 |
||
1 and 3 |
3 |
In the following program where is the variable a getting defined and where it is getting declared?
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
extern int a is declaration, int a = 20 is the definition |
|
int a = 20 is declaration, extern int a is the definition |
|
int a = 20 is definition, a is not defined |
|
a is declared, a is not defined |
When we mention the prototype of a function?
Defining |
Declaring |
||
Prototyping |
Calling |
What is the output of the program given below ?
#include<stdio.h>
int main()
{
enum status { pass, fail, atkt};
enum status stud1, stud2, stud3;
stud1 = pass;
stud2 = atkt;
stud3 = fail;
printf("%d, %d, %d\n", stud1, stud2, stud3);
return 0;
}
0, 1, 2 |
1, 2, 3 |
||
0, 2, 1 |
1, 3, 2 |
What will be the output of the program in 16 bit platform (Turbo C under DOS)?
#include<stdio.h>
int main()
{
extern int i;
i = 20;
printf("%d\n", sizeof(i));
return 0;
}
2 |
|
4 |
|
vary from compiler |
|
Linker Error : Undefined symbol 'i' |
What is the output of the program?
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
20 |
0 |
||
Garbage Value |
Error |
What is the output of the program in Turbo C (in DOS 16-bit OS)?
#include<stdio.h>
int main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3));
return 0;
}
2, 4, 6 |
4, 4, 2 |
||
2, 4, 4 |
2, 2, 2 |
What is the output of the program
#include<stdio.h>
int main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("%d, %f\n", e.age, e.sal);
return 0;
}
0, 0.000000 |
Garbage values |
||
Error |
None of above |
What will be the output of the program?
#include<stdio.h>
int X=40;
int main()
{
int X=20;
printf("%d\n", X);
return 0;
}
20 |
40 |
||
Error |
No Output |
What is the output of the program
#include<stdio.h>
int main()
{
int x = 10, y = 20, z = 5, i;
i = x < y < z;
printf("%d\n", i);
return 0;
}
0 |
1 |
||
Error |
None of these |
What is the output of the program
#include<stdio.h>
int main()
{
extern int fun(float);
int a;
a = fun(3.14);
printf("%d\n", a);
return 0;
}
int fun(int aa)
{
return (int)++aa;
}
3 |
3.14 |
||||||||||
0 |
4 |
||||||||||
Compile Error |
|||||||||||
What is the output of the program #include<stdio.h> int main() { int a[5] = {2, 3}; printf("%d, %d, %d\n", a[2], a[3], a[4]); return 0; } |
|||||||||||
|
10. |
What is the output of the program #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i); return 0; } |
||||||||
|
|||||||||
In the following program how long will the for loop get executed? #include<stdio.h> int main() { int i; for(;scanf("%s", &i); printf("%d\n", i)); return 0; } |
|||||||||
|
12. |
What will be the output of the program? #include<stdio.h> int main() { int X=40; { int X=20; printf("%d ", X); } printf("%d\n", X); return 0; } |
|||||||
|
||||||||
A long double can be used if range of a double is not enough to accommodate a real number. |
||||||||
|
2. |
A float is 4 bytes wide, whereas a double is 8 bytes wide. |
|||
|
3. |
If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function. |
|||
|
4. |
Size of short integer and long integer can be verified using the sizeof() operator. |
|||
|
5. |
Range of double is -1.7e-38 to 1.7e+38 |
||||
|
|||||
Size of short integer and long integer would vary from one platform to another. |
|||||
|
7. |
Range of float id -2.25e-308 to 2.25e+308 |
||||||||
|
|||||||||
How many times "IndiaBIX" is get printed? #include<stdio.h> int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("IndiaBIX"); } return 0; } |
|||||||||
|
2. |
How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } |
|||||||
|
3. |
Which of the following is not logical operator? |
|||||||
|
4. |
In mathematics and computer programming, which is the correct order of mathematical operators ? |
|||||||
|
5. |
Which of the following cannot be checked in a switch-case statement? |
||||||||
|
|||||||||
What will be the output of the program? #include<stdio.h> int main() { int i=0; for(; i<=5; i++); printf("%d,", i); return 0; } |
|||||||||
|
2. |
What will be the output of the program? #include<stdio.h> int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; } |
|||||||
|
3. |
What will be the output of the program? #include<stdio.h> int main() { int a = 500, b = 100, c; if(!a >= 400) b = 300; c = 200; printf("b = %d c = %d\n", b, c); return 0; } |
|||||||
|
4. |
What will be the output of the program? #include<stdio.h> int main() { unsigned int i = 65535; /* Assume 2 byte integer*/ while(i++ != 0) printf("%d",++i); printf("\n"); return 0; } |
|||||||
|
5. |
What will be the output of the 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; } |
||||||||
|
|||||||||
What will be the output of the program, if a short int is 2 bytes wide? #include<stdio.h> int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; } |
|||||||||
|
7. |
What will be the output of the program? #include<stdio.h> int main() { char ch; if(ch = printf("")) printf("It matters\n"); else printf("It doesn't matters\n"); return 0; } |
|||||||
|
8. |
What will be the output of the program? #include<stdio.h> int main() { unsigned int i = 65536; /* Assume 2 byte integer*/ while(i != 0) printf("%d",++i); printf("\n"); return 0; } |
|||||||
|
9. |
What will be the output of the program? #include<stdio.h> int main() { float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n"); return 0; } |
|||||||
|
10. |
What will be the output of the program? #include<stdio.h> int main() { int a=0, b=1, c=3; *((a) ? &b : &a) = a ? b : c; printf("%d, %d, %d\n", a, b, c); return 0; } |
|||||||
|
||||||||
What will be the output of the program? #include<stdio.h> int main() { int k, num = 30; k = (num < 10) ? 100 : 200; printf("%d\n", num); return 0; } |
||||||||
|
12. |
What will be the output of the program? #include<stdio.h> int main() { int a = 300, b, c; if(a >= 400) b = 300; c = 200; printf("%d, %d, %d\n", a, b, c); return 0; } |
|||||||
|
13. |
What will be the output of the program? #include<stdio.h> int main() { int x=1, y=1; for(; y; printf("%d %d\n", x, y)) { y = x++ <= 5; } printf("\n"); return 0; } |
|||||||
|
14. |
What will be the output of the program? #include<stdio.h> int main() { int i = 5; while(i-- >= 0) printf("%d,", i); i = 5; printf("\n"); while(i-- >= 0) printf("%i,", i); while(i-- >= 0) printf("%d,", i); return 0; } |
|||||||
|
15. |
What will be the output of the program? #include<stdio.h> int main() { int i=3; switch(i) { case 1: printf("Hello\n"); case 2: printf("Hi\n"); case 3: continue; default: printf("Bye\n"); } return 0; } |
||||||||
|
|||||||||
What will be the output of the program? #include<stdio.h> int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; } |
|||||||||
|
17. |
What will be the output of the program? #include<stdio.h> int main() { int i=4; switch(i) { default: printf("This is default\n"); case 1: printf("This is case 1\n"); break; case 2: printf("This is case 2\n"); break; case 3: printf("This is case 3\n"); } return 0; } |
|||||||
|
18. |
What will be the output of the program? #include<stdio.h> int main() { int i = 1; switch(i) { printf("Hello\n"); case 1: printf("Hi\n"); break; case 2: printf("\nBye\n"); break; } return 0; } |
|||||||
|
19. |
What will be the output of the program? #include<stdio.h> int main() { char j=1; while(j < 5) { printf("%d, ", j); j = j+1; } printf("\n"); return 0; } |
|||||||
|
20. |
What will be the output of the program? #include<stdio.h> int main() { int x, y, z; x=y=z=1; z = ++x || ++y && ++z; printf("x=%d, y=%d, z=%d\n", x, y, z); return 0; } |
|||||||
|
||||||||
1. |
A short integer is at least 16 bits wide and a long integer is at least 32 bits wide. |
|||||||
|
2. |
If scanf() is used to store a value in a char variable then along with the value a carriage return(\r) also gets stored it. |
|||
|
3. |
The modulus operator cannot be used with a long double. |
|||
|
4. |
A char variable can store either an ASCII character or a Unicode character. |
|||
|
Function
1. |
The keyword used to transfer control from a function back to the calling function is |
|||||||
|
2. |
What is the notation for following functions? 1. int f(int a, float b) { /* Some code */ }
2. int f(a, b) int a; float b; { /* Some code */ } |
|||||||
|
3. |
How many times the program will print "IndiaBIX" ? #include<stdio.h>
int main() { printf("IndiaBIX"); main(); return 0; } |
|||||||
|
||||||||
1. |
What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h>
int main() { int fun(); int i; i = fun(); printf("%d\n", i); return 0; } int fun() { _AX = 1990; } |
|||||||
|
2. |
What will be the output of the program? #include<stdio.h> void fun(int*, int*); int main() { int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0; } void fun(int *i, int *j) { *i = *i**i; *j = *j**j; } |
|||||||
|
3. |
What will be the output of the program? #include<stdio.h> int i; int fun();
int main() { while(i) { fun(); main(); } printf("Hello\n"); return 0; } int fun() { printf("Hi"); } |
|||||||
|
4. |
What will be the output of the program? #include<stdio.h> int reverse(int);
int main() { int no=5; reverse(no); return 0; } int reverse(int no) { if(no == 0) return 0; else printf("%d,", no); reverse (no--); } |
|||||||
|
5. |
What will be the output of the program? #include<stdio.h> void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int);
int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n > 0) { fun(--n); printf("%d,", n); fun(--n); } } |
|||||||
|
||||||||
6. |
What will be the output of the program? #include<stdio.h> int sumdig(int); int main() { int a, b; a = sumdig(123); b = sumdig(123); printf("%d, %d\n", a, b); return 0; } int sumdig(int n) { int s, d; if(n!=0) { d = n%10; n = n/10; s = d+sumdig(n); } else return 0; return s; } |
|||||||
|
7. |
What will be the output of the program? #include<stdio.h>
int main() { void fun(char*); char a[100]; a[0] = 'A'; a[1] = 'B'; a[2] = 'C'; a[3] = 'D'; fun(&a[0]); return 0; } void fun(char *a) { a++; printf("%c", *a); a++; printf("%c", *a); } |
|||||||
|
8. |
What will be the output of the program? #include<stdio.h>
int main() { int fun(int); int i = fun(10); printf("%d\n", --i); return 0; } int fun(int i) { return (i++); } |
|||||||
|
9. |
What will be the output of the program? #include<stdio.h> int check (int, int);
int main() { int c; c = check(10, 20); printf("c=%d\n", c); return 0; } int check(int i, int j) { int *p, *q; p=&i; q=&j; i>=45 ? return(*p): return(*q); } |
|||||||
|
10. |
What will be the output of the program? #include<stdio.h> int fun(int, int); typedef int (*pf) (int, int); int proc(pf, int, int);
int main() { printf("%d\n", proc(fun, 6, 6)); return 0; } int fun(int a, int b) { return (a==b); } int proc(pf p, int a, int b) { return ((*p)(a, b)); } |
|||||||
|
||||||||
11. |
What will be the output of the program? #include<stdio.h>
int main() { int i=1; if(!i) printf("IndiaBIX,"); else { i=0; printf("C-Program"); main(); } return 0; } |
|||||||
|
12. |
What will be the output of the program? #include<stdio.h>
int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); }
int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; } |
|||||||
|
13. |
What will be the output of the program? #include<stdio.h> int i; int fun1(int); int fun2(int);
int main() { extern int j; int i=3; fun1(i); printf("%d,", i); fun2(i); printf("%d", i); return 0; } int fun1(int j) { printf("%d,", ++j); return 0; } int fun2(int i) { printf("%d,", ++i); return 0; } int j=1; |
|||||||
|
14. |
What will be the output of the program? #include<stdio.h> int func1(int);
int main() { int k=35; k = func1(k=func1(k=func1(k))); printf("k=%d\n", k); return 0; } int func1(int k) { k++; return k; } |
|||||||
|
15. |
What will be the output of the program? #include<stdio.h>
int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %d\n", k, l); return 0; } int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } |
|||||||
|
||||||||
16. |
What will be the output of the program? #include<stdio.h> int check(int); int main() { int i=45, c; c = check(i); printf("%d\n", c); return 0; } int check(int ch) { if(ch >= 45) return 100; else return 10; } |
|||||||
|
17. |
If int is 2 bytes wide.What will be the output of the program? #include <stdio.h> void fun(char**);
int main() { char *argv[] = {"ab", "cd", "ef", "gh"}; fun(argv); return 0; } void fun(char **p) { char *t; t = (p+= sizeof(int))[-1]; printf("%s\n", t); } |
|||||||
|
18. |
What will be the output of the program? #include<stdio.h> int fun(int(*)());
int main() { fun(main); printf("Hi\n"); return 0; } int fun(int (*p)()) { printf("Hello "); return 0; } |
|||||||
|
19. |
What will be the output of the program? #include<stdio.h>
fun(int i) { i++; return i; }
int main() { int fun(int); int i=3; fun(i=fun(fun(i))); printf("%d\n", i); return 0; } |
|||||||
|
20. |
What will be the output of the program? #include<stdio.h> int fun(int); int main() { float k=3; fun(k=fun(fun(k))); printf("%f\n", k); return 0; } int fun(int i) { i++; return i; } |
|||||||
|
21.
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i=0;
i++;
if(i<=5)
{
printf("IndiaBIX");
exit(1);
main();
}
return 0;
}
Prints "IndiaBIX" 5 times |
||||||||
Function main() doesn't calls itself |
||||||||
Infinite loop |
||||||||
Prints "IndiaBIx" |
||||||||
1. |
Point out the error in the program
f(int a, int b) { int a; a = 20; return a; } |
|||||||
|
2. |
Point out the error in the program #include<stdio.h>
int main() { int f(int); int b; b = f(20); printf("%d\n", b); return 0; } int f(int a) { a > 20? return(10): return(20); } |
|||||||
|
3. |
Point out the error in the program #include<stdio.h>
int main() { int a=10; void f(); a = f(); printf("%d\n", a); return 0; } void f() { printf("Hi"); } |
|||||||
|
||||||||
1. |
A function cannot be defined inside another function |
|||||||
|
2. |
Functions cannot return more than one value at a time |
|||
|
3. |
If return type for a function is not specified, it defaults to int |
|||
|
4. |
In C all functions except main() can be called recursively. |
|||
|
5. |
Functions can be called either by value or reference |
|||
|
||||
6. |
A function may have any number of return statements each returning different values. |
|||
|
7. |
Names of functions in two different files linked together must be unique |
|||
|
Array
1. |
What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? |
|||||||
|
2. |
What does the following declaration
mean? |
|||||||
|
3. |
In C, if you pass an array as an argument to a function, what actually gets passed? |
|||||||
|
||||||||
1. |
What will be the output of the program ? #include<stdio.h>
int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } |
|||||||
|
2. |
What will be the output of the program ? #include<stdio.h>
int main() { static int a[2][2] = {1, 2, 3, 4}; int i, j; static int *p[] = {(int*)a, (int*)a+1, (int*)a+2}; for(i=0; i<2; i++) { for(j=0; j<2; j++) { printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i), *(*(i+p)+j), *(*(p+j)+i)); } } return 0; } |
|||||||
|
3. |
What will be the output of the program ? #include<stdio.h>
int main() { void fun(int, int[]); int arr[] = {1, 2, 3, 4}; int i; fun(4, arr); for(i=0; i<4; i++) printf("%d,", arr[i]); return 0; } void fun(int n, int arr[]) { int *p=0; int i=0; while(i++ < n) p = &arr[i]; *p=0; } |
|||||||
|
4. |
What will be the output of the program ? #include<stdio.h> void fun(int **p);
int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0; } void fun(int **p) { printf("%d\n", **p); } |
|||||||
|
5. |
What will be the output of the program ? #include<stdio.h>
int main() { static int arr[] = {0, 1, 2, 3, 4}; int *p[] = {arr, arr+1, arr+2, arr+3, arr+4}; int **ptr=p; ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); *ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); *++ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); ++*ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); return 0; } |
|||||||
|
||||||||
6. |
What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes? #include<stdio.h>
int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u\n", a+1, &a+1); return 0; } |
|||||||
|
7. |
What will be the output of the program in Turb C (under DOS)? #include<stdio.h>
int main() { int arr[5], i=0; while(i<5) arr[i]=++i;
for(i=0; i<5; i++) printf("%d, ", arr[i]);
return 0; } |
|||||||
|
8. |
What will be the output of the program ? #include<stdio.h>
int main() { int arr[1]={10}; printf("%d\n", 0[arr]); return 0; } |
|||||||
|
9. |
What will be the output of the program if the array begins at address 65486? #include<stdio.h>
int main() { int arr[] = {12, 14, 15, 23, 45}; printf("%u, %u\n", arr, &arr); return 0; } |
|||||||
|
10. |
What will be the output of the program ? #include<stdio.h>
int main() { float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d\n", sizeof(arr)/sizeof(arr[0])); return 0; } |
|||||||
|
11.
What will be the output of the program if the array begins 1200 in memory?
#include<stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}
1200, 1202, 1204 |
1200, 1200, 1200 |
|||||||||
1200, 1204, 1208 |
1200, 1202, 1200 |
|||||||||
1. |
Which of the following is correct way to define the function fun() in the below program? #include<stdio.h>
int main() { int a[3][4]; fun(a); return 0; } |
|||||||||
|
||||||||||
2. |
Which of the following statements mentioning the name of the array begins DOES NOT yield the base address?
|
||||||||
|
3. |
Which of the following statements are correct about the program below? #include<stdio.h>
int main() { int size, i; scanf("%d", &size); int arr[size]; for(i=1; i<=size; i++) { scanf("%d", arr[i]); printf("%d", arr[i]); } return 0; } |
|||||||
|
4. |
Which of the following statements are
correct about 6 used in the program? |
|||||||
|
5. |
Which of the following statements are correct about an array?
|
||||||||
|
String
1. |
Which of the following function sets first n characters of a string to a given character? |
|||||||
|
2. |
If the two strings are identical, then strcmp() function returns |
|||||||
|
3. |
How will you print \n on the screen? |
|||||||
|
4. |
The library function used to find the last occurrence of a character in a string is |
|||||||
|
5. |
Which of the following function is used to find the first occurrence of a given string in another string? |
|||||||
|
||||||||
6. |
Which of the following function is more appropriate for reading in a multi-word string? |
|||||||
|
7. |
Which of the following function is correct that finds the length of a string? |
|||||||
|
||||||||
1. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; } |
|||||||
|
2. |
What will be the output of the program ? #include<stdio.h>
int main() { char p[] = "%d\n"; p[1] = 'c'; printf(p, 65); return 0; } |
|||||||
|
3. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { printf("%d\n", strlen("123456")); return 0; } |
|||||||
|
4. |
What will be the output of the program ? #include<stdio.h>
int main() { printf(5+"Good Morning\n"); return 0; } |
|||||||
|
5. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { char str[] = "India\0\BIX\0"; printf("%s\n", str); return 0; } |
|||||||
|
||||||||
6. |
What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input? #include<stdio.h>
int main() { void fun(); fun(); printf("\n"); return 0; } void fun() { char c; if((c = getchar())!= '\n') fun(); printf("%c", c); } |
|||||||
|
7. |
What will be the output of the program ? #include<stdio.h>
int main() { printf("India", "BIX\n"); return 0; } |
|||||||
|
8. |
What will be the output of the program ? #include<stdio.h>
int main() { char str[7] = "IndiaBIX"; printf("%s\n", str); return 0; } |
|||||||
|
9. |
What will be the output of the program ? #include<stdio.h>
int main() { char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"}; int i; char *t; t = names[3]; names[3] = names[4]; names[4] = t; for(i=0; i<=4; i++) printf("%s,", names[i]); return 0; } |
|||||||
|
10. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { char str[] = "India\0\BIX\0"; printf("%d\n", strlen(str)); return 0; } |
|||||||
|
||||||||
11. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { static char str1[] = "dills"; static char str2[20]; static char str3[] = "Daffo"; int i; i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills"); printf("%d\n", i); return 0; } |
|||||||
|
12. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { static char s[] = "Hello!"; printf("%d\n", *(s+strlen(s))); return 0; } |
|||||||
|
13. |
What will be the output of the program ? #include<stdio.h>
int main() { static char s[25] = "The cocaine man"; int i=0; char ch; ch = s[++i]; printf("%c", ch); ch = s[i++]; printf("%c", ch); ch = i++[s]; printf("%c", ch); ch = ++i[s]; printf("%c", ch); return 0; } |
|||||||
|
14. |
What will be the output of the program in 16-bit platform (Turbo C under DOS) ? #include<stdio.h>
int main() { printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0)); return 0; } |
|||||||
|
15. |
What will be the output of the program ? #include<stdio.h>
int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is empty\n"); else printf("The string is not empty\n"); return 0; } |
|||||||
|
||||||||
16. |
If char=1, int=4, and float=4 bytes size, What will be the output of the program ? #include<stdio.h>
int main() { char ch = 'A'; printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f)); return 0; } |
|||||||
|
17. |
If the size of pointer is 32 bits What will be the output of the program ? #include<stdio.h>
int main() { char a[] = "Visual C++"; char *b = "Visual C++"; printf("%d, %d\n", sizeof(a), sizeof(b)); printf("%d, %d", sizeof(*a), sizeof(*b)); return 0; } |
|||||||
|
18. |
What will be the output of the program ? #include<stdio.h>
int main() { static char mess[6][30] = {"Don't walk in front of me...", "I may not follow;", "Don't walk behind me...", "Just walk beside me...", "And be my friend." };
printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9)); return 0; } |
|||||||
|
19. |
What will be the output of the program ? #include<stdio.h>
int main() { char str1[] = "Hello"; char str2[10]; char *t, *s; s = str1; t = str2; while(*t=*s) *t++ = *s++; printf("%s\n", str2); return 0; } |
|||||||
|
20. |
What will be the output of the program ? #include<stdio.h>
int main() { char str[] = "India\0BIX\0"; printf("%d\n", sizeof(str)); return 0; } |
|||||||
|
||||||||
21. |
What will be the output of the program ? #include<stdio.h>
int main() { char str[25] = "IndiaBIX"; printf("%s\n", &str+2); return 0; } |
|||||||
|
22. |
What will be the output of the program ? #include<stdio.h>
int main() { char str = "IndiaBIX"; printf("%s\n", str); return 0; } |
|||||||
|
23. |
What will be the output of the program ? #include<stdio.h>
int main() { char str[] = "Nagpur"; str[0]='K'; printf("%s, ", str); str = "Kanpur"; printf("%s", str+1); return 0; } |
|||||||
|
24. |
What will be the output of the program ? #include<stdio.h>
int main() { printf(5+"IndiaBIX\n"); return 0; } |
|||||||
|
25. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { char sentence[80]; int i; printf("Enter a line of text\n"); gets(sentence); for(i=strlen(sentence)-1; i >=0; i--) putchar(sentence[i]); return 0; } |
|||||||
|
||||||||
26. |
What will be the output of the program ? #include<stdio.h> void swap(char *, char *);
int main() { char *pstr[2] = {"Hello", "IndiaBIX"}; swap(pstr[0], pstr[1]); printf("%s\n%s", pstr[0], pstr[1]); return 0; } void swap(char *t1, char *t2) { char *t; t=t1; t1=t2; t2=t; } |
|||||||
|
27. |
What will be the output of the program (Turbo C in 16 bit platform DOS) ? #include<stdio.h> #include<string.h>
int main() { char *str1 = "India"; char *str2 = "BIX"; char *str3; str3 = strcat(str1, str2); printf("%s %s\n", str3, str1); return 0; } |
|||||||
|
28. |
If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h>
int main() { char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; } |
|||||||
|
29. |
What will be the output of the program ? #include<stdio.h>
int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is not empty\n"); else printf("The string is empty\n"); return 0; } |
|||||||
|
30. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { char str1[5], str2[5]; int i; gets(str1); gets(str2); i = strcmp(str1, str2); printf("%d\n", i); return 0; } |
|||||||
|
||||||||
31. |
What will be the output of the program in Turbo C? #include<stdio.h>
int main() { char str[10] = "India"; str[6] = "BIX"; printf("%s\n", str); return 0; } |
|||||||
|
32. |
What will be the output of the program ? #include<stdio.h>
int main() { char str1[] = "Hello"; char str2[] = "Hello"; if(str1 == str2) printf("Equal\n"); else printf("Unequal\n"); return 0; } |
|||||||
|
33. |
What will be the output of the program ? #include<stdio.h>
int main() { char t; char *p1 = "India", *p2; p2=p1; p1 = "BIX"; printf("%s %s\n", p1, p2); return 0; } |
|||||||
|
34. |
What will be the output of the program ? #include<stdio.h> #include<string.h>
int main() { printf("%c\n", "abcdefgh"[4]); return 0; } |
|||||||
|
35. |
What will be the output of the following program in 16 bit platform (in Turbo C under DOS) ? #include<stdio.h>
int main() { printf("%u %s\n", &"Hello", &"Hello"); return 0; } |
|||||||
|
Input/Output
1. |
In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain? |
|||||||
|
2. |
What is the purpose of "rb" in fopen() function used below in the code? FILE *fp; fp = fopen("source.txt", "rb"); |
|||||||
|
3. |
What does fp point to in the program ? #include<stdio.h>
int main() { FILE *fp; fp=fopen("trial", "r"); return 0; } |
|||||||
|
4. |
Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+"); |
|||||||
|
5. |
To print out a and b given below, which of the following printf() statement will you use? #include<stdio.h>
float a=3.14; double b=3.14; |
|||||||
|
||||||||
6. |
Which files will get closed through the fclose() in the following program? #include<stdio.h>
int main() { FILE *fs, *ft, *fp; fp = fopen("A.C", "r"); fs = fopen("B.C", "r"); ft = fopen("C.C", "r"); fclose(fp, fs, ft); return 0; } |
|||||||
|
7. |
On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"? #include<stdio.h>
int main() { int i, fss; char ch, source[20] = "source.txt", target[20]="target.txt", t; FILE *fs, *ft; fs = fopen(source, "r"); ft = fopen(target, "w"); while(1) { ch=getc(fs); if(ch==EOF) break; else { fseek(fs, 4L, SEEK_CUR); fputc(ch, ft); } } return 0; } |
|||||||
|
8. |
To scan a and b given below, which of the following scanf() statement will you use? #include<stdio.h>
float a; double b; |
|||||||
|
9. |
Out of fgets() and gets() which function is safe to use? |
|||
|
10. |
Consider the following program and what will be content of t? #include<stdio.h>
int main() { FILE *fp; int t; fp = fopen("DUMMY.C", "w"); t = fileno(fp); printf("%d\n", t); return 0; } |
|||||||
|
Earning: Approval pending. |