Thursday, 13 September 2012

CFC OCT/NOV-2012


C-09-CM/IT-105
3025
BOARD DIPLOMA EXAMINATION, (C-09)
OCT/NOV-2012
DCME-FIRST YEAR EXAMINATION
COMPUTER FUNDAMENTALS AND PROGRAMMING IN C
Time: 3 hours]                   [Total Marks:80
PART-A
Instructions: (1) Answer all questions
(2) Each question carries three marks.
(3) Answers should be brief and straight to the point and shall not exceed five simple sentences.
1.       List different types of output devices.
2.       Define each of the following terms: (a) terabyte (b) Megabyte (c) Gigabyte
3.       How would you change the appearance of a desktop in windows?
4.       List different types of web search engines.
5.       Draw a flowchart to convert the given Fahrenheit temperature to Centigrade temperature.
6.       Differentiate between break and continue statements
7.       Define an array
8.       Differentiate between address and dereferencing operators
9.       What is structure variable?
10.   What is the use of fopen()?
PART-B
Instructions: (1) Answer any five questions.
(2) Each question carries ten marks.
(3) Answers should be comprehensive and the criteria for valuation is the content but not the length of the answer
11.   (a) convert the binary number 100101 to equivalent decimal number (b) convert the binary number 101101.101 to equivalent decimal number.
12.   (a) Explain about DIR, CD command with all options in DOS. (b) explain COPY and DELETE commands in DOS.
13.   Explain the role of a modem in accessing the internet with neat sketch.
14.   Write a c program to find the largest among four given numbers.
15.   Explain data types in c with examples along with their sizes.
16.   Write a c program to check whether the given string is palindrome or not.
17.   (a) define a function. Write the uses of function (b) Explain return statement with example
18.   (a) Write a c program using pointer to compute the sum of all elements stored in an array.
                                                     
                                                          ANSWERS:

PART-A

1. Output devices~
Out put devices are used to show the output or result on the screen.
Ex~
·         Printer.
·         Monitor.
·         Speakers.

PART-B
Explain the role of a modem in accessing the internet with neat sketch.
13 ANS:



Modem stands for Modulator/Demodulator.
·         Modems are used to connect the computer to the telephone lines.
·         Standard telephone lines transmit analog signals in which sound is translated into electrical current.
·         As a result, you need a modem to translate data into a form that can be sent over telephone lines.
·         Modem converts the in coming digital signals into analog from and sends the data to the computers.
Modem plays the very important role in exchange data between computers via a telephone line.



Tuesday, 1 May 2012

Files in C

Files in C
A file is a collection of records stored on a secondary storage device.  The collection of bytes may be interpreted(translated), for example, as characters, words, lines, paragraphs and pages from a text document; fields and records belonging to a database; or pixels from a graphical image. 
types of files
1. Text files
2. Binary files
Text Files

A text file can be a stream of characters that a computer can process sequentially. It is not only processed sequentially but only in forward direction. For this reason a text file is usually opened for only one kind of operation (reading, writing, or appending) at any given time.
Binary Files
A binary file is no different to a text file. It is a collection of bytes. In C Programming Language a byte and a character are equivalent. No special processing of the data occurs and each byte of data is transferred to or from the disk unprocessed. C Programming Language places no constructs on the file, and it may be read from, or written to, in any manner chosen by the programmer.


predefined functions in files

Function Name                     meaning
fopen()                              Creates a new file. Opens an existing file.
fclose                                Closes a file already opened file
getc()                                Reads each character from a file
putc()                                Writes each character into a file
fprintf()                              Writes the data into a file
fscanf()                             Reads data from a file
getw()                              Reads a integer from a file
putw()                             Writes an integer value into the file
fseek()                             Sets the position to a desired point in the file
ftell()                               Gives the current position in the file
rewind()                            Sets the position to the beginning of the file


Example
#include<stdio.h>
#include<conio.h>
int main()
{
FILE *fp;
char c;
myfile = fopen("raj.txt", "r");
if (fp == NULL) 

{
  printf("File doesn't exist\n");
} 
else 
{
 do 

 {
  c = getc(fp);

putchar(c);

} while (c != EOF);

}
fclose(fp);
getch();

return(0);
}


//coying from one file to another file

#include<stdio.h>
#include<conio.h>
void main()
{
  FILE *p,*q;
  char f1[20],f2[20];
  char ch;
  printf("\nEnter the source file name to be copied:");
  gets(f1);
  p=fopen(f1,"r");
  if(p==NULL)
  {
      printf("cannot open %s",f1);
      exit(0);
  }
  printf("\nEnter the destination file name:");
  gets(f2);
  q=fopen(f2,"w");
  if(q==NULL){
      printf("cannot open %s",f2);
      exit(0);
  }
  while((ch=getc(p))!=EOF)
      putc(ch,q);
  printf("\nCOMPLETED");
  fclose(p);
  fclose(q);

}


1. Write a c program to open a file and write some text and close its.
2.  Write a c program to delete a file.
3. Write a c program to copy a file from one location to other location.
4. Write a c program to copy a data of file to other file.
5. Write a c program which display source code as a output.
6. Write a c program which writes string in the file.
7. Write a c program which reads string from file.
8. Write a c program which writes array in the file.
9. Write a c program which concatenate two file and write it third file.
10. Write a c program to find out size of any file.
11. Write a c program to know type of file.
12. Write a c program to know permission of any file.
13. Write a c program to know last date of modification of any file.
14. Write a c program to find size and drive of any file.
15. Big list of c program examples
pointers
Programs on files
c programs