Answer to Question #223694 in C++ for ddd

Question #223694

Find the length of the following strings

char str1[] = "I love C+++ Programming! ";

char str2[] = "This is so cool!";

char str3[] = "Good job learner!";

The output should be like the following format:

The length of str1 is __

The length of str2 is __

The length of str3 is __


1
Expert's answer
2021-08-05T14:22:56-0400
#include<iostream>


using namespace std;


int main(){
	
	char str1[] = "I love C+++ Programming! ";
	char str2[] = "This is so cool!";
char str3[] = "Good job learner!";
		int counter  = 0;
		for(auto x: str1){
		counter  += 1;
	}


int counter1  = 0;


		for(auto x: str2){
		counter1  += 1;
	}
	
	int counter2  = 0;


		for(auto x: str3){
		counter2  += 1;
	}






cout<<"The length of str1 is "<<counter<<endl;
cout<<"The length of str2 is "<<counter1<<endl;
cout<<"The length of str3 is "<<counter2<<endl;




	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS