You will have to place both menu snippets in the same place within the template and use CSS or JS to trigger and display the appropriate one for the screen width.
I’m not aware of any built-in code PHP has for detecting screen width (If any). I’ve been working with MVC on a project which as an “if_is_mobile” function you can wrap stuff in, however there’s no way of defining the breakpoints which makes it pretty much useless. As mentioned your best bet is CSS or JS.
@nisha – That post is for the WordPress Mobile Pack – I am using Ubermenu.. I went into Appearance -> Editor, but don’t find the wp_nav_menu there.
@maryamzafar: Sorry, but you’re using Ubermanu, a premium/paid plugin. It’s best to go to the support site where you bought the plugin for help with customizations and issues. You paid for support when you bought the products, so you should contact the developers. These forums are for plugins available at wordpress.org/plugins/. See http://codex.wordpress.org/Forum_Welcome#Commercial_Products