Arrays I-Introduction to Computer Programming-Assignment, Exercises of Computer Engineering and Programming

This assignment was given by Dr. Jyoti Lokesh at Biju Patnaik University of Technology, Rourkela for Computer Programming course. it includes: Integer, Arrays, Print, Elements, Arrays, Sample, Input, Output, Common, Elements, Index

Typology: Exercises

2011/2012

Uploaded on 07/13/2012

ekvir
ekvir 🇮🇳

4

(1)

35 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer programming Assignment(5 5 mar ks)
Deadline 3-01-2012 section 4
4-01-2012-Section 08
1. Declare two integer arrays of sizes 10 each. Your task is to print the elements which are
common in both the arrays.
Sample Input:
a[]: 1,2,3,4,5,6,7,8,9,20
b[]: 2,4,6,8,10,12,14,16,18,20
Sample Output:
Common elements: 2, 4, 6, 8, 20
2. Write a program which will take a character array a[] of size 15 and a character array b[] of size
10 from the user. Also take an index from the user, and starting from the given index place array
b[] in array a[]. At the end, display a[].
Sample Input:
a[]: program
b[]: computer
Index: 3
Sample Output:
a[]: procomputer
3. Write a program in which you have a character array of size 50. Input array from the user. Then
reverse all the words that are stored in the array. Input will contain spaces.
Sample Input:
this is a computer programming exercise
Sample Output:
siht si a retupmoc gnimmargorp esicrexe
4. Declare a character array A[] of size 15 and B[] of size 10. Take input in both the arrays. Your
task is to search the contents of array B[] in array A[].
Sample Input: A[ ] = helloworld B[ ] = hello
Sample Output: Word found
Sample Input: A[ ] = helloworld B[ ] = good
Sample Output: Word not found
docsity.com
pf3

Partial preview of the text

Download Arrays I-Introduction to Computer Programming-Assignment and more Exercises Computer Engineering and Programming in PDF only on Docsity!

Computer programming Assignment(55 marks)

Deadline 3-01-2012 section 4

4-01-2012-Section 08

  1. Declare two integer arrays of sizes 10 each. Your task is to print the elements which are common in both the arrays. Sample Input: a[] : 1,2,3,4,5,6,7,8,9, b[]: 2,4,6,8,10,12,14,16,18,

Sample Output: Common elements: 2, 4, 6, 8, 20

  1. Write a program which will take a character array a[] of size 15 and a character array b[] of size 10 from the user. Also take an index from the user, and starting from the given index place array b[] in array a[]. At the end, display a[].

Sample Input: a[] : program b[]: computer Index: 3

Sample Output: a[]: procomputer

  1. Write a program in which you have a character array of size 50. Input array from the user. Then reverse all the words that are stored in the array. Input will contain spaces.

Sample Input: this is a computer programming exercise

Sample Output: siht si a retupmoc gnimmargorp esicrexe

  1. Declare a character array A[] of size 15 and B[] of size 10. Take input in both the arrays. Your task is to search the contents of array B[] in array A[].

Sample Input: A[ ] = helloworld B[ ] = hello Sample Output: Word found Sample Input: A[ ] = helloworld B[ ] = good Sample Output: Word not found

  1. Declare a character array of size 20. Take input in the array (including spaces). Your task is to capitalize 1st^ letter of each word, and if the first letter is already a capital letter then replace the 3 rd^ letter with @.

Sample Input: Hello world Sample Output: He@lo World

  1. Write a program which will take choice (1 – 3) from the user in main(). For choice 1 call function1() , for choice 2 call function2() and for choice 3 end the program. Use switch case for handling user choice. The functions will perform the following tasks: function1() will take a number within its scope and print all the even numbers upto that number. function2() will take a number as argument from main() and print all the multiples of 3 upto that number.

Sample Input: 2 , 16 Sample Output: 3, 6, 9, 12, 15

  1. Write a program which will take an alphabet (small or capital) from the user in main() and pass it to a function previous_alphabet()****. The function will return the alphabet previous to the given alphabet to main(). Display the results in main(). After every output, ask whether the user wants to run the program again or not.

Characters ASCII Values

A – Z 65 – 90

a – z 97 – 122

Sample Input: f Sample Output: e Sample Input: A Sample Output: Error! No previous alphabet.