Computer Programming C/C++ 1 Term 2012
Computer Programming C/C++ 1 Term 2012
Computer Programming C/C++ 1 Term 2012
Part - A
Q. 1. Differentiate any five paris.
(i) Variable and Constants.
( ii ) Increment and decrement operators.
( iii ) Printf( ) and Scanf( )
( iv ) While Loop and Do While loop
( v ) Reserve words and User defined words.
( vi ) Operands and Operators. 10
Q. 2. Write short note on any fwo from the following with examples.
i. Break Statement ii. Conditional Operators
iii. Standard Counter 10
Q. 3. Write body structure (Syntax) for any five from the following.
i. if-else statement ii. Switch Statement iii. For Loop iv. Do While Loop
v. Injection of any header file vi. C/C++ Program structure10
Q. 4. Write output for any four from give logic.
i. Printf(“ *\n * * \n * * * \n * * * * “);
ii. Printf(“%S”, Strlwr(“ Pakistan”));
iii. Printf((“ %d”,ceil(-9.5));
iv. int I, sum = 0;
for (I=1; I<8 ; I++)
sum += i;
printf(“\n sum = %d and iterations are = %d”; sum, I);
v. char arr[] = “Pakistan”;
int len;
len = strlen(arr);
printf(“total length = %S length = %d”,arr,len); 10
Part – B
Q. 5. Write program to display even numbers in descending order from 100 to 0. 10
Q. 6. a) What is C Language? Elaborate difference between C and C++ in detail.
b) Write note on Nested For Loop. Write just body structure as example. 10
Q. 7. What is Library function? Write note on it types also elaborate at least two library functions from
each type. 10
Q. 8. What is variable data type? Elaborate five data types used in C/C++ program. Also write down
its declaration method. 10
Part - A
Q. 1. Differentiate any five paris.
(i) Signed and Unsigned Integer
( ii ) Strlwr ( ) and Strupr( )
( iii ) Break and Continue Statement
( iv ) Prefix and Postfix Operator
( v ) Declaration time value assignment and run time value assignment
( vi ) C and C++
Q. 2. Write short note on any two from the following with examples.
i. For Loop ii. Preprocessor directive
iii. Arithmetic functions
4
Q. 3. Write body structure (Syntax) for any five from the following.
i. Nested if-else statement ii. Declaration of user defined function iii. Goto statment iv.
While Loop v. printf vi. C/C++ Program structure
Q. 4. Write output for any four from give logic.
j. Int a = 5, b= 10
Printf(“b%a = %d\n”, b%a)
ii. int a = 10;
char ch = ‘*’;
printf(“%d”,n);
printf(“%c”,ch);
iii. int i,j;
for(I=1; I<5; I++)
{
for(j=1; j<=I; j++)
printf(“*”);
printf(“\n”);
}
iv. Printf(“%f”, ceil(9.9));
v. Printf(“%f”,pow(5,3));
Part – B
Q. 5. Write program that take a number from user and shows whether it is odd or even using if-else
statement.
Q. 6. Elaborate while and do while loop in detail with one example.
Q. 7. Elaborate user defined words and reserve words with examples.
Q. 8. Write Input and Output statements, also write down two functions of each statement.
Computer Programming C/C++ 2nd Term 2015 Marks 50
Attempt any five questions by selecting at least 02 questions from each part. All questions carry equal
marks. Mobile Phone & Programmable calculators are not allowed.
Part - A
Q. 1. Differentiate any five paris.
(i) Numeric constant and Integer Constant.
( ii ) For loop and Nested for loop.
( iii ) Ceil( ) and Floor( )
( iv ) Pre-increment and Post Increment
( v ) Declaring variable and Declaring constant
( vi ) Syntax error and Logical error
Q. 2. Write short note on any five from the given.
i. Link Libraries ii. Statements iii. Expression iv. Pre Processor directives v. Reserve words
vi. Program Compilation
Q. 3. Write output of the following expression.
a. Sqrt(-64)
b. printf(“*-*\n*+*\n*\n-,-\n****+-,+\n*\n”);
c. i. Floor(+14.5) ii. Ceil(-14.5)
d. float T = -8.5; printf(fabs(T));
e. printf(“size of char = %d\n”,size of(char));
Q. 4. Write structure (syntax) for any five from the given.
a. Body structure of While loop
b. Body of Nested if statement
c. C program
d. Switch Statement
e. for loop with pre-increment operator
f. injection of Header file
Part - B
Q. 5. Write a program that take starting and ending values from user and display all odd numbers in
range of given values using do while loop.
Q. 6. A. What is string ouput function? Write its syntax or structure.
b. Write any five weaknesses of C language.
Q. 7. A. What is input statement? Write syntax of Scanf( ) to take float value.
b. Elaborate relational operators with example.
Q. 8. Write a brief note on counters. Also elaborate its types with general syntax.
5
Computer Programming C/C++ 1st Term 2016 Marks 50
Attempt any five questions by selecting at least 02 questions from each part. All questions carry equal
marks. Mobile Phone & Programmable calculators are not allowed.
Q.1. Explain structure of C/C++ program. Also write any five differences between C and C++.
Q.2. Define “Reserve words” explain any three reserve words.
Q.3. Discuss different data types used in C/C++ language.
Q.4. Write a program that displays larger of two numbers using conditional operator.
Q. 5. What is Preprocessor directives? Discuss any two Preprocessor directives.
Q. 6. Write note on the following. i. Increment and decrement operator ii. Function prototype.
Q. 7. Write program that display first ten odd numbers in descending order using while loop.
Q.8. Write syntax and purpose of the following build in functions.
Strlen( ), ABS( ), Strlwr( )