IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Input / Output

@ : Home > C Programming > Input / Output > General Questions

Exercise

"Example is better than precept."
- (Proverb)
6. 

Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main()
{
    FILE *fs, *ft, *fp;
    fp = fopen("A.C", "r");
    fs = fopen("B.C", "r");
    ft = fopen("C.C", "r");
    fclose(fp, fs, ft);
    return 0;
}

A. "A.C" "B.C" "C.C"B. "B.C" "C.C"
C. "A.C"D. Error in fclose()

7. 

On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?

#include<stdio.h>

int main()
{
    int i, fss;
    char ch, source[20] = "source.txt", target[20]="target.txt", t;
    FILE *fs, *ft;
    fs = fopen(source, "r");
    ft = fopen(target, "w");
    while(1)
    {
        ch=getc(fs);
        if(ch==EOF)
            break;
        else
        {
            fseek(fs, 4L, SEEK_CUR);
            fputc(ch, ft);
        }
    }
    return 0;
}

A. r nB. Trh
C. errD. None of above

8. 

To scan a and b given below, which of the following scanf() statement will you use?

#include<stdio.h>

float a;
double b;

A. scanf("%f %f", &a, &b);B. scanf("%Lf %Lf", &a, &b);
C. scanf("%f %Lf", &a, &b);D. scanf("%f %lf", &a, &b);

9. 

Out of fgets() and gets() which function is safe to use?

A. gets()B. fgets()

10. 

Consider the following program and what will be content of t?

#include<stdio.h>

int main()
{
    FILE *fp;
    int t;
    fp = fopen("DUMMY.C", "w");
    t = fileno(fp);
    printf("%d\n", t);
    return 0;
}

A. size of "DUMMY.C" file
B. The handle associated with "DUMMY.C" file
C. Garbage value
D. Error in fileno()



© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!