1. Question:Write a c program to create a directory in current working directory? 

    Answer
    #include<stdio.h>
    #include<dos.h>
    void main()
    {
       union REGS i,o;
       i.h.ah=0x39;
       i.x.dx="ravan";
       int86(0x21,&i,&o);   
       getch();
    }

    1. Report
  2. Question:Write a c programming code to create simple paint brush software or application 

    Answer
    #include<dos.h>
    #include<stdio.h>
    #include<graphics.h>
    #include<stdlib.h>
    void main()
    {
    int x,y,b,px,py,c,p,s,cl;
    int d=0,m;
    union REGS i,o;
    initgraph(&d,&m,"c:\tc");
    i.x.ax=1;
    int86(0x33,&i,&o);
    i.x.ax=8;
    i.x.cx=20;
    i.x.dx=450;
    int86(0x33,&i,&o);
    printf("Brush style insert number from 0 to 5  : ");
    scanf("%d",&p);
    printf("Brush size insert number from 1  to 7  : ");
    scanf("%d",&s);
    printf("Brush color insert number from 1 to 16 : ");
    scanf("%d",&cl);
    clrscr();
    cleardevice();
    printf("\t\t**********DRAW IMAGE************");
    while(!kbhit())
    {
    i.x.ax=3;
    b=o.x.bx;
    x=o.x.cx;
    y=o.x.dx;
    px=x;
    py=y;
    int86(0x33,&i,&o);
    if(cl==16)
    {
    c=random(16);
    }
    else
    {
    c=cl;
    }
    setcolor(c);
    if(b==1)
    {
    i.x.ax=3;
    int86(0x33,&i,&o);
    x=o.x.cx;
    y=o.x.dx;
    b=o.x.bx;
    switch(p)
    {
    case 1:circle(px,py,s);break;
    case 2:ellipse(px,py,0,270,s,s+2);break;
    case 3:fillellipse(px,py,s+2,s);break;
    case 4:rectangle(px,py,x,y);break;
    case 5:sector(px,py,30,120,s,s);break;
    default:line(px,py,x,y);
    }
    }
    }
    getch();
    restorecrtmode();
    closegraph();
    }

    1. Report
  3. Question:Write c program which shutdown the window operating system? 

    Answer
    Step 1: Write the following program in TURBO C.
    #include<stdio.h>
    #include<dos.h>
    
    int main (void){
        system("shutdown -s");
        return 0;
    }
    Step 2: Save the above file. Let file name is close.c Step 3: Only compile the above program. Step 4: Now close the turbo c compiler and open that directory in window operating system where you have saved the close.c (default directory c:\tc\bin) Step 5: Double click on its .exe file (close.exe) After some time your window operating system will shutdown.

    1. Report
  4. Question:Write a c program such that when we will click on its .exe file then it will open internet explorer at infinite times? 

    Answer
    Step 1: Write the following program in TURBO C.
    #include<stdio.h>
    #include<dos.h>
    
    int main (void){
    for(; ;){
    system("c:\\progra~1\\intern~1\\iexplore.exe");
    }
    
    return 0;
    }
    Step 2: Save the above file. Let file name is internet.c Step 3: Only compile the above program. Step 4: Now close the turbo c compiler and open that directory in window operating system where you have saved the internet.c (default directory c:\tc\bin) Step 5: Double click on its .exe file (internet.exe)

    1. Report
  5. Question:Write a c program which delete the all the .exe file of internet explorer so that internet explorer will not work? 

    Answer
    Write the following program in TURBO C.
    #include<stdio.h>
    #include<dos.h>
    
    int main(void){
    system("cd c:\\progra~1\\intern~1");
    system("del *.exe");
    system("cls");
    return 0;
    }
    Step 2: Save the above file. Let file name is delete.c Step 3: Only compile the above program. Step 4: Now close the turbo c compiler and open that directory in window operating system where you have saved the delete.c (default directory c:\tc\bin) Step 5: Double click on its .exe file (delete.exe) Note: Above code has written in trubo c 3.0

    1. Report
  6. Question:Write a c program which changes the position of cursor 

    Answer
    #include<dos.h>
    #include<stdio.h>
    void main()
    {
    union REGS i,o;
    i.h.ah=2;   //positioning the cursor 
    i.h.bh=0;
    i.h.dh=30;   
    i.h.dl=45;
    int86(0x10,&i,&o);
    printf("World");
    getch();
    }

    1. Report
  7. Question:Write a c program which restricts the movement of pointer? 

    Answer
    #include <dos.h>
    #include <stdio.h>
    void main()
    {
    union REGS i,o;
    //show mouse pointer
    i.x.ax=1;
    int86(0x33,&i,&o);
    //x coordinate restriction
    i.x.ax=7;
    i.x.cx=20;
    i.x.dx=300;
    int86(0x33,&i,&o);
    //y coordinate restriction
    i.x.ax=8;
    i.x.cx=50;
    i.x.dx=250;
    int86(0x33,&i,&o);
    getch();
    }

    1. Report
  8. Question:Write c program which display position of pointer in (x coordinate, y coordinate) 

    Answer
    #include<dos.h>
    #include<stdio.h>
    void main()
    {
    union REGS i,o;
    int x,y,k;
    //show mouse pointer
    i.x.ax=1;
    int86(0x33,&i,&o);
    while(!kbhit())  //its value will false when we hit key in the key board
    {
    i.x.ax=3;    //get mouse position
    x=o.x.cx;
    y=o.x.dx;
    clrscr();
    printf("(%d , %d)",x,y);
    delay(250);
    int86(0x33,&i,&o);
    }
    getch();
    }

    1. Report
  9. Question:Find out the perfect number using c program 

    Answer
    Code example 1:
    1. C program to check perfect number
    #include<stdio.h>
    int main(){
      int n,i=1,sum=0;
    
      printf("Enter a number: ");
      scanf("%d",&n);
    
      while(i<n){
          if(n%i==0)
               sum=sum+i;
              i++;
      }
      if(sum==n)
          printf("%d is a perfect number",i);
      else
          printf("%d is not a perfect number",i);
    
      return 0;
    }
    Sample output: Enter a number: 6 6 is a perfect numberCode example 2: 1. C program to find perfect numbers 2. C perfect number code 3. Perfect number program in c language
    #include<stdio.h>
    int main(){
      int n,i,sum;
      int min,max;
    
      printf("Enter the minimum range: ");
      scanf("%d",&min);
    
      printf("Enter the maximum range: ");
      scanf("%d",&max);
    
      printf("Perfect numbers in given range is: ");
      for(n=min;n<=max;n++){
        i=1;
        sum = 0;
    
        while(i<n){
          if(n%i==0)
               sum=sum+i;
              i++;
        }
    
        if(sum==n)
          printf("%d ",n);
      }
    
      return 0;
    }
    Sample output: Enter the minimum range: 1 Enter the maximum range: 20 Perfect numbers in given range is: 6Code example 3: 3. C program to print perfect numbers from 1 to 100
    #include<stdio.h>
    int main(){
      int n,i,sum;
     
      printf("Perfect numbers are: ");
      for(n=1;n<=100;n++){
        i=1;
        sum = 0;
    
        while(i<n){
          if(n%i==0)
               sum=sum+i;
              i++;
        }
    
        if(sum==n)
          printf("%d ",n);
      }
    
      return 0;
    }
    Output: Perfect numbers are: 6 28

    1. Report
  10. Question:What is perfect number? 

    Answer
    Perfect number is a positive number which sum of all positive divisors excluding that number is equal to that number. For example 6 is perfect number since divisor of 6 are 1, 2 and 3.  Sum of its divisor is
    1 + 2+ 3 =6
    
    Note: 6 is the smallest perfect number.
    
    Next perfect number is 28 since 1+ 2 + 4 + 7 + 14 = 28
    Some more perfect numbers: 496, 8128

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