What will be the output of the following segment of the program?

main( )

{

char *s = “hello world”;

int i = 7;

printf(“%, *s”, i, s);

}

(A) Syntax error (B) hello w

(C) hello (D) o world

1 Answer

Answer :

Answer: Marks given to all

Related questions

Description : What is the output of the following program ? (Assume that the appropriate pre-processor directives are included and there is no syntax error) main() { char S[ ] = "ABCDEFGH"; printf ("%C",* (& ... Base address of S is 1000 */ } (A) ABCDEFGH1000 (B) CDEFGH1000 (C) DDEFGHH1000 (D) DEFGH1000

Last Answer : (D) DEFGH1000

Description : Trace the error: void main( ) { int *b, &a; *b = 20 printf(“%d, %d”, a, *b) } (A) No error (B) Logical error (C) Syntax error (D) Semantic error

Last Answer : (C) Syntax error

Description : What will be the output of the following ‘C’ code ? main ( ) { int x = 128; printf (“\n%d”, 1 + x++); } (A) 128 (B) 129 (C) 130 (D) 131

Last Answer :  (B) 129

Description : How many times the word 'print' shall be printed by the following program segment? for(i=1, i≤2, i++) for(j=1, j≤2, j++) for(k=1, k≤2, k++) printf("print/n") (A) 1 (B) 3 (C) 6 (D) 8

Last Answer : (D) 8

Description : Which of the following has compilation error in C ? (A) int n = 32; (B) char ch = 65; (C) float f= (float) 3.2; (D) none of the above

Last Answer : D

Description : Give output for following code: class student { int roll no; char name [14]; } s[6]; void main() { cout<<sizeof(s); }

Last Answer : Considering roll_no(Single variable) the output is: 96 OR Considering roll, no (Two variables) the output is: 108 OR Considering roll no the output is: error – space between roll and no

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} print(a.get(5,4)) a) Error, invalid syntax b) A c) 5 d) 4

Last Answer : d) 4

Description : If an integer occupies 4 bytes and a character occupies 1 byte of memory, each element of the following structure would occupy how many bytes ? struct name { int age; char name[30]; }; A) 30 B) 32 C) 34 D) 36

Last Answer : C) 34

Description : If we define putchar function in putchar :. char -> IO () syntax than character input as an argument andreturns a. Useful value b. Get output c. Getno output d. None of these

Last Answer : c. Getno output

Description : hat is the output when following code is executed ? >>>print r"\nhello" The output is a) a new line and hello b) \nhello c) the letter r and then hello d) error

Last Answer : d) error

Description : What is the output when following code is executed ? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:] a) olleh b) hello c) h d) o

Last Answer : b) hello

Description : What is the output when we execute list(“hello”)? a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]. b) [‘hello’]. c) [‘llo’]. d) [‘olleh’].

Last Answer : a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’].

Description : Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error

Last Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception

Description : Process of removing errors called a) Error Free b) Debug c) Syntax Error d) Exception

Last Answer : b) Debug

Description : How many times does the following code segment execute int x=1, y=10, z=1; do{y--; x++; y-=2; y=z; z++} while (y>1 && z

Last Answer : A) 1

Description : What is the output of the following piece of code? >>> a=(0,1,2,3,4) >>> b=slice(0,2) >>> a[b] a) Invalid syntax for slicing b) [0,2]. c) (0,1) d) (0,2)

Last Answer : c) (0,1)

Description : What is the output of the following piece of code when executed in Python shell? >>> a=("Check")*3 >>> a a) (‘Check’,’Check’,’Check’) b) * Operator not valid for tuples c) (‘CheckCheckCheck’) d) Syntax erro

Last Answer : c) (‘CheckCheckCheck’)

Description : What will be the output of the following Python code? nums = set([1,1,2,3,3,3,4,4])print(len(nums)) a) 7 b) Error, invalid syntax for formation of set c) 4 d) 8

Last Answer : Answer: c Explanation: A set doesn’t have duplicate items.

Description : Consider the following JAVA program: public class First { public static int CBSE (int x) { if (x < 100) x = CBSE (x +10); return (x - 1); } public static void main (String[] args){ System.out.print(First.CBSE(60)); } } What does this program print? (1) 59 (2) 95 (3) 69 (4) 99

Last Answer : (2) 95 

Description : printf ("%" d,% x ", & b); Explain the statement ?

Last Answer : printf ( % d,% x , & b); Here , the printf statement displays the output function printf () function as a variable data result of different data types. The C program is used to ... b respectively which indicates the memory location of integer type a and b variables where data will be stored.

Description : What is the output when following code is executed ? >>>str1="helloworld" >>>str1[::-1] a) dlrowolleh b) hello c) world d) helloworld

Last Answer : a) dlrowolleh

Description : Which one of the following describes the syntax of prolog program ? I. Rules and facts are terminated by full stop (.) II. Rules and facts are terminated by semicolon (;) III. Variables names must start with upper case alphabets. ... alphabets. Codes : (A) I, II (B) III, IV (C) I, III (D) II, IV

Last Answer : (C) I, III

Description : What will be the output? >>>my_tuple = (1, 2, 3, 4) >>>my_tuple.append( (5, 6, 7) ) >>>print len(my_tuple) a) 1 b) 2 c) 5 d) Error

Last Answer : c) 5

Description : What is the output of the following? i = 5 while True: if i%0O9 == 0: break print(i) i += 1 a) 5 6 7 8 b) 5 6 7 8 9 c) 5 6 7 8 9 10 11 12 13 14 15 …. d) error

Last Answer : d) error

