\documentclass[12pt]{exam}
\newtheorem{theorem}{Theorem}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{commath}
\usepackage{epstopdf}
\usepackage{tikzpagenodes}
\usepackage{float}
\begin{document}
\usepackage{float}
\usepackage{lipsum}
\newenvironment{absolutelynopagebreak}
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
\begin{questions}
\question Answer the following questions on the basis of given diagram
\begin{figure}[hbt!]
\begin{center}
\includegraphics[scale=0.70]{images/assignment-1.png}
\end{center}
\end{figure}
\end{questions}
\end{document}
I am trying to frame a picture based function but the picture is going down in the next page, besides that picture is shifted towards right, how to bring it back in the current page, in the center position and just near to the place where the question number is labelled.
Here is my updated code as per the suggestions by @ABlueChameleon
\documentclass[12pt]{exam}
\newtheorem{theorem}{Theorem}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{commath}
\usepackage{epstopdf}
\usepackage{tikzpagenodes}
\usepackage{float}
\begin{document}
\begin{questions}
\question Answer the following questions on the basis of given diagram
\begin{figure}[hbt!]
\begin{absolutelynopagebreak}
\includegraphics[scale=0.70]{images/assignment-1.png}
\end{absolutelynopagebreak}
\end{figure}
\end{questions}
\end{document}

assignment-1.pngto compile this code as is. Please use example images of themwepackage (available for everyone), or, if you cannot simulate the problem with the example images, show a screenshot of the output. – Fran Apr 27 '20 at 03:32\includegraphics[width=<width>,height=<height>{example-image-a}if the picture dimensions were provided by the OP :) – BambOo Apr 27 '20 at 11:25