Question

Answer the questions based on the program given below. a) Write the function prototype of fnFunny...

Answer the questions based on the program given below.

a) Write the function prototype of fnFunny function.

b) Write the output produced by the above program

#include <stdio.h>

int main (void){

      unsigned short i =4;

      unsigned long j = 6 ;

      short k = 2 ;

      k = fnFunny ( i , j );

      printf("i = %hu, j = %lu, k = %hi\n", i, j, k);

      return 0;

}

short fnFunny (unsigned short i, unsigned long j ){

      short k = 0;

      for(   ;   ;   )

      {

                  printf("i = %hu, j = %lu, k = %hi\n", i, j, k);

                  if (--i == 3 ) continue;

                  k += i ;

                  if (j++ == 6) break;

      }

      return k;

}

Homework Answers

Answer #1
a)
the function prototype of fnFunny function.
short fnFunny (unsigned short, unsigned long);

b)
#include <stdio.h>

short fnFunny (unsigned short, unsigned long);

int main (void){

      unsigned short i =4;

      unsigned long j = 6 ;

      short k = 2 ;

      k = fnFunny ( i , j );

      printf("i = %hu, j = %lu, k = %hi\n", i, j, k);

      return 0;

}

short fnFunny (unsigned short i, unsigned long j ){

      short k = 0;

      for(   ;   ;   )

      {

                  printf("i = %hu, j = %lu, k = %hi\n", i, j, k);

                  if (--i == 3 ) continue;

                  k += i ;

                  if (j++ == 6) break;

      }

      return k;

}

the output produced by the above program is 

i = 4, j = 6, k = 0
i = 3, j = 6, k = 0
i = 4, j = 6, k = 2


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
#include <stdio.h> extern unsigned long long sum(unsigned int *array, size_t n); int main(void) { unsigned int...
#include <stdio.h> extern unsigned long long sum(unsigned int *array, size_t n); int main(void) { unsigned int array[] = { 1, 1, 1, 3 }; unsigned long long r = sum(array, sizeof(array) / sizeof(*array)); printf("Result is: %llu (%s)\n", r, r == 6 ? "correct" : "incorrect"); return 0; } Complete the code for the line that calls the sum function. Write the sum function.
In C language: Partially finished program is given below. The second and third parameters of the...
In C language: Partially finished program is given below. The second and third parameters of the count() function need to be pointer parameters. However, the programmer forgot to write the necessary ampersands and asterisks in the prototype, call, function header, and function code. Add these characters where needed so that changes made to the parameters adults and teens actually change the underlying variables in the main program. #include #define MAX 10 void count( int ages[], int adults, int teens );...
A program is already given to you.  There are five problems in this skeleton version of the...
A program is already given to you.  There are five problems in this skeleton version of the program, each is 10 points. All you got to do is complete the missing code in each function. What the function does is clearly stated in the name of the function.   // ASSIGNMENT ON FUNCTIONS #include <stdio.h> // Problem 1: Compile with gcc func_assignment.c -Wall // There are some warnings because there is a mismatch between // data type passed and defined. // Find...
Experience with Functions Are the following statements a function header, a prototype or a function call?...
Experience with Functions Are the following statements a function header, a prototype or a function call? double calcMonthlyPmt(double amt); void displayResults() void showMenu(); showNum(45.67); area = CalArea(5,10); Write the function calls for the following headers and prototypes: void showValue(int quantity) void display(int arg1, double arg2, char arg3); pass the following to the call: int age; double income; char initial double calPay(int hours, double rate); What is the output of the following program? #include <iostream> using namespace std; void showDouble(int); //Function...
how can i write a function to call by reference ? using fopen, printf, fclose statements....
how can i write a function to call by reference ? using fopen, printf, fclose statements. #define _CRT_SECURE_NO_WARNINGS #define PI 3.14159 #include <stdio.h> void findArea(double *area, double r); int main(void) { double area, r = 100.5; findArea(&area, r); printf("area = %.2lf\n", area); return 0; }
Write a C/C++ program that performs the tasks described below. If there is just 1 command-line...
Write a C/C++ program that performs the tasks described below. If there is just 1 command-line argument and it is -hw you should simply print hello world and then exit(0). Otherwise, the program should provide a function named mm_alloc. This is the function prototype: void *mm_alloc(int num_bytes_to_allocate) mm_alloc function should obtain space for the user from a block which you obtain via mmap. You should obtain the block on the first invocation and the block size should be some number...
I am trying to write a program in C language but keep running into errors. Any...
I am trying to write a program in C language but keep running into errors. Any help would be awesome. here is my code I have so far. #include <stdio.h> #include <conio.h> #include <string.h> int main(){    int lenght, i = 0, state = 0;    char line[100];    printf("enter the string for checking of comment line: \n");    gets(line);    while(i < strline(line)){        switch(state){            case 0: if (line[i] == '/'){               ...
Write a program that reads a string and outputs the number of lowercase vowels in the...
Write a program that reads a string and outputs the number of lowercase vowels in the string. Your program must contain a function with a parameter of a char variable that returns an int. The function will return a 1 if the char being passed in is a lowercase vowel, and a 0 for any other character. The output for your main program should be: There are XXXX lowercase vowels in string yyyyyyyyyyyyyyyyyyyyyy Where XXXX is the count of lowercase...
Q3) Write a function that takes two arrays and their size as inputs, and calculates their...
Q3) Write a function that takes two arrays and their size as inputs, and calculates their inner product (note that both arrays must have the same size so only one argument is needed to specify their size). The inner product of two arrays A and B with N elements is a scalar value c defined as follows: N−1 c=A·B= A(i)B(i)=A(0)B(0)+A(1)B(1)+···+A(N−1)B(N−1), i=0 where A(i) and B(i) are the ith elements of arrays A and B, respectively. For example, theinnerproductofA=(1,2)andB=(3,3)isc1 =9;andtheinnerproductofC= (2,5,4,−2,1)...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT