C Programming and Problem Solving Questions and Answers 1 to 10

C Programming and Problem Solving

Questions 1 to 10








Click 
at 
down for 
go to 
next 
Set  
1...  
2...  
3...  
4...  
5...  
6...  
7...  
8...  
9...  
10... 
11... 
12...  
13...  
14...  
15...  
16...  
17...  
18... 
19... 
20...  
21...  
22...  
23...  
24...  
25...  
26...  
27... 
28...
29...  
30...  
31...  
32...  
33...  
34...  
35...  
36...
1.
What number will z in the sample code given below?
        int z, x=5, y= -10, a=4, b=2;
        z=x++ - --y *b/a;
(a)  5                       
(b)  6                       
(c)  10                     
(d)  11                    
(e)  12.

2.
Every C program consists  of __________ function(s).
(a)  Only one                                          
(b)  Only two                                    
(c)  One or two
(d)  One or many                                    
(e)  None of the above.

3.
What is the correct value to return to the operating system upon the successful completion of a program?

(a)  1                                                                                   
(b)  1                       
(c)  0                            
(d)  Programs do not return a value                                       
(e)  2.

4.
What is the only function all C programs must contain?

(a)  Start()                
(b)  System()                                         
(c)  Main()
(d)  Program()          
(e)  None of the above.

5.
Which of the following is not a correct variable type?

(a)  Float                 
(b)  Real                  
(c)  Int                     
(d)  Double              
(e)  Char.

6.
Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?

(a)  Foo[6];              (b)  Foo[7];              (c)  Foo(7);              (d)  Foo;                 (e)  Foo{ };

7.
Which of the following is a complete function?

(a)  Int funct();                                                                      
(b)  Int funct(int x) {return x=x+1;}
(c)  Void funct(int) {printf(“Hello");}                                        
(d)  Void funct(x) {printf(“Hello");}
(e)  None of the above.

8.
Which of the following is a not a keyword in C language?

(a)  Void                  
(b)  Volatile            
(c)  Sizeof               
(d)  Getchar             
(e)  Short.

9.
What is the return value of the following statement if it is placed in C program?

strcmp (“ABC”,”ABC”);

(a)  33                     
(b)  –1                     
(c)  1                       
(d)  Compilation error                              
(e)  0.

10.
Suppose the return type of function f is void. Which one of the following statements is true?

(a)   Function f does not contain a return statement
(b)   Function f does not have parameters
(c)   Function f returns a generic value
(d)   Function f does not work correctly
(e)   None of the above.



Answers

1.
Answer : (a)
Reason:  According to precedence of operators.
2.
Answer : (d)
Reason: 
3.
Answer : (c)
Reason:  After successful completion of a program  0 is returned to the operating system.
4.
Answer : (c)
Reason:  Since main() is the starting of a program execution.
5.
Answer : (b)
Reason:  real is not a variable type in C language.
6.
Answer : (a)
Reason:  Since array index starts with 0 in c language.
7.
Answer : (b)
Reason:  Since return type for the function is int and  in the function definition return statement is used by returning an integer value of x.
8.
Answer : (d)
Reason:  Getchar() is not a keyword in C language.
9.
Answer : (e)
Reason:  If the same statement is used in a C program  compilation error will occur.
10.
Answer : (c)
Reason:  Function returns a generic value.


1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


6 comments :

  1. Good
    Here is blog for basic C and C++ programs
    List of C and C++ Programs
    blog link
    C and C++ based programs

    ReplyDelete
  2. Good
    Here is a link for C/C++ programs and pointer programs. This may be useful for you.

    C Programs

    C++ Programs

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. 1st question's answer is 10 not 5

    ReplyDelete
  5. Programming is combination of intelligent and creative work. Programmers can do anything with code. The entire Programming tutorials that you mention here on this blog are awesome. Beginners Heap also provides latest tutorials of Programming from beginning to advance level.
    Be with us to learn programming in new and creative way.

    ReplyDelete