11.3 LAB: Convert String to Cyphertext cstring
#include <iostream>
#include <cstring>
#include<string>
using namespace std;
char* cypher(string str, int rotate)
{
int size=str.size();
char* cstr=new char[size];
cstr=&str[0];
for (int i=0; i < size; i++)
{
if (*(cstr+i) >= 'A'
&& *(cstr+i) <= 'Z')
{
*(cstr+i) = (char)(((*(cstr+i) + rotate - 'A' + 26) % 26) +
'A');
}
else if (*(cstr+i) >=
'a' && *(cstr+i) <= 'z')
{
*(cstr+i) = (char)(((*(cstr+i) + rotate - 'a' + 26) % 26) +
'a');
}
}
return cstr;
}
int main()
{
char* s;
s=cypher("ABC",0);
puts(s);
return 0;
}
11.3 LAB: Convert String to Cyphertext cstring mplement the following (Called a Ceasar Cypher, since it...
Please explain lowing function should allocate space for a new string, copy the nd convert every string from the passed argument into the new string, a lower-case character in the new string into an upper-case modify the original st character (do not ring). Fill-in the blanks and the body of the for0 loop: char* upcase char str)t char p; char* result; result, (char*) malloc( - strcpy( for( p-result; *p!-10': p++) / Fill-in 'A'-65, 'a' 97, 'Z 90, 'z' 122/ return...
In C++ please. Thank you!! #include <iostream> #include <cstring> // print an array backwards, where 'first' is the first index // of the array, and 'last' is the last index void writeArrayBackward(const char anArray[], int first, int last) { int i = 0; for (i = last; i >= first; i--) { std::cout << anArray[i]; } std::cout << std::endl; } // test driver int main() { const char *s = "abc123"; writeArrayBackward(s, 0, strlen(s) - 1); } // Using the...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
Write this function in c++.Use of string and <cstring> is not allowed .You are required to use char* and implement the use of ** in this question . Gtest case to pass: #include "q1.cpp" #include <gtest/gtest.h> //-------------------Q1_8----------------- TEST(Question1_8, First) { char t1[]="Hello World"; char res1[] = "Hello"; char res2[] = "World"; char** r= StrTok(t1,' '); ASSERT_EQ(0, strcmp(r[0],res1) ); ASSERT_EQ(0, strcmp(r[1],res2) ); } TEST(Question1_8, Second) { char t1[]="Hello?World?OOP"; char res1[] = "Hello"; char res2[] = "World"; char res3[] = "OOP"; char**...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...
#include <iostream> #include <string> #include <cstring> using namespace std; class Node{ private: int data; Node* nextNodePtr; public: Node(){} void setData(int d){ data = d; } int getData(){ return data; } void setNextNodePtr(Node* nodePtr){ nextNodePtr = nodePtr; } ...
Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...
Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...
C++ When running my tests for my char constructor the assertion is coming back false and when printing the string garbage is printing that is different everytime but i dont know where it is wrong Requirements: You CANNOT use the C++ standard string or any other libraries for this assignment, except where specified. You must use your ADT string for the later parts of the assignment. using namespace std; is stricly forbiden. As are any global using statements. Name the...