Description : hat is the output of the following? i = 5 while True: if i%0O11 == 0: Page No 12 break print(i) i += 1 a) 5 6 7 8 9 10 b) 5 6 7 8 c) 5 6 d) error

Last Answer : b) 5 6 7 8

Description : What is the output of the following? i = 1 while True: if i%0O7 == 0: break print(i) i += 1 a) 1 2 3 4 5 6 b) 1 2 3 4 5 6 7 c) error d) none of the mentioned

Last Answer : a) 1 2 3 4 5 6

Description : What would happen if "String[]args" is not included as argument in the main method. A) No error B) Compilation error C) Program won't run D) Program exit

Last Answer : C) Program won't run

Description : What does the following expression means ? char *(*(* a[N]) ( )) ( ); (A) a pointer to a function returning array of n pointers to function returning character pointers. (B) a ... to characters (D) an array of n pointers to function returning pointers to functions returning pointers to characters.

Last Answer : Answer: A,B,C,D

Description : Consider the following statements related to compiler construction: I. Lexical Analysis is specified by context-free grammars and implemented by pushdown automata. II. Syntax Analysis is specified by regular expressions and implemented by ... Only l (2) Only ll (3) Both I and II (4) Neither I nor Il

Last Answer : Answer: 4

Description : What are the types of casting shown by the following examples: (i) char c = (char)120; (ii) int x = ‘t’;

Last Answer : Ans. (i) Explicit casting (ii) Implicit casting

Description : Classify the following as primitive or non-primitive data types: (i) char (ii) arrays (iii) int (iv) classes

Last Answer : Ans. (i) char – Primitive (ii) arrays – Non primitive (iii) int – Primitive (iv) Classes – Non primitive

Description : Arrange the following primitive data types in an ascending order of their size: (i) char (ii) byte (iii) double (iv) int

Last Answer : Ans. The sizes of the given data types are as follows char = 2 bytes byte = 1 byte double = 8 bytes int = 4 bytes Arranging them in ascending order gives byte < char < int < double

Description : State the number of bytes occupied by char and int data types.

Last Answer : Ans. char occupies two bytes and int occupied 4 bytes.

Description : Classify the following as primitive or non-primitive data types: (i) char (ii) arrays (iii) int (iv) classes

Last Answer : Ans. (i) char – Primitive (ii) arrays – Non primitive (iii) int – Primitive (iv) Classes – Non primitive

Description : The compiler _ translate a program code with any syntax error: a. Can b. Cannot c. Without d. None of these

Last Answer : b. Cannot

Description : Debugger is a program that (A) allows to examine and modify the contents of registers (B) does not allow execution of a segment of program (C) allows to set breakpoints, execute a segment of program and display contents of register (D) All of the above

Last Answer : (C) allows to set breakpoints, execute a segment of program and display contents of register

Description : What is the output of printf("%d")?

Last Answer : 1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after ï ½%dï ½ so compiler will show in output window garbage value. 2. When we ... an error without the proper number and type of arguments for things like printf(...) and scanf(...).

Description : A three dimensional array in C' is declared as int A[x][y][z]. Here, the address of an item at the location A[p][q][r] can be computed as follows (where w is the word length of an integer): (A) &A[0][0][0]+w(y*z*q+z*p+r) (B) &A ... *q+r) (C) &A[0][0][0]+w(x*y*p+z*q+r) (D) &A[0][0][0]+w(x*y*q+z*p+r)

Last Answer : Answer: B

Description : main() { Int a=3, b=2, c*d*e; d=&a; e=&b; c=*d+*e; } Which one of the given answers is correct? A) a=4, c-6 B) a=3, c=5 C) a=3, c=6 D) a=3, c=8

Last Answer : B) a=3, c=5

Description : Write a C program Reading and Writing data using Scanf() and Printf() statement -Technology

Last Answer : #include int main(){ char ch; char str[100]; printf('Enter any character '); scanf('%c', &ch); printf('Entered character is %c ', ch); printf('Enter any string ( upto 100 ... , str);}OUTPUT:Enter any characteraEntered character is aEnter any string ( upto 100 character )haiEntered string is hai

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} a.setdefault(4,"D") print(a) a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}. b) None. c) Error.

Last Answer : a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}.

Description : What will be the output? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2 a) True b) False c) Error d) None

Last Answer : c) Error

Description : What will be the output? d1 = {"john":40, "peter":45} Page No 40 d2 = {"john":466, "peter":45} d1 == d2 a) True b) False c) None d) Error

Last Answer : b) False

Description : What will be the output? d = {"john":40, "peter":45} "john" in d a) True b) False c) None d) Error

Last Answer : a) True

Description : What is the output of the following code? >>> a=(1,2,3,4) >>> del(a[2]) a) Now, a=(1,2,4) b) Now, a=(1,3,4) c) Now a=(3,4) d) Error as tuple is immutable

Last Answer : d) Error as tuple is immutable

Description : What will be the output? >>>t1 = (1, 2, 4, 3) >>>t2 = (1, 2, 3, 4) >>>t1 < t2 a) True b) False c) Error d) None

Last Answer : b) False

Description : What is the output when following code is executed ? >>>list1 = [11, 2, 23] >>>list2 = [11, 2, 2] >>>list1 < list2 is a) True b) False c) Error d) None

Last Answer : b) False

Description : What is the output when following code is executed ? >>>names = ['Amir', 'Bear', 'Charlton', 'Daman'] >>>print(names[-1][-1]) a) A b) Daman c) Error d) n

Last Answer : b) Daman

Description : What is the output of the following? print("xyyzxyzxzxyy".count('xyy', -10, -1)) a) 2 b) 0 c) 1 d) error

Last Answer : b) 0