Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

***
// Find the Nth term in the series
#include
#include
#include

int main()
{
int a = 0,b = 0,i = 0, n;
char num[100];

printf("Enter the number:");
scanf("%s",num); //get the input up to 100 digit
n = strlen(num);
while(n>0)
{
if(i==0) //add even digits when no of digit is even and vise versa
{
a+=num[n-1]-48;
n--;
i=1;
}
else //add odd digits when no of digit is even and vice versa
{
b+=num[n-1]-48;
n--;
i=0;
}
}
printf("Difference between the sum of odd and even position digits is %d",abs(a-b)); //print the difference of odd and even

return 0;
}
***
2 years ago
Ans : D
Explanation: This program will generate an error as the break statement does not end with an semi-colon in case 5.
2 years ago
Option B
Expression gets evaluated in cases. The control goes to the second case block after evaluating 1+2 = 3 and “Online” is printed.
2 years ago
As others also say below, the Python/C++ combo is the de facto standard in machine learning and AI today. The second best is R/Rcpp/C++. Other ecosystem has also parallel offers (even PHP has an ML library), but the industry clearly prefers the Python/C++ combo today.

There might be some changes in the future. Rust might get stronger and actually take some share both from C++ (for writing ML libraries) and from Python (for putting ML algorithms in production) in the ML/AI business.

Julia is a strong contender, let us see how far she can go. She has the ambition to dethrone both Python and C++ all at once. But I am personally not sure if it is ever gonna happen.

Other languages such as Go, JavaScript, Kotlin and Swift will also have some roles in using pre-trained algorithms.

But today, the most dominant player is Python/C++ [and it might be perhaps Python/Rust in the future, but this is only my personal fantasy ;)].
2 years ago
You're going to need to have core Java programming experience and knowledge. The reverse- end inventor is going to be dealing with data processing.

*JDBC*-your going to need experience using JDBC in order to communicate with a database.
*Concurrency*-your going to need to know how to safely design, develop, and applymulti-threaded processes.
*API*-your going to have to be suitable to integrate with other systems using varied APIs.
*Testing*-your going to need to be good at testing an debugging to make sure all integrated systems are working as designed.
On top of these, it goes without saying you'll need to integrate maven and git into your design development.
2 years ago
Ok, so in n-ary tree the structure of node will look like this-)
**
struct Node{
int val;
vector childs;
Node(int x,vector child){
val=x;
childs=child;
}
};
**
//Here we will only look towards the traversing part, for building n-ary tree ,you can take help from gfg or leetcode .
**
vector postorder(struct Node* root){
if(root==NULL)
return {};
vector pos;// for storing traversal
stack st;
st.push(root);
while(!st.empty())
{
Node* curr=st.top();
st.pop();
pos.push_back(curr->val);
// node values are entered in reverse order so we have to reverse //it again in end
for(auto x: curr->childs)// looping through the childs of curr node
{
if(!x)
st.push(x);
}
}
reverse(pos.begin(),pos.end());
return pos;
}
**
2 years ago
Apple added a JSON parser and serializer in iOS 5.0 and Mac OS X 10.7. See NSJSONSerialization.

To generate a JSON string from a NSDictionary or NSArray, you do not need to import any third party framework anymore.

Here is how to do it:
***
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryOrArrayToOutput
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];

if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
***
3 years ago
This is an old question, but I think the answer needs to be updated.

This method does not involve defining and creating your own custom view. In iOS 6 and up, you can easily change the background color and the text color by defining the
***
-(void)tableView:(UITableView *)tableView
willDisplayHeaderView:(UIView *)view
forSection:(NSInteger)section
***
section delegate method

For example:
***
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
// Background color
view.tintColor = [UIColor blackColor];

// Text Color
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor whiteColor]];

// Another way to set the background color
// Note: does not preserve gradient effect of original header
// header.contentView.backgroundColor = [UIColor blackColor];
}
***
3 years ago
In 3.0, there's now an easier way - hook into the new motion events.

The main trick is that you need to have some UIView (not UIViewController) that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events:
***
@implementation ShakingView

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
// Put in code here to handle shake
}

if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}

- (BOOL)canBecomeFirstResponder
{ return YES; }

@end
***
You can easily transform any UIView (even system views) into a view that can get the shake event simply by subclassing the view with only these methods (and then selecting this new type instead of the base type in IB, or using it when allocating a view).

In the view controller, you want to set this view to become first responder:
***
- (void) viewWillAppear:(BOOL)animated
{
[shakeView becomeFirstResponder];
[super viewWillAppear:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
[shakeView resignFirstResponder];
[super viewWillDisappear:animated];
}
***
Don't forget that if you have other views that become first responder from user actions (like a search bar or text entry field) you'll also need to restore the shaking view first responder status when the other view resigns!

This method works even if you set applicationSupportsShakeToEdit to NO.
3 years ago
What I had to do was to run

pod install
again and thus configuring cocoapods for the new Preview configuration. It updated my project, the workspace and the Pod's project file and the problem disappeared
3 years ago
Despite some of the suggested answers being very creative and extremely clever, the simplest solution is as follows:
***
button.semanticContentAttribute = UIApplication.shared
.userInterfaceLayoutDirection == .rightToLeft ? .forceLeftToRight : .forceRightToLeft
***
As simple as that. As a bonus, the image will be at the left side in right-to-left locales.
this is iOS 9 +.
3 years ago
Objective-C:
***
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
***
Swift 3+:
***
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
***
3 years ago