Programming in C

Description

First year First Year Quiz on Programming in C, created by Faheem Ahmed on 26/03/2018.
Faheem Ahmed
Quiz by Faheem Ahmed, updated more than 1 year ago
Faheem Ahmed
Created by Faheem Ahmed about 6 years ago
1675
0

Resource summary

Question 1

Question
A C variable name can start with a ____
Answer
  • Number
  • Plus Sign (+)
  • Underscore
  • Asterisk (*)

Question 2

Question
Name the loop that executes at least once.
Answer
  • for
  • if
  • do-while
  • while

Question 3

Question
A pointer pointing to a memory location of the variable even after deletion of the variable is known as _____
Answer
  • far pointer
  • dangling pointer
  • null pointer
  • void pointer

Question 4

Question
Which of the following correctly shows the hierarchy of arithmetic operations in C?
Answer
  • / + * -
  • * - / +
  • + - / *
  • / * + -

Question 5

Question
The output of the following code is: main() { int z, a = 5, b = 3; z = a * 2 + 26 % 3; printf("%d", z); }
Answer
  • 10
  • 0
  • 12
  • None of the above

Question 6

Question
The output of the following code is: void main() { char a = 'B'; switch (a) { case 'A' : printf("a"); case 'B' : printf("b"); default : printf("c"); } }
Answer
  • B
  • b
  • bca
  • bc

Question 7

Question
What is the output of this C code? main() { int x=35; printf("%d %d %d",x==35,x=50,x>40); }
Answer
  • 1 50 1
  • 0 50 0
  • Runtime error
  • Compile time error

Question 8

Question
Which among the following is NOT a logical or relational operator?
Answer
  • !=
  • ==
  • ||
  • =

Question 9

Question
Which of the following is not a correct variable type?
Answer
  • float
  • real
  • int
  • double

Question 10

Question
Which of the following is true?
Answer
  • 1
  • 66
  • 0.1
  • -1
  • All of the above

Question 11

Question
Evaluate !(1 && !(0 || 1)).
Answer
  • True
  • False
  • Unevaluatable
  • Error

Question 12

Question
Which of the following is the proper declaration of a pointer?
Answer
  • int x;
  • int &x;
  • ptr x;
  • int *x;

Question 13

Question
Which of the following gives the memory address of integer variable a?
Answer
  • *a;
  • a;
  • &a;
  • address(a);

Question 14

Question
Which of the following gives the value stored at the address pointed to by pointer a?
Answer
  • a;
  • val(a);
  • *a;
  • &a;

Question 15

Question
Which conversion is not possible?
Answer
  • int to float
  • float to int
  • char to float
  • All are possible

Question 16

Question
What variables stores the number of arguments to a program in command line arguments?
Answer
  • argc
  • argv
  • count
  • arglen

Question 17

Question
What is argv[0]?
Answer
  • The number of arguments to the program
  • The name of the program
  • The first argument to the program
  • This syntax is illegal

Question 18

Question
The parameter passing mechanism for an array is
Answer
  • call by value
  • call by value-result
  • call by reference
  • none of these

Question 19

Question
Consider the statement int val[2] [4] = { 1, 2, 3, 4, 5, 6, 7, 8} ; 4 will be the value of
Answer
  • val[0][ 3]
  • val[0][4]
  • val[1][1]
  • none of the above

Question 20

Question
The following program fragment int a = 4, b = 6; printf (" %d ", a == b);
Answer
  • outputs an error message
  • prints 0
  • prints 1
  • none of the above

Question 21

Question
The following program fragment int a = 4, b = 6; printf ("%d", a = b) ;
Answer
  • outputs an error message
  • prints 0
  • prints 1
  • 6

Question 22

Question
main( ) { int a = 5, b = 2; printf("%d", a+++b); }
Answer
  • results in syntax error
  • prints 7
  • prints 8
  • none of above

Question 23

Question
Let x be an integer which can take a value of 0 or 1. The statement if(x = =0) x = 1; else x = 0; is equivalent to which one of the following?
Answer
  • x=1+x;
  • x=1—x;
  • x=x—1;
  • x=1%x;

Question 24

Question
Which command is used to skip the rest of a loop and carry on from the top of the loop again?
Answer
  • break;
  • resume;
  • continue;
  • skip ;
  • exit;

Question 25

Question
Which of the following is not a storage class in C?
Answer
  • auto
  • struct
  • extern
  • static
  • register

Question 26

Question
Which of following is not a valid name for a C variable?
Answer
  • Hairaj
  • Hello_raj
  • Hello raj
  • Both (a) and (b) above
  • None of the above.

Question 27

Question
How many times the below loop will get executed? main() { int i; for(i=9;i;i=i-2) { printf("\n%d",i); } }
Answer
  • 5
  • 6
  • Compilation Error
  • Infinite

Question 28

Question
What will be the output main() { int i; i = 10; if(i == 20 || 30) {printf("True"); } else {printf("False"); } }
Answer
  • True
  • False
  • Syntax Error
  • Run time Error

Question 29

Question
What the below statement will print if a=10 and b = 20? printf("%d",a==b);
Answer
  • 20
  • 10
  • 1
  • 0

Question 30

Question
What is the output of the following code? void main(){ printf("%d%d%d",50,100); }
Answer
  • 50,100
  • 50,100,garbage
  • 50,100,0
  • 0,50,100

Question 31

Question
What is the output of the following program? void main(){ printf("%d%d",100,200,300); }
Answer
  • 100 200
  • 200 300
  • 300 200
  • 100 200 300

Question 32

Question
What is the output of the following program? void main(){ printf("2+3=%d",2+3); }
Answer
  • 2+3=0
  • 2+3=2+3
  • 2+3=5
  • 5=2+3

Question 33

Question
What is the output of the following program? void main(){ int a; a=3+5*5+3; printf("%d",a); }
Answer
  • 43
  • 64
  • 31
  • none of these

Question 34

Question
what is the output of following program? void main(){ int a; float f; a=12/5; f=12/5; printf("%d%f",a,f); }
Answer
  • 2,2.000000
  • 2,2.00
  • 2,2
  • none of these

Question 35

Question
What is the output of following program? void main(){ int a; a='a'>'A'; printf("%d",a); }
Answer
  • 0
  • 1
  • garbage
  • none of these

Question 36

Question
What is the output of following program? void abc(int a){ ++a; } void main(){ int a=10; abc(); abc(); printf("%d",a); }
Answer
  • 10
  • 11
  • 12
  • 13

Question 37

Question
What is the output of following program? void main(){ int i=10; printf("%d%d%d",++i, i++, ++i); }
Answer
  • 11 11 13
  • 13 11 11
  • 11 12 13
  • 13 12 11

Question 38

Question
what is the output of following program? void main(){ printf("One"); if(2>1) printf("Two"); else printf("Three"); printf("Four"); }
Answer
  • One Two Three
  • Two Three Four
  • One Two Four
  • One Three Four

Question 39

Question
what is the output of following program? void main(){ float a; a=6.7; if(a==6.7) printf("A"); else printf("B"); }
Answer
  • A
  • B
  • error
  • nothing display on screen

Question 40

Question
what is the output of following program? void main(){ int a; a=10; a*=10+2; printf("%d",a); }
Answer
  • 102
  • 100
  • 120
  • 22

Question 41

Question
what is the output of following program? void main(){ int a; a=100; printf("%d%d",++a,a++); }
Answer
  • 101 101
  • 101 102
  • 102 100
  • 102 101

Question 42

Question
What is the output of the following program? void main(){ int a; a=100>90>80; printf("%d",a); }
Answer
  • 0
  • 1
  • error
  • none of these

Question 43

Question
What will be the output of the following program void main( ){ int a=10; printf("%d",a); { int a=20; printf("%d",a); } printf("%d",a); }
Answer
  • 10 10
  • 20 10
  • 10 20 10
  • 10 10 10

Question 44

Question
What is the output of following program? void f1(){ int a=0; ++a; printf("%d",a); } main(){ int a=10; f1(); f1(); f1(); printf("%d",a); return 0; }
Answer
  • 0 1 1 10
  • 10 0 1 10
  • 1 2 3 4
  • 1 1 1 10
Show full summary Hide full summary

Similar

Economics definitions: F582
busybee112
Features of a Volcano
Deirdre Molloy
Human Biology Year 1 Semester 1 Midterm 1 - Cells
michellelynnlebl
Human Biology Year 1 Midterm 1 Genetics (plus all TOPHAT)
michellelynnlebl
public administration 1st year uni
Hanin Lewa
PR Skillset Key Messages
charlotte.cranny
Spot the FIB, Living in a medieval manor town.
Liz Broderick
Learning and Motivation MCQ
Ani Av
Thermoregulation
Mollie Bedford
Chapter 1 Quiz
UNSW O-Week
Renal System (Part of)
Addeana