Question 1
5. Define a classes Person and it has attributes name, DOB, Address, Father name, Classname and use set function to give value and get function to show value. Create Object of
the class.
Answer
039;s Name: " << person1.getFatherName() << endl;
cout << "Class Name: " << person1.getClassName() << endl;
return 0;
}
Question 2
akhil took two pointers one that points at the start of the string and the other at the end of
the string. The characters are reversed one by one with the help of these two
pointers.reverse all characters,build a flowchart and algorithm and write c code
Answer
include
int main()
{
char str[100], *p1, *p2, temp;
printf("Enter a string: ");
scanf("%s", str);
p1 = str; //points to the start of the string
p2 = str + strlen(str) - 1; //points to the end of the string
while(p1<p2) //loop continues till pointers meet or cross each other
{
temp = *p1;
*p1 = *p2;
*p2 = temp;
p1++; //increment the first pointer p2--; //decrement the second pointer
}
printf("Reversed String: %s", str);
return 0;
}
programming/c-strings
Computer Science Answer Note #2
of 2
Report
Tell us what’s wrong with it:
Thanks, got it!
We will moderate it soon!
Free up your schedule!
Our EduBirdie Experts Are Here for You 24/7! Just fill out a form and let us know how we can assist you.
Take 5 seconds to unlock
Enter your email below and get instant access to your document