Thursday, 23 February 2017

MCA Ist sem /MCS-011/Solved Assignment/Problem Solving And Programming/2016-2017 New

Q.1.Mention the type of applications which can be developed using C language. Also, list the latest C compilers that are available in the market by giving the complete details like the name of the compiler, version, vendor‟s name, DOS based /WINDOWS based / Others, year of release, etc..


A.1. Features of ‘C’ language:-

C is a general purpose, structured programming language. C programming is widely used in computer Technology.
 ·         Low Level Features:
C programming provides Low level features that are generally provided by the Lower level languages. C is closely related to Lower level Language such as “Assembly Language”.
It is easier to write assembly codes in C programming.
·         Portability:
C Programs are portable i.e. they can run on any Compiler with little or No Modification.
Compiler and Preprocessor make it possible for C Programs to run it on Different Platforms.
·         Powerful:
Provides wide verity of “Data Types”
Provides wide verity of “Functions”
Provides useful Control and Loop Control Statements
·         Bit Manipulation
C Programs can be manipulated using bits. We can perform different operations at bit level.
It provides wide verity of bit manipulation Operators. We have bitwise operators to manage Data at bit level.
·         High Level Features:
It is more User friendly as compare to Previous Languages. Previous languages such as BCPL, Pascal and other programming languages never provide such great features to manage data.
Previous languages have their Pros and Cons but C Programming collected all useful features of previous languages thus C become more effective Language.
·         Modular Programming:
Modular programming is a software design technique that increases the extent to which software is composed of separate parts, called Modules.
C Program consist of different modules that are integrated together to form complete program.
·         Efficient Use of Pointers:
Pointers have direct access to memory.
 C supports efficient use of pointer.
·         More Efficient:
C Programming language is more efficient to Other languages.

Application Developed in C Programming are:-
 1.      C language can be used for creating computer applications
2.      Can be used in writing Embedded software
3.      Firmware for various electronics, industrial and communication products which use Micro-Controllers
4.      It is also used in developing verification software, test code, simulators etc.
5.      For Creating Compilers of different languages.
6.      C is used to implement different Operating System Operations.
7.      Unix kernel is completely developed in C Language.
                                                                                                            
Three ‘C’ compilers:-
1.      Turbo C++
2.      Borland C++
3.      Visual C++




      Q.2.Draw a flow chart and write a corresponding interactive program which prompts the user with the following options on the opening menu: 1) Subtract two integers 2) Compare two integers to find the smallest 3) Test an integer for odd or even 4) Quit Enter your choice         If an “1” is entered, prompt for the input of two integers and display their difference. If “2” is entered, prompt for two integers and display the smaller of the two. If “3” is entered, prompt the user for one integer and print out if it is odd or even. If “4” is entered, exit the program. If the user enters any letters or numbers other than the choice, re display the prompt. All output should go to the terminal and all input should come from the keyboard.

   A.2.  switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.
switch(expression) {

   case constant-expression  :
      statement(s);
      break; /* optional */
   case constant-expression  :
      statement(s);
      break; /* optional */
  
   /* you can have any number of case statements */
   default : /* Optional */
   statement(s);
}










    Q.3. Write an interactive program using strings which:  

   a) gets a filename from the standard input (keyboard) or a file

    b) gets a mode (read or write) from the same source and, 

   c) copies the contents of the input file to: 

    (i) the standard output if the input is from a file

        OR

     (ii) to the file specified in a) if the mode from b) is write If the file won't open, direct the input/output to the corresponding standard file (stdin/stdout).

   A.3.
Strings are actually one-dimensional array of characters terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.
The following declaration and initialization create a string consisting of the word "Hello". To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word "Hello."
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
If you follow the rule of array initialization then you can write the above statement as follows −
char greeting[] = "Hello";





  Q.4.Draw a flowchart and write an interactive C program that prints a power table for a specified range of integers. The user specifies the starting and ending integer on the command line along with the max power to compute for each integer. An example is included below:  
Example: 1 Starting Integer: 2 Ending Integer: 4 Maximum Power to be computed: 5 Output Num Powers (1 - 5) 2 2 4 8 16 32 3 9 27 81 243 729 4 16 64 256 1024 4096 Your program should use the pow( ) function along with casting of this function‟s arguments and output.

A.4. POW Functions():-  
  • pow( ) function in C is used to find the power of the given number.
  • ”math.h” header file supports pow( ) function in C language. Syntax for pow( ) function in C is given below.
double pow (double base, double exponent);



Q.5.Write an interactive C program to simulate the evaluation scheme for MCA (First semester) for 10 students. Each course should have both the components (Assignment as well as Term End Examination).

     A.5.



Q.6.Write a program to crypt its input according to a specified transformation scheme. The transformation scheme will consist of two strings:

   a string of characters and then a string of replacement characters. The idea is that your program replaces every instance of the ith character in the initial string with the (i+1)th character (of English alphabets) in the replacement string. It follows a cyclic pattern. If alphabet z is met it starts with alphabet a. When no substitution is defined for a character, the program just passes it through to the output unchanged. Blank spaces and the other symbols remains the same. The program should inform the user of any errors in the transformation scheme. Your program should display the strings before and after the substitutions in the corresponding 2 files named bcrypt and acrypt. Example: Original String: I know C programming. String after the transformation: J lopx D qsphsbnnjoh.

   A.6.
The crypt command reads from the standard input and writes to the standard output. The password is a key that selects a particular transformation. If no argument is given, crypt demands a key from the terminal and turns off printing to the screen while the key is being typed in. If the -k option is used, crypt will use the key assigned to the environment variable CrYpTkEy. The crypt command encrypts and decrypts with the same key: see ``Examples'' section below.
Files encrypted by crypt are compatible with those treated by the editors in encryption mode.
The security of encrypted files depends on three factors: the fundamental method must be hard to solve; direct search of the key space must be infeasible; ``sneak paths'' by which keys or clear text can become visible must be minimized.
The crypt command implements a one-rotor machine designed along the lines of the German Enigma, but with a 256-element rotor. Methods of attack on such machines are known, but not widely; moreover the amount of work required is likely to be large.
The transformation of a key into the internal settings of the machine is deliberately designed to be expensive, that is, to take a substantial fraction of a second to compute. However, if keys are restricted to (say) three lower-case letters, then encrypted files can be read by expending only a substantial fraction of five minutes of machine time.
If the key is an argument to the crypt command, it is potentially visible to users executing or a derivative. To minimize this possibility, crypt takes care to destroy any record of the key immediately upon entry. The choice of keys and key security are the most vulnerable aspect of crypt








    


s

4 comments: