Sie sind auf Seite 1von 4

Q1 #include<stdio.

h> Void main() { Int I; For(;scanf(%d,&i);printf(%d,i)) ; }

Why is it an infinite loop?

Q2 what is difference between declaration and definition? A2 There is two differences between definition and declaration a) In definition, space is reserved for the variable and some initial value is assigned to it, whereas a declaration only identifies the type of variable for a function. b) Thus, definition is where variable is created or assigned storage, whereas declaration is a place where the nature of variable is stated but no storage is allocated. c) Secondly, the redefinition is an error, whereas redeclaration is not an error. Q3 When we mention the prototype of a function are we defining the function or declaring it? A3 We are declaring it. When the function, along with the statement belonging to it is mentioned then we are defining the function.

Q4Program: #include<stdio.h> Void main() {

Extern int fun (float); Int a; a=fun(3.14) printf(%d,a); }

Int fun (aa) Float aa; { Return ((int)aa); } A.3 B.3.14 C.0 D.Error A4 The error occurs because we have here mixed the ANSI prototype with K&R style of function definition. When we use ANSI prototype of a function and pass a float to the function it is prompted as double, when this double reaches the function into a float type error occurs. We should write it as Int fun (float aa) { } Q5 program: #include<stdio.h>

Void main() { Display(); Getch(); } Void display() { Printf(Sannisth); } A5 Firstly, the function display should have a prototype, before main function. Secondly, if a particular function isnt declared it is assumed by the compiler that the data type of the function is integer, hence when the compiler confronts the void type, it reports us the discrepancy via a redeclaration error.

Q6 Program: #include<stdio.h> Void main() { Char *cptr,c; Void *vptr,v; C=10; V=0; Cptr = &c; Vptr = &v; Getch(); }

A6 The above program will show error size of v is unknown It is so because we can create a null pointer but never a variable with datatype void We cant create a void pointer Q7 pg 12, test c , yashwant kanetkar Q8 pg 14, test c, yashwant kanetkar Q9 Int a[5]={2,3}; Printf(%d%d%d,a*2+,a*3+,a*4+); A9 This will print 0 0 0, this is so as in a partially initialized array, al the remaining elements are initialized to 0

Q10 Int a[5]; Printf(%d%d%d,a*2+,a*3+,a*4+); A10 Now, this will print garbage value as the array has never been initialized. Q11 pg 16, test c, yashwant kanetkar Q12 How to sort a array in ascending or descending order?

Das könnte Ihnen auch gefallen