© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

21.  What are the advantages of the functions?

Ans:
- Debugging is easier
- It is easier to understand the logic involved in the program
- Testing is easier
- Recursive call is possible
- Irrelevant details in the user point of view are hidden in functions
- Functions are helpful in generalizing the program

Ex - 1: What will be the result of the following program ?
main()
{
 char c=' ',x,convert(z);
 getc(c);
 if((c>='a') && (c<='z'))
 x=convert(c);
 printf("%c",x);
}
convert(z)
{
  return z-32;
}

Ans:
Compiler error

Explanation:
declaration of convert and format of getc() are wrong.

Ex - 2: Find the output for the following C program
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}

Ans:
hai

Explanation:
\n  - newline
\b  - backspace
\r  - linefeed


SLogix Student Projects
bottom