0% found this document useful (0 votes)
26 views2 pages

Assignment 4

Uploaded by

Pinjar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Assignment 4

Uploaded by

Pinjar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MTL505 (Introduction to Computers and Programming)

Assignment #4,

1. Explain what is likely to happen when the following situations are encountered in
a program.

• Data type of one of the actual arguments (calling function) does not match
with the type of the formal argument (function prototype and definition).
• The type of expression used in return statement does not match with the type
of the function.

2. Write a function that can be called to compute the product of the two matrices of
size m by n and n by m. The main function provides the values for m and n for
two matrices.

3. Using this code what can you say about the f() near the origin? What happen if we
remove + sign from printf command
# include <stdio.h>
# include <math.h>
double f(double);
void main()
{
double x;
for(x=-.25;x≤.25;x=x+.01)
printf(“f(%+.2f)=%.13f\ n”,x,f(x));
}
double f(double x)
{
return (tan(sin(x))-sin(tan(x)));
}

4. Write a function exchange() to interchange the values of two variables (x&y) and
then call this in main(). Assume that x and y are global variables.

5. What will be the output of printf statements

# include <stdio.h>
int a = 1, b = 2, c = 3;
int f(void);
int main()
{
printf(“%d\n”,f());
printf(“%d%d%d\n”,a, b, c);
return 0;
}
int f(void)

1
{
int b, c;
a = b = c = 4;
return (a + b + c);
}
what will happen if you will replace declaration statement int a = 1, b = 2, c = 3
by extern int a = 1, b = 2, c = 3.

6. Given the following declaration


int x = 10, y = 10;
int ∗p1 = &x, ∗p2 = &y;
What is the value of each of the following expression
• (*p1)++
• –(*p2)
• *p1+(*p2)–
• ++(*p2)-*p1
7. Write a function (using pointer parameters) that compares two integer arrays to see
whether they are identical. The function return 1 if they are identical, 0 otherwise.
8. Write a function (using pointer parameters) that reverse the elements of a given
array.
9. Answer the following question from keyboard “Your name and graduation place” in
the format of “my name is xyz and I have done my graduation from abc college”,
then print this string with the help of function prn string() that uses putchar() to
print a string passed as an argument.
10. First declare the floating array and then initialize the array (value=index of array/2)
using a cast operator. Now make pointer (fp) which points to array x. Print via
pointer arithmetic members of x are adjacent to each other in memory.
11. Use the following piece of code
# include <stdio.h>
int main()
{
char text 1[30], text 2[30]; char ta, tb;
int i;
char message[] = ”Hello, I am a string; what are you?”;
printf(“Original message: %s\n”, message);

(a). to make a function user strlen() to determine the exact length of string (mes-
sage) and then match your result with strlen() function (define in string.h).
(b). to copy the message to text 1 using the loop.
(c). to copy the message to text 2 using pointer arithmetic (ta points to message
and tb points to text 2).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy