X hits on this document

244 views

0 shares

0 downloads

0 comments

18 / 93

Page 18 of 93

Week 8

a) Write a C program to generate Pascal’s triangle.

b) Write a C program to construct a pyramid of numbers.

Week 9

Write a C program to read in two numbers, x and n, and then compute the sum of this geometric progression:

1+x+x2+x3+………….+xn

For example: if n is 3 and x is 5, then the program computes 1+5+25+125.

Print x, n, the sum

Perform error checking. For example, the formula does not make sense for negative exponents – if n is less than 0. Have your program print an error message if n<0, then go back and read in the next pair of numbers of without computing the sum. Are any values of x also illegal ? If so, test for them too.

Week 10

a) 2’s complement of a number is obtained by scanning it from right to left and complementing all the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C program to find the 2’s complement of a binary number.

b) Write a C program to convert a Roman numeral to its decimal equivalent.

Week 11

Write a C program that uses functions to perform the following operations:

i) Reading a complex number

ii) Writing a complex number

iii) Addition of two complex numbers

iv) Multiplication of two complex numbers

(Note: represent complex number using a structure.)

Week 12

a) Write a C program which copies one file to another.

b) Write a C program to reverse the first n characters in a file.

(Note: The file name and n are specified on the command line.)

Week 13

Write a C program that uses functions to perform the following operations on singly linked list.:

i) Creation  ii) Insertion   iii) Deletion   iv) Traversal

Week 14

Write a C program that uses functions to perform the following operations on doubly linked list.:

i) Creation ii) Insertion   iii) Deletion   iv) Traversal in both ways

Week 15

Write  C programs that implement stack (its operations) using

i) Arrays   ii) Pointers   

Week 16

Write C programs that implement Queue (its operations) using

i) Arrays   ii) Pointers   

Week 17

Write a C program that uses Stack operations to perform the following:

i) Converting infix expression into postfix expression

ii) Evaluating the postfix expression

Week 18

Write a C program that uses functions to perform the following:

i) Creating a Binary Tree of integers

ii) Traversing the above binary tree in preorder, inorder and postorder.

Document info
Document views244
Page views244
Page last viewedSat Dec 10 04:18:38 UTC 2016
Pages93
Paragraphs3102
Words29541

Comments