main()

{

char string[]="Hello World";

display(string);

}

void display(char *string)

{

printf("%s",string);

}

Answers were Sorted based on User's Feedback



main() { char string[]="Hello World"; display(string); } ..

Answer / susie

Answer :

Compiler Error : Type mismatch in redeclaration of
function display

Explanation :

In third line, when the function display is
encountered, the compiler doesn't know anything about the
function display. It assumes the arguments and return types
to be integers, (which is the default type). When it sees
the actual function display, the arguments and type
contradicts with what it has assumed previously. Hence a
compile time error occurs.

Is This Answer Correct ?    21 Yes 3 No

main() { char string[]="Hello World"; display(string); } ..

Answer / pratibha

this problem of type mismatching can be solved by declaring display function as a first line inside main() so that compiler will know that display is of type void and then it will resolve type mismatch while encountering calling function of display.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

write a c program to Reverse a given string using string function and also without string function

1 Answers  


what is variable length argument list?

2 Answers  


main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

1 Answers  


What are the files which are automatically opened when a C file is executed?

1 Answers  


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,






What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


how to delete an element in an array

2 Answers   IBM,


Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }

2 Answers   Broadridge,


Categories