JAYASHREE ORACLE CERTIFIED JAIN UNIVERSITY

Friday, October 8, 2010

C Programming List For Final Lab Exam(BCA Ist SEM)


Part A

1 Printing the reverse of an integer.



2 Printing the odd and even series of N numbers.



3 Get a string and convert the lowercase to uppercase and vice--versa using getchar() and putchar().



4 Input a string and find the number of each of the vowels appear in the string.




5 Accept N words and make it as a sentence by inserting blank spaces and a full stop at the end.


6 Printing the reverse of a string.



7 Finding the first N terms of Fibonacci series.



8 Finding the maximum of 4 numbers by defining a macro for the maximum of two numbers.


9 Recursive program to find the factorial of an integer.



10 Demonstration of bitwise operations.




Part B

11 Searching an element in an array using pointers.



12 Checking whether the given matrix is an identity matrix or not.



13 Declare 3 pointer variables to store a character, a character string and an integer respectively. Input values into these variables. Display the address and the contents of each variable.



14 Define a structure with three members and display the same.



15 Declare a union with three members of type integer, char, string and illustrate the use of union.


16 Arranging N numbers in ascending and in descending order using bubble sort.



17 Addition and subtraction of two matrices.



18 Multiplication of two matrices.



19 Check whether the given string is a palindrome or not.



20 Applying binary search to a set of N numbers by using a function.




21 Create a sequential file with three fields: empno, empname, empbasic. Print all the details in a neat format by adding 500 to their basic salary.






Thursday, October 7, 2010

Algorithm for Functions

Algorithm LargestNumber

Input: A non-empty list of numbers L.
Output: The largest number in the list L.


largest ← L0
for each item in the list (Length(L)≥1), do
if the item > largest, then
largest ← the item
return largest


--------------------------------------------------
Algorithm for Sorting using function


procedure bubbleSort( A : list of sortable items ) defined as:
do
swapped := false
for each i in 0 to length(A) - 2 inclusive do:
if A[i] > A[i+1] then
swap( A[i], A[i+1] )
swapped := true
end if
end for
while swapped
end procedure

--------------------------------------------------
function factorial is:
input: integer n such that n >= 0
output: [n × (n-1) × (n-2) × … × 1]

1. create new variable called running_total with a value of 1

2. begin loop
1. if n is 0, exit loop
2. set running_total to (running_total × n)
3. decrement n
4. repeat loop

3. return running_total

end factorial

-------------------------------------------------------

Flow Chart for Functions


Tuesday, September 28, 2010

BLOGS for Diffrent Subjects

http://jayashree-dbms.blogspot.com/
http://jayashree-sqlplsql.blogspot.com/
http://bca-3sem-vb.blogspot.com/
http://bca-3sem-cpp.blogspot.com/
http://bca-3sem-se.blogspot.com/

Friday, September 24, 2010

C Q Bank

C Skills Written Test Questions

1. find(int x,int y)
{ return ((xcall find(a,find(a,b)) use to find
(a) maximum of a,b
(b) minimum of a,b
(c) positive difference of a,b
(d) sum of a,b

2. integer needs 2bytes , maximum value of an unsigned integer is
(a) { 2 power 16 } -1
(b) {2 power 15}-1
(c) {2 power16}
(d) {2 power 15}

3.y is of integer type then expression
3*(y-8)/9 and (y-8)/9*3 yields same value if
(a)must yields same value
(b)must yields different value
(c)may or may not yields same value
(d) none of the above

4. 5-2-3*5-2 will give 18 if
(a)- is left associative,* has precedence over -
(b) - is right associative,* has precedence over -
(c) - is right associative,- has precedence over *
(d)- is left associative,- has precedence over *

5. printf("%f", 9/5);
prints
(a) 1.8,
(b) 1.0,
(c) 2.0,
(d) none
.
6. if (a=7)
printf(" a is 7 ");
else
printf("a is not 7");
prints
(a) a is 7,
(b) a is not 7,
(c) nothing,
(d) garbage.

7. if (a>b)
if(b>c)
s1;
else s2;
s2 will be executed if
(a) a<= b,
(b) b>c,
(c) b<=c and a<=b,
(d) a>b and b<=c.

8. main()
{
inc(); ,inc(); , inc();
}
inc()
{ static int x;
printf("%d", ++x);
}
prints
(a) 012,
(b) 123,
(c) 3 consecutive unappreciable numbers
(d) 111.

9.preprocessing is done

(a) either before or at beginning of compilation process
(b) after compilation before execution
(c) after loading
(d) none of the above.

10. printf("%d", sizeof(""));
prints
(a) error
(b)0
(c) garbage
(d) 1.

11.main()
{
int a=5,b=2;
printf("%d", a+++b);
}

(a) results in syntax,
(b) print 7,
(c) print 8,
(d) none,

12. process by which one bit pattern in to another by bit wise operation is
(a) masking,
(b) pruning,
(c) biting,
(d) chopping,

13.value of automatic variable that is declared but not initialized
will be
(a) 0,
(b) -1,
(c) unpredictable,
(d) none,

14. int v=3, *pv=&v;
printf(" %d %d ", v,*pv);
output will be
(a) error
(b) 3 address of v,
(c) 3 3
(d) none.

15. declaration
enum cities{bethlehem,jericho,nazareth=1,jerusalem}
assian value 1 to
(a) bethlehem
(b) nazareth
(c)bethlehem & nazareth
(d)jericho & nazareth

16. #include
#include
void main()
{
char buffer[82]={80};
char *result;
printf( "input line of text, followed by carriage return :n");
result = cgets(buffer);
printf("text=%sn",result);
}
(a) printf("length=%d",buffer[1]);
(b) printf("length=%d",buffer[0]);
(c) printf("length=%d",buffer[81]);
(d) printf("length=%d",buffer[2]);

17. consider scanf and sscanf function , which is true

(a) no standard function called sscanf
(b) sscanf(s,...) is equivalent to scanf(...) except that
input charecter are taken from string s.
(c) sscanf is equivalent to scanf.
(d) none of above.

18. #include
main()
{
char line[80];
scanf("%[^n]",line);
printf("%s",line);
}
what scanf do ?
(a) compilation error . Illegal format string.
(b) terminates reading input into variable line.
(c) and (d) other two options.

19. Problem was big so i couldn't remember . Simple one.

20 . ceil(-2.8) ?
(a) 0
(b) -3.0
(c) -2.0
(d) 2

21. for( p=head; p!=null; p= p -> next)
free(p);

(a) program run smooth.
(b) Compilation error.
(c) Run time error.
(d) None of above.

22. int x[3][4] ={
{1,2,3},
{4,5,6},
{7,8,9}
}
(a) x[2][1] = x[2][2] =x[2][3] = 0
(b) value in fourth column is zero
(c) value in last row is zero
(d) none of above.

24. main ()
{
printf("%u" , main());
}
(a) print garbage.
(b) Execution error
(c) printing of starting address of function main.
(d) Infinite loop.

25 . int a, *b = &a, **c =&b;
....
....
.....
a=4;
** c= 5;

(a) doesn't change value of a
(b) assign address of c to a.
(c) assign value of b to a.
(d) assign 5 to a.

28 . answer: swapping of values .

30 . i =5;
i= (++i)/(i++);
printf( "%d" , i);
prints ,
(a) 2
(b) 5
(c) 1
(d) 6

C Q Bank

Subject: Computer Concepts & C programming
Sub Code: CCP/23

1. Write the algorithm for computing the biggest of 3 given numbers also write the flow chart.
2. Evaluate each of the following expr independent of eachother. The declaration and initialiasation statement is int i=3,j=4,k=2;
i) i+ + - j -- ii)++k % --j
iii) j+1/i-1 iv) j++/i--
3. In the following expr write the hierarchy of computation and also mention the type of the operator
A*x*x+b*x-c/d>=x&&x!=15.0
4. List the different types of constants used in C. Give 2 examples in each type.
5. With a example explain scanf(() and printf() statements.
6. int a,b;
a=11;b=6;
Give the results of
(i) a &b (ii) a: b (iii) a ^b (iv) a>>2 (v)~b
7. List out fundamental data types in C.
8. What is flow chart? List out symbols used in writing flowchart.
9. Explain the use of bitwise operators in C with examples.
10. Explain with example an algorithm and flowchart.
11. Distinguish between variables and keywords with example.
12. Explain different unary operators in C.
13. Explain relational operators in C.
14. With an example getch() and putchar() functions.
15. Explain briefly printf() with format specifiers.
16. Mention different primitive data types and memory required for them.
17. Mention different operators used in C with examples.
18. Write a program to find the squares and cubes of a 2 digit odd number.
19. Write a program to compute the area of an isosceles triangle.
20. Explain the following operators with eqution:
i) Logical operators
ii ) Relational operators
iii) conditional operators
21. Write the expr in C lang and evaluate the arithmetic expr.
a=4,b=2,c=4
b(a+b)²/a²(a-b)
2ab/a+b.c
22. Give the basic structure of a C program and explain with an example to find the area and perimeter of a circle of given radius ‘r’.Give the purpose of each line in the program.
23. What is a variable? How are keywords different from them?
24. Explain the following:
i) Conditional operator
ii) Comma operator
iii) size of operator
25. Identify the syntax errors in the following program
main {}
{
float X;
X=25;
Y=Exp(x);
/** printing section**/
Print(x,y)
}
26. Give the syntax and explain the semantics of formatted i/p and o/p statements.
27. What are bitwise operators available in C?
28. What is a conditional operator? Execute the statement:
y=(x>z)? (2*x+5) :( 1.5*x+3);
29. Write a program segment that will read the value of a x & evaluate the following functions.
1 for x>0
Y= 0 for x=0
-1 for x<0
Using (i) nested if statement (ii) Else if statement (iii) Conditional operator
30. Given 3 sides of a triangle, write a c program to classify the triangle as equilateral, isosceles and scalene.
31. Explain the syntax of switch statement with an example.
32. Explain while loop structure with an example write the flow chart also
33. Write a c program to solve a quadratic equation using switch statement.
34. Using array declaration for Fibonacci series, write a c program to generate first nterms.
35. Write a program to read ten integers from the keyboards and print the sum of evenand odd numbers.
36. Distinguish between while and do while
37. What do you mean by looping? give the syntax for looping statements in c.
38. Write a program to check whether the given number is prime or not. Print the suitable messages.
39. Write a c program to check whether a given 5 digit number is palindrome or not
40. List the different types of control statements explain the types of if statement gives one example for each.
41. Write a program to convert a given decimal numbers into its binary equivalent.
42. Give the syntax of a switch statement and also write an equivalent ladder if statement.
43. Write a program using switch statement to grade the students marks as A=80 andabove=70 and above=60 and above D=40 and above and the rest below 40 as E grade.
44. Write a program to evaluate the following series.
f(x)=x-x³/3! + x/5!-x/7!......................unto given numbers of terms.
45. Write a program to find the number and sum of all integers from 100to 200 and divisible by 7.
46. Write a program segment that will read the value of x and evaluate following function:
1 for x>0
y= 0 for x=0
-1 for x<0
using i) nested if statements ii)else if statements.
47. What is an array? How are they declared in ‘C’? What are the rules to be followedwhile using arrays?
48. a and b are two integers arrays each with n elements. Write a program to find the array c such that
c[i]=a[i]+b[n-1-i]
49. Given two sets A and B of integers, write a program to read them. Determineits UNION and INTERSECTION and print the resultant sets.
50. Write a function to concatenate two strings, write a program to read three Strings anduse the function to concatenate them and print it.
51. Give any five string manipulation library functions, with an example each.
52. You are given sufficient number of 5 paise,10 paise,20 paise,25 paise and 50 paise denominations. Given a value of R rupees and P paise,write a C program to determine the minimum number of coins to get the required value. Use any looping construct to implement the program.
53. Explain dot matrix printer.
54. Explain the structure of floppy disc
55. Explain the structure of hard disc. Compare floppy disc and hard disc.
56. Write a note on CD –ROM
57. Discuss the advantages and disadvantages of machine level language.
58. Discuss the advantages of High level language

C Progrramming Blue Print