1. Start by sketching your program on paper using a flowchart or pseudocode. Thi
ID: 3672324 • Letter: 1
Question
1. Start by sketching your program on paper using a flowchart or pseudocode. This will make it easier for you to write your program and allow you to see what must be done. Use the following questions as a guide.
a)How will you get 1 character from the string?
b)How will you determine if that character is the NULL character?
c)How will you determine if that character is a lowercase letter?
d)How will you convert a lowercase letter into an uppercase letter?
e)When do you need to read (load) the next Word of the string?
f)How do you move from character to character within a Word?
g)What data items and counters do you need to keep track of?
how to use this for mars mips
help please.
Explanation / Answer
#include<stdio.h>
#include<conio.h>
int main() {
char str[20], ch;
int count = 0, i;
printf(" Enter a string : ");
scanf("%s", &str);
printf(" Enter the character to be searched : ");
scanf("%c", &ch);
for (i = 0; str[i] != ''; i++) {
if (str[i] == ch)
count++;
}
if (count == 0)
printf(" Character '%c'is not present", ch);
else
printf(" Occurence of character '%c' : %d", ch, count);
if(islower(ch))
toupper(ch);
cout<<ch;
if(ch==" ")
cout<<"null character";
return (0);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.