0% found this document useful (0 votes)
33 views

Indian Institute of Information Technology, Allahabad Course: Introduction To Programming (ITP) Batch: B.Tech (IT) First Semester (Section 1)

The document outlines 10 programming assignments for an Introduction to Programming course, including writing functions to sum arrays, call functions in loops, perform operations on matrices, calculate factorials recursively and non-recursively, reverse strings in arrays, search and replace strings in arrays, return unique words from sentences, and compute the Fibonacci series using functions and recursively.

Uploaded by

ashruth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Indian Institute of Information Technology, Allahabad Course: Introduction To Programming (ITP) Batch: B.Tech (IT) First Semester (Section 1)

The document outlines 10 programming assignments for an Introduction to Programming course, including writing functions to sum arrays, call functions in loops, perform operations on matrices, calculate factorials recursively and non-recursively, reverse strings in arrays, search and replace strings in arrays, return unique words from sentences, and compute the Fibonacci series using functions and recursively.

Uploaded by

ashruth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Indian Institute of Information Technology, Allahabad

Course: Introduction to Programming (ITP)


Batch: B.Tech (IT) First Semester (Section 1)
Lab Assignment #4
Lab Sessions: 10.10.2018
Evaluation Date: 10.10.2018

1. Write code to sum the elements of an array of int. (Write it as a function) Use it to sum the array
int a[] = {1, 2, 3, 4, 5, 6};
(The answer, of course, should be 21).

2. Write a loop to call the multbytwo() function on the numbers 1-10. For extra credit, compile your main function and
the multbytwo() function as two source files, one function per file.

3. Write a program using switch control statement for addition, substation and multiplication on two square matrix of
5*5.

4. Write a function to compute the factorial of a number, and use it to print the factorials.

5. Write a recursive function to compute the factorial of a number, and use it to print the factorials.

6. Write a program to reverse the strings stored in the following array of pointers to strings:
a. char *s[ ] = {"To err is human...","But to really mess things up...","One needs to know C!!"};
Hint: Write a function xstrrev (string) which should reverse the contents of one string. Call this function for
reversing each string stored in s.

7. Write a program that uses an array of pointers to strings str[ ]. Receive two strings str1 and str2 and check if str1 is
embedded in any of the strings in str[ ]. If str1 is found, then replace it with str2.
char *str[ ] = { "We will teach you how to...","Move a mountain", "Level a building", "Erase the past", "Make a
million","...all through C!"
};
For example if str1 contains "mountain" and str2 contains "car", then the second string in str should get changed to
"Move a car".

8. Implement a function that returns an array of unique strings (words) and write the unique string in a file. The
complete string (sentence) is entered by the user. The function has signature: char *uniqueStrings (char *sentence);

9. Write a program to compute and print first 20 numbers of Fibonacci series using function.

10. Write a program to compute and print first 20 numbers of Fibonacci series using recursive function.

You might also like