AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C Programming
What is the output of the program given below ?
#includeint 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); return0; }
0, 1, 2
1, 2, 3
0, 2, 1
1, 3, 2
Answer:Option C
Explanation :enum takes the format like {0,1,2..) so pass=0, fail=1, atkt=2stud1 = pass (value is 0)stud2 = atkt (value is 2)stud3 = fail (value is 1)Hence it prints 0, 2, 1
What will be the output of the program in 16 bit platform (Turbo C under DOS)?
#includeint main() { externint i; i = 20; printf("%d\n", sizeof(i)); return0; }
2
4
vary from compiler
Linker Error : Undefined symbol 'i'
Answer:Option DExplanation :Linker Error : Undefined symbol 'i'The statement extern int i specifies to the compiler that the memory for 'i' is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name 'i' is available in any other program with memory space allocated for it. Hence a linker error has occurred.
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.
#include #include int main () { printf ("fmod of 3.14/2.1 is %lf\n", fmod (3.14,2.1) ); return0; }
What are the types of linkages?
Internal and External
External and None
External, Internal and None
Internal
Explanation :
External Linkage-> means global, non-static variables and functions.Internal Linkage-> means static variables and functions with file scope.None Linkage-> means Local variables.
Which of the following special symbol allowed in a variable name?
* (asterisk)
| (pipeline)
- (hyphen)
_ (underscore)
Answer:Option DExplanation :Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted. Names must not begin with a digit.Examples of valid (but not very descriptive) C variable names:=> foo=> Bar=> BAZ=> foo_bar=> _foo42=> _=> QuUx
Which of the following is not user defined data type?
struct book { char name[10]; float price; int pages; };
longint l = 2.35;
enum day {Sun, Mon, Tue, Wed};
1
3
1 & 2
Answer:Option B
Explanation :C data types classification are Primary data types 1. int 2.char 3. float 4. double 5.void Secondary data types (or) User-defined data type 1. Array 2. Pointer 3. Structure 4. Union 5. EnumSo, clearly long int l = 2.35; is not User-defined data type.(i.e.long int l = 2.35; is the answer.)
What is the output of the program?
#includeint main() { int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return0; }
0
Error
No Error
Since x < y turns to be TRUE it is replaced by 1. Then 1 < z is compared and to be TRUE. The 1 is assigned to i.
#includeint main() { externint fun(float); int a; a = fun(3.14); printf("%d\n", a); return0; } int fun(int aa) { return (int)++aa; }
Compile Error
Answer:Option DExplanation :2 Errors1. Type mismatch in redeclaration of fun2. Type mismatch in parameter aa
What is the output of the program?#includeint main(){ int a[5] = {2, 3}; printf("%d, %d, %d\n", a[2], a[3], a[4]); return 0;}
Garbage Values
2, 3, 3
3, 2, 2
0, 0, 0
Answer: Option D
When an automatic array is partially initialized, the remaining elements are initialized to 0.
In the following program how long will the for loop get executed?#includeint main(){ int i=5; for(;scanf("%s", &i); printf("%d\n", i)); return 0;}
The for loop would not get executed at all
The for loop would get executed only once
The for loop would get executed 5 times
The for loop would get executed infinite times
Answer:Option D
Explanation :During the for loop execution scanf() ask input and then printf() prints that given input. This process will be continued repeatedly because, scanf() returns the number of input given, the condition is always true(user gives a input means it reurns '1').Hence this for loop would get executed infinite times.
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies