Wednesday 7 July 2021

C Language Assignment

 


Q1. What will be the value of a after the following statement:

int a,b,c,d;

a=b=c=d=10;

Ans:



Q2. Find value of k: ( assume k is a float variable)

k=3/2*4+3/8+3

Ans:



Q3. Find value of k: ( assume k is a float variable)

k = 1/3*4/4-6/2+2/3*6/5

Ans:



Q4. What punctuation is used to signal the

beginning and end of code blocks?

A. { }

B. -> and <-

C. BEGIN and END

D.( and )



Q5. Evaluate !(1 && !(0 || 1)).

A. True

B. False

C. Can not be evaluated



Q6.In an assignment statement a=b; Which of the following statement is true?

A. The variable a and the variable b are equal

B. The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a

C. The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a

D. The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.



Q7. When following piece of code is executed, what happens?

b = 3;

a = b++;

A. a contains 3 and b contains 4

B. a contains 4 and b contains 4

C. a contains 4 and b contains 3

D. a contains 3 and b contains 3



Q8. A compiler is preferable to an interpreter, because

a. It can generate stand-alone programs that often take less time for execution

b. It is much helpful in the initial stages of program development

c. Debugging can be faster and easier

d. All of above



Q9. Which of the following system software always resides in main memory?

a. Text editor

b. Assembler

c. Loader

d. Linker



Q10. What is the difference between the declaration and definition of a variable in C Programming language?

a. Both can occur multiple times, but a declaration must occur first

b. There is no difference between them

c. A definition occurs once, but a declaration may occur many times

d. A declaration occurs once, but a definition may occur many times




Q11. 

void main()

int i=10;

if(i<20)

printf(“hello:i”);

printf(“stop”);

}

what will be the output of the above C program.

a. hello:10 stop

b. hello:20 stop

c. hello:i stop

d. stop



Q12. How many time the loop iterates

for(i=0,i<10;i=i+2) 

printf(“%d”,i);

a. 6

b. 7

c. 1

d. 5



Q13. Output of the following code:

int a=5;

if(a>5)

printf("%d",a);

elseif (a==5)

printf(" a is 5");

A. 5

B. a is 5

C. 5 a is 5

D. Error




Q14. Output of the following code:

int a=5;

if(a==5)

printf("a is 5 ”);

else

if (a<6)

printf(" a is less than 6");

A. a is 5

B. a is less than 6

C. a is 5 a is less than 6

D. Error



Q15. What would be the output of the following programs: 


(a) 

main( ) {

int i = 2, j = 3, k, l ;

float a, b ;

k = i / j * j ;

l = j / i * i ;

a = i / j * j ;

b = j / i * i ;

printf( "%d %d %f %f", k, l, a, b ) ; }

Ans:



(b) main( ) {

int a, b ;

a = -3 - - 3 ;

b = -3 - - ( - 3 ) ;

printf ( "a = %d b = %d", a, b ) ; }

Ans:




(c) main( ) {

float a = 5, b = 2 ;

int c ;

c = a % b ;

printf ( "%d", c ) ; }

Ans: 


Q16. The real constant in C can be expressed in which of the following forms

(1) Fractional form only

(2) Exponential form only

(3) ASCII form only

(4) Both fractional and exponential forms




Q17. A C variable cannot start with

(1) An alphabet

(2) A number

(3) A special symbol other than underscore

(4) Both (2) & (3) above




Q18. Find the output:

main( ) {

int x = 32765 ;

printf ( "\n%d %d %d", x <0, x = x+2, x > 30 ) ; }

Ans: 



Q19. Find the output:

int j = 10, k = 12 ;

if ( k >= j )

{ k = j ;

 j = k ; }

printf("%d %d",j,k);

Ans:


No comments:

Post a Comment