+ 1
CANT DO IT ANYONE CAN HELP?
There are some alphabet words and their points below down. So, calculate and display the total point of text that entered from the user. 1 POINTS->A,E,I,K,L,R,T 2 POINTS->M,O,S,U 3 POINTS->B,D,U,Y 4 POINTS->C,S,Z 5 POINTS-> G,H,P 7 POINTS->F,V 8 POINTS->J
3 Réponses
+ 1
#include <string.h>
int main()
{
char text[200];
char alph[3]={'a','b','c'};
int length;
int points;
int leng;
printf("ENTER YOUR TEXT> ");
gets(text);
length=strlen(text);
leng=strlen(alph);
for(int i=0;i<length;i++)
{
for(int j=0;j<=leng;j++){
if(text[i]==alph[j])
{
points+=1;
}
}
}
printf("%d",points);
return 0;
}
Thanks for your answer everyone.I did simply one of my question.So if anyone who wonder about syntax,i'm leaving this anwser here.#StaySafe #StayHome
+ 2
First try from your side and show your attempts.
+ 1
Yeah, use conditional stmts and loop stmts... If, else if and else... Or you can also go for switch stmt...First apply loop on the given string and find the respective character and add point to it... Finally you'll get the total points...