Question

GO Programming Write Go package that imports all the libraries. please include variable, pointer anf fucntion...

GO Programming

Write Go package that imports all the libraries. please include variable, pointer anf fucntion the code doesn't have to something major. Something that can run some of the Go labraries.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

package main

import (
"fmt"
"math"
)

//swap function which interchange paramter values
func swap(a *int,b *int){
var temp int
temp = *a
*a = *b
*b = temp
}

func main() {
//varaibles declared and initialised
var num1, num2 int = 100,50
//displays variable values
fmt.Printf("\n num1 : %d", num1)
fmt.Printf("\n num2 : %d ",num2)
//using math library functions
result := math.Max(float64(num1),float64(num2))
fmt.Print("\n Sum of two numbers : ",result)
result = math.Sqrt(float64(num1))
fmt.Print("\n Square Root of ",num1," is ",result)
fmt.Print("\n Before Swapping :")
fmt.Printf("\n num1 = %d",num1)
fmt.Printf("\n num2 = %d",num2)
//interchange values using call by reference
swap(&num1,&num2)
fmt.Print("\n After Swapping :")
fmt.Printf("\n num1 = %d",num1)
fmt.Printf("\n num2 = %d",num2)

}

OUTPUT:

I.lI Result $go run main.go numi : 100 num2:5e Sum of two numbers 1ee Square Root of 1eeis 1e Before Swapping: num25e After Swapping:

Add a comment
Know the answer?
Add Answer to:
GO Programming Write Go package that imports all the libraries. please include variable, pointer anf fucntion...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C Programming For this task, you will have to write a program that will prompt the...

    C Programming For this task, you will have to write a program that will prompt the user for a number N. Then, you will have to prompt the user for N numbers, and print then print the sum of the numbers. For this task, you have to create and use a function with the following signature: int sum(int* arr, int n); Your code should look something like this (you can start with this as a template: int sum(int* arr, int...

  • C Programming QUESTION 2 Which of the following statements about pointer arguments are true? Select all...

    C Programming QUESTION 2 Which of the following statements about pointer arguments are true? Select all choices you believe are correct--this question may have more than one correct answer! A. The * operator allows you to access the address of an existing variable, while the & operator allows you to dereference a pointer and access the data to which it points. B. A function with pointer arguments must have the void return type. C. Pointer arguments allow you to write...

  • ***PLEASE HELP!!!*** PLEASE READ INSTRUCTIONS CAREFULLY ANF PLEASE THOROUGHLY COMPLETE. Will reward full points! PROGRAMMING LANGUAGE:...

    ***PLEASE HELP!!!*** PLEASE READ INSTRUCTIONS CAREFULLY ANF PLEASE THOROUGHLY COMPLETE. Will reward full points! PROGRAMMING LANGUAGE: JAVA Thank you in advance. Summary Now for something a little different In a hypothetical world, a new mobile game emerges where players "collect" digital characters called "Digit The players start out with a selection of Digitoids oids (specific to the region of world they began at) from which they choose one to be their first Digitoid However, players can also visit famous landmarks...

  • please help with the marked ones the programming language is python code. 23.16 Write an RGB...

    please help with the marked ones the programming language is python code. 23.16 Write an RGB class that represents an RGB color. Store the red, green. and blue components. Include a _str_0 method and a luminance method that returns the luminance of the color. Write a main() function to test your code. 23.17 Write a CD class that represents a single music cd. Store the artist, title, genre, year of release, and playing time in minutes and seconds. However, instead...

  • (Java with Netbeans) Programming. Please show modified programming code for already given Main class, and programming...

    (Java with Netbeans) Programming. Please show modified programming code for already given Main class, and programming for code for the new GameChanger class. // the code for Main class for step number 6 has already been given, please show modified progrraming for Main class and GameCHanger class, thank you. package .games; import java.util.Random; import java.util.Scanner; public class Main { public static void main(String args[]) { System.out.println("Welcome to the Number Guessing Game"); System.out.println(); Scanner sc = new Scanner(System.in); // Get upper...

  • please help! Write a program that can be used as a math tutor for a young...

    please help! Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added. The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution. The output must be formatted correctly with the numbers aligned properly. You will build on this assignment...

  • Python please help! Thanks you Write a code to get an unlimited number of grades from...

    Python please help! Thanks you Write a code to get an unlimited number of grades from the user (the user can press enter to finish the grades input, or use a sentinel, for example-1), and then calculate the GPA of all the grades and displays the GPA To do this you might need some help. Try to follow the following process (and check your progress by printing different values to make sure they are as they supposed to be): 1-...

  • Please help me with the following C Programming project. I am providing the code I used...

    Please help me with the following C Programming project. I am providing the code I used which needs to be reworked to add the following requirements. Here is my code #include<stdio.h> char input; int main() { int i = 0; while (true){ scanf_s("%c", &input); if (input == 'X') break; printf("%c", input); } return 0; } Here are the requirements for the code plus and additional note what the code should have. Goals Understand the ASCII representation of character values. Understand...

  • please please include all work..and please write extremely legibly and slowly so I can read every...

    please please include all work..and please write extremely legibly and slowly so I can read every step clearly and legibly.. I've been having trouble reading some of the problems I put on here...it has to written very very legibly. B. Section 9.2 Find 2. (fog)(x) b. (gºf)(x) c. (fºg)(2) f() = 7x+1, g(x) = 2x2 – 9

  • C programming. please include comments In this lab, you will learn to read data from and...

    C programming. please include comments In this lab, you will learn to read data from and write data to a file - another use for pointers. SAMPLE PROGRAM There are two sample programs this week - WriteFile.c and ReadFile.c. The first, WriteFile.c, allows the user to enter customer names (first, middle, and last), and writes each name to an output text file, customerNames.txt. formatted as: firstName middlelnitial lastName" After you've run it once, what happens to the names you added...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT