predict the output of the following program: #include
#include void main ()
{ char STR [ ] ="E1x2";
for (int b=0;STR [B]!=/0';B++)
{
if(!isdigit(STR[B])
STR[B]='@';
else if (isupper(STR[b]))
STR [b]='*';
else
STR [b]=STR [b+1];
{
puts (STR);
[
Answers
Answer:
predict the output of the following program: #include
#include void main ()
{ char STR [ ] ="E1x2";
for (int b=0;STR [B]!=/0';B++)
{
if(!isdigit(STR[B])
STR[B]='@';
else if (isupper(STR[b]))
STR [b]='*';
else
STR [b]=STR [b+1];
{
puts (STR);
[
The program will have the following errors:
#include
| ^
main.c: In function ‘main’:
main.c:12:19: error: ‘B’ undeclared (first use in this function)
12 | for (int b=0;STR [B]!=/0';B++)
| ^
main.c:12:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:23: error: expected expression before ‘/’ token
12 | for (int b=0;STR [B]!=/0';B++)
| ^
main.c:12:25: warning: missing terminating ' character
12 | for (int b=0;STR [B]!=/0';B++)
| ^
main.c:12:25: error: missing terminating ' character
12 | for (int b=0;STR [B]!=/0';B++)
| ^~~~~~
main.c:22:1: error: expected declaration or statement at end of input
22 | [
| ^
Explanation:
In #include the preprocessor needs to be specified in which we can add either stdio.h or conio.h.
The opening parenthesis of put function is there without it's closing parenthesis.
STR B used is not declared.