Computer Programming C/C++ 1 Term 2012

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

1

Computer Programming C/C++ 1ST term 2012


Attempt any five questions. All questions carry equal marks.
Q. 1. Briefly explain the difference between C & C++.
Q. 2. Define & explain the term-reserved words. Give at least three examples. Explain each.
Q. 3. Define constant? Also elaborate types of constant.
Q. 4. Write down a C++ program which converts Fareneit to Celsius Scale.
Q. 5. What is IF statement? Explain the term IF & Nested if with example of C++.
Q. 6. Write down a Do-while loop program in which Quotient & Remainder of an arithmetic division
operation shows.
Q. 7. Define function. Also pass or demonstrate the use of constants as arguments in a function.
Q. 8. Write down a C/C++ program which demonstrates the cube root of a number by using for loop &
multiple values.
C/C++ Marks 50 2nd Term 2012
Note: Attempt any five questions. All questions carry equal marks. Mobile Phone &
1. State the structure of a C/C++ program 10
2. (a) What are C/C++ data types. 3
(b) Explain the following data types also write how they are declared.
i. Boolean type ii. Character type iii. Integer type

3. a) What do you mean by character constant? Give one example. 5


b) What is a string constant? Explain with the help of on example. 5
4. a) Define and explain Varaibles. 5
b) Write the rules for constructing variable names. 5
5. Write the purpose of the following functions in one line. 10
a. get() function b. put() function c. getch() function d. putch() function e. gets() function
6. State about output using cout and input using cin by giving one example.
1. a) What is Do-While loop. Explain with the help of an example. 5
b) What is a break statement? Give one example. 5
2. a) What does relational operator do, list its different types. 5
b) Write a C++ program to print first ten numbers. 5

Computer Programming C/C++ 1ST term 2013 Marks 50


Any five questions.
Q.No. 1. Differentiate the following terms with suitable examples.
a. Variable Declaration and Variable Definition.
b. Identifier, Constant and Variable
c. Operands, Operators and Expression 10
Q.No. 2. What will be the output of the following program segment. Explain the
output.
main()
{
int a = 2, b = 3, x,y;
float w,z;
x = a/b * b;
y = b/a * a;
w = a/b * b;
z = b/a * a;
printf(“%d%d%f%f,a,b,w,z); 10
}
Q.No. 3. a. What is decision control structure? Explain the if statement and if-
else statement with the help of an example.
b. Explain Break statement with example. 10
Q.No. 4. Write a program Which find and print the largest of three numbers
by using nested if statement. 10
Q.No. 5. a. What is loop? Explain For Loop with the help of an example.
b. What will be the output of the following program segement.
main()
{
int i ;
for(i =1; I<=5; printf(“in%d”,i));
i++;
}
Q.No. 6. a. What is preprocessor directives? Why we use #include 20
Preprocessor directives in the start of program.
b. What is Header file? Give some example of header files are used in C/C++;
2
Q.No. 7. Explain the following operation with the help of an example.
a. Compound Assignment Operators.
b. Increment & decrement operators.
c. Conditional Operator.
Q.No. 8. Differentiate the following built in functions. 2+2+2+2+2
a. printf( ) and scanf( ) b. getch( ) and putch( )
c. puts( ) and gets( ) d. strlen( ) and strlwr( ) e. pow( ) and sqrt( )

Computer Programming C/C++ 2nd term 2013 Marks 50


Q.No. 1. (a) What is the difference between variable and identifier?
(b) What are the roles for constructing the valid identifier?
(c) Which of the following are invalid variable name.
Interest-paid , si-int , average , percent , 123 , dist in km , FLOAT, name
Q.No. 2. (a) What is expression
(b) What will be the output of the following expression. Determine the Hierarchy of
operators.
(a) x = 4 + 2% - 8 (b) x = 2 * ¾ + 4/4 + 8 – 2 + 5/8
Q.No. 3. (a) What is the difference between nested if-else statement and Switch Statement.
(b) What will be the output of the following code? Explain the output.
main( )
{
int x = -3, y = 3;
if(!x + !y*1)
printf(“Welcome”);
else
printf(“Bye Bye”);
}
Q.No. 4. Write a program to determine whether the character entered is a Capital letter, a small
letter case letter, a digit or a special symbol?
Q.No. 5. (a) What is nested Loop? Explain with the help of an example.
(b) What will be the output of the following program code? Explain the output.
main( )
{
int x = 1, y = 1;
for(;;)
{
break;
else
y +=x;
cout<<endl<<y;
x+=y;
}
}
Q.No. 6. Write a program to find the factorial value of any number entered through the keyboard.
Q.No. 7. Explain the following keywords.
i) strlwr( ) and str upr( ) ii) scanf( ) and clrscr( ) (iii) putch( ) and getch( )
iv) cin and cout
Q.No. 8. Explain the following operators with suitable example.
(i) Logical Operators (ii) Relational Operators (iii) Size of operator

Computer Programming C/C++ 1st term 2014 Marks 50


Q.No. 1. Define Language. Differentiate between C and C++ as language.
Q.No. 2. Differentiate between variables and constants. Explain their role in a program.
Q.No. .3 Solve the following by applying priority of operators rules.
(i) (a + b/c * c – (d + 4))
(ii) (a + b ) / 4 * d ^ 2 + c / 2
Q.No. 4. Write the purpose of the following.
( i ) Printf( ), cout
( ii ) Putch ( ), Ptuchar ( )
(iii ) Getch ( ), getche ( )
(iv) iostream, stdio
(v) Scanf ( ), cin
Q.No. 5. Write a program to print largest of three numbers.
Q.No. 6. Explain the difference between if-else statement and Conditional operators with the help
of a program.
3
Q.No. 7. Write ouput of the given function
( i ) Sqrt ( )
( ii ) Floor ( )
( iii ) POW ( )
( iv) Strlen ( )
Q.No. 8. Write short notes on following
a) Variables definition rule
b) Reserved words
c) main ( )

Computer Programming C/C++ 2nd term 2014 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) 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

Computer Programming C/C++ 1st 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) 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. a. What is the difference between C and C++.


b. Write the weakness of C.
c. Explain each part of the following. i. int varint ii. Char varch = 64;
Q. 2. Write a program to find out the factorial of a number 6.
Q. 3. Write a program to display the square of even numbers of ranges with 1 to 20.
Q. 4. a. Describe the relational and conditional operators with proper example.
b. What will be the output of the following program.
main()
{
int k = 35;
printf(“%d%d”,k==35,k=50,k>40);
}
Q. 5. Explain the following functions. i. scanf() ii. Printf() iii. gets() iv. puts()
Q. 6. What is the difference between in For loop and While loop.
Q. 7. Explain with example the following functions.
i. abs() ii. sqrt(), iii. strlen() iv. exp() v. pow()
Q. 8. Write a program to display the following outputs using a loop statement.
1
1 2
1 2 3
1 2 3 4
Computer Programming C/C++ 2nd Term 2016 Marks 50

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( )

You might also like