Programming Fundamentals Past Papers – University 

Programming Fundamentals Past Papers – University

Here, we are showing you a sample of past paper of programming fundamental. If your student of a university and want to get an idea of the paper. Then this is a great sample paper for you.

Programming Fundamentals – Paper 1

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 60 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Q.1. Write the output of the following segments of codes [6*3=18].

A.

int b[4] = {11,1,2,3};
int* p = b;
*p = *(p+2);
cout << b[0];

B.

int a[5];
a[4] = 3;
for (int i=3; i >= 0; i--)
 {
	a[i] = 2*a[i+1] - i;
	cout <<"\n"<< a[i];
            }

C.

for (int i=1; i<4; i++)
                {
                     for (int j=1; j<=i; j++)
               cout << j << " ";
                     cout << "\n";
                }

D.

int main( ) 
         { 
            increment( ) ; 
            increment( ) ; 
            increment( ) ; 
       } 
              void  increment( ) 
                   { 
                               static int i = 1 ; 
                               cout<< i  ; 
                               i = i + 1 ; 
        }

E.

int x=2;
int y=3;
cout <<(x>y?x:y);

F.

int x = 7;
int y = 3;
cout << x/y << " , " << x%y<<"and"<<++x*y--;
  1. 2. Briefly comment each of the following lines of code. The first line is done for you. Make sure you describe the difference between statements. [7]
int x = 2; 
//Creates integer variable named  x and assigns it value 2.
int *p;
p = &x;
*p = 4;
cout << p;.
cout << *p;
int fun(int *, int*);

 Q.3.(10 points) We know that when an array is defined a constant pointer is created which stores the starting address of an array.  For example

float arr[6]={10,20,30,40,50,60};

a constant pointer,  with the name of ‘arr’, is created as given below:[7]

arrays program in university past paper
Consider the above diagram and calculate:
arr+3 and *(arr+3)
If the type of the above-mentioned array is an integer instead of float then calculate arr+3 and *(arr+3)
Q.4. Write a function to print the following series where n is input by the user in the main function. The limit should be inputted through the keyboard and will be passed to function as an argument.[7]
           1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
Q.5. Write a recursive function to obtain the running sum of the first 100 natural numbers.[7]
Q.6. Create a structure named Student to specify data on students given below: [7]
Roll number, Name, Department, Course, Year of joining
Assume that there are not more than 450 students in the college.
(a) Write a function to print names of all students who joined in a particular year.
(b) Write a function to print the data of a student whose roll number is given.
Q.7. Differentiate the following:[2×4=8]
a) Actual Parameters and Formal Parameters
b) Parameter passing by value and by the pointer

Programming Fundamentals – Paper 2

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 60 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Instruction:

  1. All questions are compulsory.

Q#1

What is pointer variable? Explain the working of pointer variable?                                    (10)

Q#2

Write a program that declares a STRUCTURE to store roll nos. and marks of 5 subjects in a single array. The program should define a structure variable, inputs the values and displays roll no, marks and average marks?                                                                                            (10)

Q#3

Write a program to initialize 3 different strings and perform the following functions:

  1. Copy STRING1 into STRING3 (5)
  2. Concatenate STRING1 and STRING2 (5)
  3. Calculate and show the total length of STRING1 after concatenation. (5)

Q#4

  1. Differentiate between actual and formal parameter?                                     (5)
  2. Write a program that displays back-counting from 10 to 1 by incorporating the(do while loop, function calls, function declaration, function definition, and global variable) concepts in your program.                                                                                        (10)

Q#5     Write a program to initialize the array with 5 values and the sort the values with

selection sort?                                                                                                            (10)

Program %age of LB covered prior Mid-Term %age of LB expected to be covered prior

Final-Term

Question Paper Weight

 

Prior Mid    +    After Mid

%age of Objective Questions
MCS-1A 50% 50% After Mid 100% Nill

Programming Fundamentals – Paper 3

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 35 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Q1:                                                                                                                              (10)

Write a program to bubble sort the values in an array?

Q2:                                                                                                                              (10)

Write a program to calculate the sum of the following series using do while loop.

1+1/2+1/4+1/6+1/8+…………………..+1/100

Instructions: Use the user define functions.

 Q3:                                                                                                                              (5)

Write a program to display the following output.

100                  10                    120

80                    30                    150

60                    50                    180

Instructions:

Use the user define functions.

Use the struct

