CFORBEGINNERS.COM

C Quiz on Datatypes

1. What is the correct way to write a comment in C ?
    a) /this is a comment/
    b) /*this is a comment/*
    c) /*this is a comment*/

2. How would you declare an integer called sum and initialize it to 10?
    a) int sum 10;
    b) int sum=10;
    c) double sum=10;

3. What is the correct way to print integer sum to the screen?
    a) printf("%i",sum);
    b) printf("%f",sum);
    c) printf("%i",10);

4. What is the place holder for a double data type value?
    a) %i
    b) %d
    c) %f

5. Is it legal to declare multiple integers like this, int sum,age,group;
    a) yes
    b) no

6. What do double data types hold?
    a) integers
    b) two integers
    c) decimals

7. What is the correct way to scan in an integer called sum?
    a) scanf("%i",&sum);
    b) scanf("%i",sum);
    c) scan("%i",&sum);

8. What is the correct way to scan in a double called sum?
    a) scan("%i",&sum);
    b) scanf("%lf",&sum);
    c) scanf("%f",sum);

9. What placeholder would the integer x go into in this print statement?
printf("%f %i %i",age,x,sum);
    a) %f
    b) the first %i
    c) the second %i

10. Why shouldn't integers be divided integers?
    a)Their values will be truncated
    b) The compiler will give you an error message
    c) your program will automatically crash