Skip to main content\(\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 16.1 Getting Started Programming in C
Exercise 16.1.1. Translating Java into C.
Rewrite the following Java program into C:.
public class AddNumbers {
public static void main(String[] args) {
int result;
result = 1 + 2;
System.out.println("result is " + result);
}
}
Answer.
See below for the solution:
int main(void) {
int result;
result = 1 + 2;
printf("%d\n", result);
return 0;
}