Example(s):Palindrome, prime, armstrong, "linear search", reverse etc.
Example(s):1575, 1632, 1539 (Only one at a time)
Problem Statement - Output writing implicit typecasting
Write output of the following program if the input given is R
char x, y=32;
cout<<"Input an uppercase alphabet: ";
cout<<"Output 1 would be "<<c<<endl;
cout<<"Output 2 would be "<<d<<endl;
Input an uppercase alphabet: R
Output 1 would be r
Output 2 would be 114
char x, y=32;
Both x and y are character type variables. 32 is stored in y. Although 32 is a number but characters store only ascii numbers against characters. Char storage is nothing but a place to store 8 bit numeric value.
cout<<“Input an uppercase alphabet: “; cin>>x;
Here we collect the value of x. If R is input what actually would get stored would be 82
Here x as 82 and y as 32 would be stored making it 114 as stored value but type as char so if c is displayed it would be small r (ascii 114)
here storage 114 is done as integer, so if displayed it would be displayed as 114
cout<<“Output 1 would be “<<c<<endl; cout<<“Output 2 would be “<<d<<endl;
Will display small r (the char form of ascii 114) and 114 the integer form directly.
The display of char and int forms in 8 bit form are directly interchangeable as the storage is practically the binary number form only. char display or num display are just way to represent them on screen. This kind of conversion is called implicit conversion.