Q4:                                                                                                                              (5)

Write a program that takes inputs from the user within a described range, and then adds only the odd numbers within the array.

Instructions:

Use the Global Variable

Use  For loop

Use user define a function

Q5:                                                                                                                              (5)

Write a program that takes the built-in functions of string to concatenate, and copies the strings.

Programming Fundamentals – Paper 4 Practical

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 20 (points)
Date & Time: Confidential Total Time:  30 Minutes
Student’s Name: Reg. No:

Q1:                                                                                                                                          (10)

Write a program to generaFibonaccibonacci numbers in an array within the given range, and then add all the indexes within the array, and show the final sum.

Q2:                                                                                                                                          (10)

Demonstration of practical/project performed in computer Lab.

Programming Fundamentals – Paper 5

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 35 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Q#1     Write a program that takes two numbers from the user as an input, and then demonstrates the working of a calculator using a switch statement?                7 Marks

Hint: Calculator working is like addition, multiplication, subtraction of two numbers

Q#2     Write a program to swap two variables without using a third variable?      7 Marks

Q#3     Write a program to find the factorial of a number using while loop?          7 Marks

Q#4     Write a program that displays the following shape using nested for loop?

*

*  *

*  *   *                                                                                                                       7 Marks

Q#5                                                                                                                 3+3+2=8 Marks

  1. Makes an observation to detect that this code is error free or not? If you find errors, then explain what the errors in this code are.

Do{Cout<<”enter a number”<<Endl;

}While(number < 10)

  1. Write two different techniques to declare and initialize a variable with an example?
  2. What is the difference between while and do while loop?

Programming Fundamentals – Paper 6

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 35 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Q#1     Write a program that takes a number from the user and then shows that number is even or odd?                                                                                                                                                                                 7 Marks

Q#2     Write a program (starting from #include) that repeatedly collects positive integers from the user, stopping when the user enters a negative number or zero. After that, output the product of all positive entries.                                                                                                                                                                                              6 Marks

Q#3     Write a program to find the factorial of a number using for loop?                                      7 Marks

Q#4     Write a program that takes the maximum range for calculating the Fibonacci and then to calculate the Fibonacci series of numbers.

Hint : Fibonacci series is like 1,1,2,3,5,8,13,21,…….till range            .

e.g, if a user enters a range of 5 then first five should be calculated only,

like 1,1,2,3,5,8 11                                                                                                                            7 Marks

Q#5                                                                                                                                        5+3=8 Marks

  1. Write the minimum five rules for naming a variable?
  2. Write two different techniques to declare and initialize a variable with an example?

Programming Fundamentals – Paper 7 -Practical

Course Code: Confidential Course Title: Programming Fundamentals
Teacher’s Name: Confidential Total Marks: 20 (points)
Date & Time: Confidential Total Time:  2 Hours
Student’s Name: Reg. No:

Instruction:

  1. All questions are compulsory.

Q#1

Write a program that initializes ten values within an array and sort the array

with bubble sort?                                                                                                                    (10)

Q#2

Write a program that gets the values in two-dimensional array, and after getting the values, the program should show the values.                                                                                                                             (10)


[OBJECTIVE]

Subject: Programming Fundamentals

Time Allowed: 15 Minutes

Max Marks: 10

NOTE: Attempt this Paper on this Question Sheet only. Please encircle the correct option. Division of marks is given in front of each question. This Paper will be collected back after expiry of time limit mentioned above.

 

Part-I  Encircle the Correct Answer, cutting and overwriting are not allowed. (10)

  1. Placing function prototypes in the definitions of other functions restricts function calls to the function in which the prototypes appear.

[True]                                   [False]

  1. Pointers are valid operands in arithmetic expressions, assignment expressions, and comparison expressions. However, not all the operators normally used in these expressions are valid in conjunction with pointer variables.

[True]                                   [False]

  1. A pointer to void can be dereferenced just like any other pointer, by using the indirection operator (*).

[True]                                   [False]

  1. If b is the name of an array of at least 4 elements, then the following statements both refer to its 4th element.

&b[ 3 ] bPtr +3

[True]                                   [False]

  1. The following statement defines an array of pointers to strings.

const char *suit[ 3 ] = { “Hearts”, “Diamonds”, “Clubs” };

[True]                                   [False]

  1. The following function receives a const double-scripted array of integers and two const string arrays.

void deal( const int wDeck[][ 13 ], const char *wFace{], const char *wSuit[] )

[True]                                   [False]

  1. A function name is really the starting address in memory of the code that performs the function’s task. Pointers to functions can be passed to functions, returned from functions, stored in arrays, and assigned to other function pointers.

[True]                                   [False]

  1. The following statement defines a pointer to a function that receives two integer parameters and returns an integer result. int *compare( int, int );

[True]                                   [False]

  1. In C, all arrays passed to functions are passed by reference.

[True]                                   [False]

  1. 10. The string “life “, may be stored in an array of 4 characters.

[True]                                   [False]

 

[SUBJECTIVE]

Subject: Programming Fundamentals

Time Allowed: 2 Hours 45 Minutes

Max Marks: 50

NOTE: ATTEMPT THIS (SUBJECTIVE) ON SEPARATE ANSWER SHEET PROVIDED

 

Part-II  Give Short Answers, Each question carries equal marks. (20)

Q#1: What will be the output of the following program? If the program contains some errors (syntax, run time or logical) then correct them before writing the output.

# include <iostream.h>

int aain()

{

int i:

int array(3)=(10, 15, 20};

int *ptrl, *ptr2, *ptr3;

ptrl = array;

ptr2 = arraytl;

ptr3 = arrayt2:

*otr2 = 6;

ptr2 = ptr3;

*otr2 = 43

+¢+(*ptrl);

for (im0; i<3; {+t+)

cout<<array(i}<<” “;

cout<<endl;

++ptrl;

*ptrl = 14; :

for (i=0; 1<3; i++)

cout<<array[i}<<” “%;

cout<<endl;

}

 

 

 

Q#2: What will be the output of the following program? If the program contains some errors (syntax, run time or logical) then correct them before writing the output.

#include <iostream.h>

void inc_count (int *count_ptr)

{*count_ptr) ++;

int main()

‘ int count = 0;

while (count < 10)

ine_count (&écount):

cout<<count;

return (0);

 

 

Q#3: Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a Prime number, or false otherwise.[only write the definition for this function).

bool {sPrime (int num);

 

Q#4: Implement the following function threeToZero which accepts an integer array and its size, if there is a 2 in the array immediately followed by a 3, set the 3 element to 0.

 

Note: Indent your code properly. Use meaningful variable names. Write cin, cout, and all c++ keywords in lowercase (like if, for etc.)

void threeToZero(int arr{], int size)

{

// complete the function definition here

 

 

Part-III  Give Long Answers, Each question carries equal marks. (30)

Q#1: Write down a program that accepts the following command line arguments:

  1. The name of the text file that contains single ~ digit integer data separated by a white space.
  2. An integer to be searched from the data in the file.

The program displays the total number of occurrences of the integer in the file data.

 

Q#2: Assume yourself as a part of the control unit of Windows Live hotmail. Your job is to determine the password length of the user entered passwords.

A password

  • Is said to be short if it contains less than 6 characters.
  • Is perfect if it its length is greater than 6. (Max. length is 20 characters.)

You are to design a function that takes a parameter string (By Reference) and determines its length according to the above mentioned criteria.

 

 

shamil memory table

Electrical Engineering Past Papers and Guess(EE)

  1. Calculus & analytic geometry past papers
  2. Introduction to computing past papers
  3. Electricity and magnetism past papers
  4. APPLIED LINEAR ALGEBRA past papers
  5. Programming Fundamentals Past Papers
  6. Electronic devices and circuits
  7. Digital Logic Design DLD Past Papers
  8. Basic Electronics & DLD Past Papers
  9. Functional English Past Papers
  10. Differential Equations Past Papers
  11. Data Structures Past Papers
  12. Electric Machines Past Papers 
  13. Network Analysis Past Papers
  14. Numerical Analysis Past Papers
  15. Signals Systems Past Papers
  16. complex variables and transform past papers
  17. Engineering drawing and AutoCAD past papers
  18. Applied Thermodynamics Past Papers
  19. Communication and presentation skills Past Papers
  20. Field Theory Past Papers
  21. Communication Systems Past Papers
  22. Embedded Systems Past Papers
  23. Basic Electronics Instrumentation Past Papers
  24. Power Transmission Distribution Past Papers
  25. Linear control systems Past Papers
  26. Probability Methods in Engineering Past Papers
  27. Engineering Economics Past Papers
  28. Technical Report Writing Past Papers
  29. Professional Ethics Past Papers
Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.