write a program in qbasic to accept a string and display each character of string in separate line
Answers
Answer:
Code
Explanation:
#include<stdio.h>
int main()
{
int i;
char s[100];
scanf("%s", s);
for(i=0; s[i]!='\0'; i++)
{
printf("%c", s[i]);
if(s[i]==' ')
{
printf("\n");
}
}
}
Answer:
It is not possible to write the program in QBasic you told. But I have written a different program with similar results you can go through for your help.
Explanation:
-------------------------------------------------------------------------------------------------------------
CLS
PRINT " Please Enter a Word "
INPUT w$
PRINT " Your entered word is "; w$
PRINT " Please Enter number of letters in the word "
INPUT l
LET l = l - 1
DIM L(l) AS STRING
PRINT " Enter each letter of your word "
i = 0
DO WHILE (i <= l)
PRINT "Enter the "; i; "th letter :"
INPUT L(i)
i = i + 1
LOOP
CLS
PRINT "The letters in your word are "
i = 0
DO WHILE (i <= l)
PRINT "The"; i; "th letter is "; L(i)
i = i + 1
LOOP
END
-------------------------------------------------------------------------------------------------------------
You can read and test this program on your QBasic platform.
Just copy and paste the program from here to your QBasic platform.
Press run option and select start. the program will run automatically.
-------------------------------------------------------------------------------------------------------------