CANT DO IT ANYONE CAN HELP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

21st Apr 2020, 11:50 AM
Mustafa
Mustafa - avatar
3 Answers
+ 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
21st Apr 2020, 12:38 PM
Mustafa
Mustafa - avatar
+ 2
First try from your side and show your attempts.
21st Apr 2020, 11:59 AM
A͢J
A͢J - avatar
+ 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...
21st Apr 2020, 12:01 PM
sarada lakshmi
sarada lakshmi - avatar