Golang Find Output Programs
- Golang Basics | Find Output Programs | Set 1
- Golang Basics | Find Output Programs | Set 2
- Golang Basics | Find Output Programs | Set 3
- Golang Basics | Find Output Programs | Set 4
- Golang Basics | Find Output Programs | Set 5
- Golang If/Else | Find Output Programs | Set 1
- Golang If/Else | Find Output Programs | Set 2
- Golang Switch | Find Output Programs | Set 1
- Golang Switch | Find Output Programs | Set 2
- Golang goto, break, continue | Find Output Programs | Set 1
- Golang goto, break, continue | Find Output Programs | Set 2
- Golang const, Type Casting | Find Output Programs | Set 1
- Golang const, Type Casting | Find Output Programs | Set 2
- Golang for Loop | Find Output Programs | Set 1
- Golang for Loop | Find Output Programs | Set 2
- Golang for Loop | Find Output Programs | Set 3
- Golang Functions | Find Output Programs | Set 1
- Golang Functions | Find Output Programs | Set 2
- Golang Recursion | Find Output Programs | Set 1
- Golang Recursion | Find Output Programs | Set 2
- Golang Strings | Find Output Programs | Set 2
- Golang Closures | Find Output Programs | Set 1
- Golang Closures | Find Output Programs | Set 2
- Golang Arrays | Find Output Programs | Set 1
- Golang Arrays | Find Output Programs | Set 2
- Golang Arrays | Find Output Programs | Set 3
- Golang Structures | Find Output Programs | Set 1
- Golang Structures | Find Output Programs | Set 2
- Golang Pointers | Find Output Programs | Set 1
- Golang Pointers | Find Output Programs | Set 2
- Golang Conversions | Find Output Programs | Set 1
- Golang Conversions | Find Output Programs | Set 2
- Golang Date & Time | Find Output Programs | Set 1
- Golang Date & Time | Find Output Programs | Set 2
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 1
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 2
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 3
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 4
Answer Program 1:
Output:
Explanation:
The above program will generate a syntax error. Here we did not use the correct syntax for if..else statements.
The correct syntax is given below,
The curly braces "{ }" are mandatory with the "if..else" statement.
Answer Program 2:
Output:
Explanation:
The above program will generate a syntax error. Here we used integer value 1 in the "if" condition. The "if" condition accepts only a Boolean value.
Answer Program 3:
Output:
Explanation:
In the above program, we created a variable num of type float32, which was initialized with 6.34. Then we converted the variable num from float32 to integer using the int() function and checked the condition to find out the resulted number is Even number or Odd number.
Answer Program 4:
Output:
Explanation:
In the above program, we created a variable num of type int. Then we read the value of variable num from the user using fmt.Scanln() function. After that, we checked the condition to find out the entered number is even or odd.
Answer Program 5:
Output:
Explanation:
In the above program, we created a variable num, which was initialized with the value returned by fmt.Print() function. The fmt.Print("Hello World") printed "Hello World" and returned 11, which was assigned to num. Then we checked the condition for EVEN or not and print the appropriate message.
need an explanation for this answer? contact us directly to get an explanation for this answer