1. Question:Write a c program to know read/write permission of given file. 

    Answer
    #include "time.h"
    #include "sys\stat.h"
    #include "stdio.h"
    void main(){
        struct stat status;
        FILE *fp;
        stat("test.txt",&status);
        clrscr();
        if (status.st_mode & S_IREAD)
             printf("You have read permission.\n");
        if (status.st_mode & S_IWRITE)
             printf("You have write permission.");
        getch();
    
    }






    1. Report
  2. Question:Write a c program to know the last date of modification of any file 

    Answer
    #include "time.h"
    #include "sys\stat.h"
    #include "stdio.h"
    int main(){
        struct stat status;
        FILE *fp;
        fp=fopen("test.txt","r");
        fstat(fileno(fp),&status);
        
        printf("Last date of modification : %s",ctime(&status.st_ctime));
        return 0;
    }






    1. Report
  3. Question:Write a c program to find out the size and drive where file has stored of any given file? 

    Answer
    #include "time.h"
    #include "sys\stat.h"
    #include "stdio.h"
    int main(){
        struct stat status;
        FILE *fp;
        fp=fopen("test.txt","r");
        fstat(fileno(fp),&status);
        printf("Size of file : %d",status.st_size);
        printf("Drive name   : %c",65+status.st_dev);
        return 0;
    }






    1. Report
  4. Question:How to use complex numbers in c 

    Answer
    #include<stdio.h>
    int main(){
    int a,b;
    
    printf("Enter any complex number in the format a+ib: ");
    scanf("%d+i%d",&a,&b);
    
    printf("Real part is: %d",a );
    printf("\nImaginary part is: %d",b);
    
    return 0;
    
    }






    1. Report
  5. Question:C program to printf complex numbers 

    Answer
    #include<stdio.h>
    int main(){
    int a,b;
    
    printf("Enter the real part of complex number: ");
    scanf("%d",&a);
    
    printf("Enter the imaginary part of complex number: ");
    scanf("%d",&b);
    
    printf("\nComplex number is: %d%+di",a,b );
    
    return 0;
    
    }






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd