2076 Ashwin

  • 1. What are different types of computer software? What do you mean by high level and low level programming languages? A long with the block diagram explain the steps involved during compilation of a source code. [2+2+4]
  • 2. Explain different types of error that usually appears during the programming. Define preprocessing directive and explain its type with example. Write the algorithm and draw the flowchart to find the reverse of given number. [2+2+4]
  • 3. Why are formatted output important in C language? Write a program to print all the roots (Even imaginary roots) of quadratic equation. [3+5]
  • 4. Explain the importance of a switch case statement. Compare switch-case with if-else ladder. Write a program to find sum of numbers from 1 to 100 which are exactly divisible by 5 and not by 3. [2+2+4]
  • 5. How is function declared? Why is function prototype necessary? Write recursive function segment that returns the sum of numbers from 1 to n given by the user. [2+1+5]
  • 6. How can you pass one dimensional array to function and what does name of an array in • function call represents? Write a program to find the largest and smallest element of an array using a single function and display the result in calling function. [3+5]
  • 7. Explain how a structure can be defined and structure variables can be declared in C. Write a program that reads name, roll numbers, program and marks obtained in five subjects by students until the user enters 'e' and display the student detail and total marks obtained by each student. [3+5]
  • 8. What is pointer? Discuss its relationship with an array. Write a function program that behaves strcpy() function using pointer as arguement. [1+2+5]
  • 9. Explain different modes in opening file. Write a program to read a string, write it into a file and display the content of a file into a screen. [4+4]
  • 10 Explain different data types available in FORTRAN. Write a program in FORTRAN to check whether a number given by user is palindrome or not. [2+6]

2075 Ashwin

  • 1. a) What is a computer program? Discuss in brief about different generation of programming languages. [1+4]
  • b) Why is algorithm and flowchart development important in problem solving? [1+4]. Write an algorithm and draw flowchart to test a number entered by the user whether it is even or not. [2+3]
  • 2. a) What is the identifier? What are the ways to give value to variables? Explain with an example? [1+2+1]
  • b) Explain about input and output functions available in C with syntax and examples of each part. [2+2+2]
  • 3. a) Write algorithm, draw flowchart and program to input a number check it is Armstrong or not.[2+2+2]
  • b) What do you mean by selective and repetitive statements? Why do we need a break and continue statement? [2+2]
  • 4. a) What do you mean by "call by value and call by reference"? Explain it with suitable examples. [4]
  • b) Can we pass the whole array element from the function? Write the program to pass an array to function and sort them. [6]
  • //Program to find the largest word in a given sentence.

    #include< stdio.h>
    #include< stdlib.h>

    void main()
    {
      system("cls");
      char a[100];
      int i,lenght = 0,count = 0, max = 0,beg;

      printf("Enter any string ");
      gets(a);

      for(i=0;a[i]!='\0';i++)
      {
        lenght++;
      }

      for(i=0;i <=lenght;i++)
      {
        if(a[i] == ' ' || a[i] == '\0')
        {
            if(count > max)
            {
            max = count;
            beg = i - max;
            }
            count = 0;
        }
        else
        {
        count++;
        }
      }

      printf("\n");

      for(i=1;i <=max;i++)
      {
      printf("%c",a[beg]);
      beg++;
      }
    }

    Output:
    Enter any string : Khwopa Engineering College

    Largest word = Engineering
  • b) Differentiate between the methods of passing arguments to function with example. What are their advantages and disadvantages? [6]
  • 6. What is structure? Why is it necessary? Write a program to add two distances given in feet and inch format using structure. [1+1+6]
  • A Null Pointer is a pointer that does not point to any memory location, instead pointer is initialized either with NULL or 0 explicitly to indicate that this pointer variable is still unused. And it is a standard practice to use a NULL constant rather than 0.

    Example of Null Pointer
    #include < stdio . h>
    void main()
    {
      int *p = NULL; //initialize the pointer as NULL
      printf("The value of pointer is %u",p);
    }

    Output:
    The value of pointer is 0.

    Next Question
    #include < stdio.h>

    int main()
    {
      if(!NULL)
      {
      printf("C programming is easy");
      }
      else
      {
      printf("C programming is not easy");
      }
    }

    Output:
    C programming is easy

    Discussion
    According to C Coding standards,

    NULL is the pointer whose value is equivalent to 0 (Zero).
    And 0 (Zero) value is FALSE in C and other non-zero value is TRUE.

    Hence if !(not operator) is applied to NULL (FALSE), it implies that !NULL is TRUE
    So, if block statement is executed and "C programming is easy" is printed.
  • b) Write a program to calculate the length of the string without using the string handling function. [4]
  • //Displaying the detail of all employees in the order of their salary.

    #include< stdio.h>
    #include< stdlib.h>

    struct employee
    {
    char name[20];
    int id;
    int salary;
    };

    void main()
    {
      struct employee e[5],temp;
      int i,j;
      FILE *fp;
      fp = fopen("employee.txt", "r+b");

      fread(&e, sizeof(e), 5, fp);

      for(i=0;i <5;i++)
      {
        for(j=0;j <5;j++)
        {
        if(e[i].salary < e[j].salary)
            {
            temp = e[i];
            e[i] = e[j];
            e[j] = temp;
            }
        }
      }
      printf("Required record of employee in order of their salary are \n");

      for (i = 0; i <5; i++)
      {
      printf("%s %d %d\n", e[i].name, e[i].id, e[i].salary);
      }

      fclose(fp);
    }

    Output:
    Required record of employee in order of their salary are
    Satis 1 20000
    Utshab 2 30000
    Nimesh 3 40000
    Safal 4 50000
    Biraj 5 60000
  • 9. Write a program in FORTRAN to read 10 integers from the user and sort them in ascending order. [6]

2074 Shrawan

  • 1. What are computer programs and computer programming? Explain the steps that are required to build a computer program for solving a certain problem. [2+6]
  • 2. Explain with an example the role that precedence and associativity play in the execution of an expression. Rewrite the following program by correcting any errors, if present and also write down the output of the corrected code. [4+4]

  • Define MAX'5'

    int main()
    {
    int case(MAX)={2,3,5,4,10),i,sum=0;
    for(i=0,KMAX, i+=1)
    printf("Case %d = %3.2d\n",1,case[i]);
    sum +=* case+i;
    average = sum/MAX;
    printf("%06.2f", average);
    return 1;
    }

  • 3. a) Compare if-else-if ladder and switch construct with example and flowchart. [5]
  • b) Write a program in C to generate following pattern using unformatted input/output functions only. [5]
              N
            e e e
        P P P P P
      a a a a a a a
    L L L L L L L L L

  • 4. Write a program in C to find out whether the nth term of the Fibonacci series is a prime number or not. Read the value of n from the user and display the result in the main function. Use separate user-defined functions to generate the nth Fibonacci term and to check whether a number is prime or not. [8]
  • 5. a) How two dimensional arrays are created in C programming? Write a program to read square matrix of size NxN and find sum of both diagonals. [2+4]
  • b) Write a program in C to check whether a given string is palindrome or not using user defined function. [4]
  • 6. What are the advantages of using pointer in C programming? Write a program in C to find second largest elements from an array containing N elements using concept of pointer. [2+4]
  • 7. Explain structures and nested structures? Create a structure to hold any complex number xtiy. Write a program that uses the structure to read two complex numbers and display a third complex number which is the multiplication of the entered complex numbers. [3+5]
  • 8. a) What are different input/output functions used with data files in C? Explain with syntax and examples. [4]
  • b) Write a program in C to read integers from user until user says "no". After reading the data write all the odd numbers to a file name odd.txt and all the even number to file named even.txt. [4]
  • 9. When can we use recursive functions? Why do we need control statements in computer programs? Differentiate between do...while and for statements. [2+2+2]
  • 10. What are the characteristics of FORTRAN Programming? Write a program in FORTRAN to calculate the value of n by evaluating the following formula for the first 25 terms. [4]

2073 Shrawan

  • 1. a) What do you mean by Programming Language? Explain about the evolution of programming languages. [1+3]
  • b) What are the advantages of a Flowchart design? Write down the guidelines to be followed to draw a flowchart. [2+2]
  • 2. a) What is the purpose of the semicolon that appears at the end of most assignment statement in C? Explain the program compilation, linking and loading process with example. [2+4]
  • b) Discuss the types of errors in programming. How do you debug a C-program? [2+4]
  • 3. a) Explain relational and logical operators.
  • b) Write a C program to display following pattern without using formatted input/output statements. [4]
  • Programming
    rogrammin
    ogrammi
    gramm
    ram
    a
  • 4. a) Why do we need control statements? Compare switch and if-else-if ladder with example. [4]
  • b) Write a C program to display all characters between a given ranges. [6]
  • 5. a) What are the advantages of using functions? Differentiate between Library functions and User-defined functions with suitable example. [5]
  • b) Write a program to check whether a given number is Armstrong number or not using recursive function. [5]
  • 6. a) Write a C program to read two strings in main and compare them using userdefined function. Display appropriate message from main. [4]
  • b) What are overflow and underflow errors in context of array? Write a program to add corresponding elements of two arrays. The results should form a new array. [2+4]
  • 7. a) Why should we prefer structure over array? Explain nested structure with example. [2+4]
  • b) Write a program to read name and roll number of 48 students from user and store them in file. If the file already contains data, your program should add new data at the end of the file. [6]
  • 8. a) What is the structure of FORTRAN program? [5]
  • b) Write a FORTRAN program to read n numbers and display largest number among them. [6]