Last Updated on October 18, 2019 by Admin
CLA – Programming Essentials in C Quizzes Chapter 7 Assessment Exam Answers Full 100%
-
The following string:
JohnDoe
is a valid file name in
- MS Windows systems
- Unix/Linux systems
-
Unix/Linux systems treat the following names
JohnDoe johndoe
- as identical file names
- as different file names
-
The following string:
HomeDir/HomeFile
is a valid file name in:
- MS Windows systems
- Unix/Linux systems
-
The following string:
D:\USERDIR\johndoe.txt
is a valid file name in
- MS Windows systems
- Unix/Linux systems
-
What happens if you try to compile and run this program?
int main(void) { FILE *f; f = fopen("file","wb"); printf("%d",f != NULL); fclose(f); return 0; }
- the program outputs 1
- the program outputs 0
- the execution fails
- the compilation fails
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { FILE f; f = fopen("file","wb"); printf("%d",f != NULL); fclose(f); return 0; }
- the execution fails
- the program outputs 0
- the compilation fails
- the program outputs 1
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f; f = fopen("file","wb"); printf("%d",f != NULL); fclose(f); return 0; }
- the program outputs 2
- the program outputs 1
- the compilation or execution fails
- the program outputs 0
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i; i = fprintf(stdin,"Hello!"); printf("%d",i == EOF); return 0; }
- the program outputs 0
- the program outputs 1
- the program outputs 2
- the compilation or execution fails
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i; i = fprintf(stderr,"Hello!"); printf("%d",i == EOF); return 0; }
- the program outputs 0 to the stdout stream
- the compilation or execution fails
- the program outputs 1 to the stdout stream
- the program outputs 2 to the stdout stream
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { FILE *f; int i = fprintf(f,"Hello!"); printf("%d",i == EOF); return 0; }
- the program outputs 2
- the program outputs 0
- the program outputs 1
- the compilation or execution fails
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i = fprintf(f,"Hello!"); printf("%d",i != EOF); return 0; }
- the compilation or execution fails
- the program outputs 2
- the program outputs 1
- the program outputs 0
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i = fputs(f,"Hello!"); printf("%d",i != EOF); fclose(f); return 0; }
- the compilation or execution fails
- the program outputs 0
- the program outputs 2
- the program outputs 1
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i = fputs("Hello!",f); printf("%d",i != EOF); return 0; }
- the compilation or execution fails
- the program outputs 1
- the program outputs 2
- the program outputs 0
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { char s[20]; FILE *f = fopen("file","w"); int i = fputs("12A",f); fclose(f); f = fopen("file","r"); fgets(s,2,f); puts(s); fclose(f); return 0; }
- the compilation or execution fails
- the program outputs 12A
- the program outputs 1
- the program outputs 12
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { char s[20]; FILE *f = fopen("file","w"); int i = fputs("12A",f); fclose(f); f = fopen("file","r"); fgets(s,20,f); puts(s); fclose(f); return 0; }
- the program outputs 1
- the program outputs 12A
- the compilation or execution fails
- the program outputs 12
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i; fputs("12A",f); fclose(f); f = fopen("file","r"); fseek(f,0,SEEK_END); i = ftell(f); fclose(f); printf("%d",i); return 0; }
- the program outputs 3
- the program outputs 1
- the program outputs 2
- the compilation or execution fails
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i; fputs("12A",f); fclose(f); f = fopen("file","r"); fseek(f); i = ftell(f,0,SEEK_END); fclose(f); printf("%d",i); return 0; }
- the program outputs 3
- the program outputs 2
- the program outputs 1
- the compilation or execution fails
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); int i; fputs("12A",f); fclose(f); f = fopen("file","r"); fscanf(f,"%d",&i); fclose(f); printf("%d",i); return 0; }
- the program outputs 12A
- the program outputs 12
- the program outputs 1
- the compilation or execution fails
-
What happens if you try to compile and run this program assuming that fopen() succeeds?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); char c; fputs("12A",f); fclose(f); f = fopen("file","r"); fscanf(f,"%c",&c); fclose(f); printf("%c",c); return 0; }
- the program outputs 1
- the program outputs 12A
- the compilation or execution fails
- the program outputs 12
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { FILE *f = fopen("file","w"); float f; fputs("12A",f); fclose(f); f = fopen("file","r"); fscanf(f,"%f",&f); fclose(f); printf("%f",f); return 0; }
- the program outputs 1.000000
- the compilation or execution fails
- the program outputs 0.000000
- the program outputs 12.0000000