Languages-C & C Plus Plus [TCS Placement]: Sample Questions 70 - 71 of 119

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 70

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is wrong with this program statement? void = 10;

Explanation

  • The word void is a reserved word in C language and cannot be used as a user-defined variable.
  • Void functions are created and used just like value-returning functions except they do not return a value after the function executes.
  • Void functions use the keyword “void.”
  • A void function performs a task, and then control returns back to the caller-but, it does not return a value.
Given the Image is Define the Void () Function

Question 71

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What does the function toupper () do?

Explanation

  • function int toupper (int c) converts lowercase letter to uppercase.
  • Syntax: int toupper (int c) ;
  • This function returns uppercase equivalent to c, if such value exists, else c remains unchanged.
  • The value is returned as an int value that can be implicitly casted to char.
  • Example:
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. intmain()
  4. {
  5.     inti=0;
  6.     charc;
  7.     charstr[] =“welcomefriends”;
  8.     while(str[i])
  9.     {
  10.         putchar(toupper(str[i]));
  11.         i++;
  12.     }
  13.     return0;
  14. }
  • Let us compile and run the above program to produce the following result-

WELCOME FRIENDS

Developed by: