Search
 
SCRIPT & CODE EXAMPLE
 

C

square in c

#include <math.h>
int main()
{
	float number;
  	square = pow(number,2); //This returns number raised to the power 2
  	printf("The square of %f is %f", number, square);
  	return 0;
}
Comment

square in c

#include <stdio.h>
int main()
{
	float number;
	printf("Enter a number: ");
	scanf("%f", &number);
	square = number * number;
	printf("square of the given number %f is %f", number, square);
	return 0;
}
Comment

sqrt function in c

Are you beginner in problem solving?
Let's Solve 200 Beginner level problems with explanation video:
https://cutt.ly/200-Problems-interactive-coding-pdf

#include <stdio.h>
#include <math.h>
void main(){
    int num, result;
    printf("Enter a number: ");
    scanf("%d",&num);
    
    result = sqrt(num);

    printf("Square root of %d = %d",num,result);
}
Comment

Sqrt() function implementation in C

ubuntu@ip-172-31-63-244:~/julien$ l
total 44
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 25 02:47 .
drwxrwxr-x 19 ubuntu ubuntu 4096 Mar 25 02:44 ..
-rw-rw-r-- 1 ubuntu ubuntu 89 Mar 25 02:44 0-print_z.c
-rw-rw-r-- 1 ubuntu ubuntu 132 Mar 25 02:44 1-print_alphabet.c
-rw-rw-r-- 1 ubuntu ubuntu 132 Mar 25 02:44 2-print_tebahpla.c
-rw-rw-r-- 1 ubuntu ubuntu 166 Mar 25 02:44 3-print_base16.c
-rw-rw-r-- 1 ubuntu ubuntu 162 Mar 25 02:44 4-positive_or_not.c
-rw-rw-r-- 1 ubuntu ubuntu 636 Mar 25 02:44 5-print_number.c
-rw-rw-r-- 1 ubuntu ubuntu 178 Mar 25 02:47 my_functions.h
-rw-rw-r-- 1 ubuntu ubuntu 76 Mar 25 02:44 print_char.c
-rw-rw-r-- 1 ubuntu ubuntu 1392 Mar 25 02:46 print_char.o
ubuntu@ip-172-31-63-244:~/julien$ gcc -Wall -pedantic -Werror -Wextra -std=gnu89 -c *.c
ubuntu@ip-172-31-63-244:~/julien$ l
total 68
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 25 02:47 .
drwxrwxr-x 19 ubuntu ubuntu 4096 Mar 25 02:44 ..
-rw-rw-r-- 1 ubuntu ubuntu 89 Mar 25 02:44 0-print_z.c
-rw-rw-r-- 1 ubuntu ubuntu 1400 Mar 25 02:47 0-print_z.o
-rw-rw-r-- 1 ubuntu ubuntu 132 Mar 25 02:44 1-print_alphabet.c
-rw-rw-r-- 1 ubuntu ubuntu 1408 Mar 25 02:47 1-print_alphabet.o
-rw-rw-r-- 1 ubuntu ubuntu 132 Mar 25 02:44 2-print_tebahpla.c
-rw-rw-r-- 1 ubuntu ubuntu 1408 Mar 25 02:47 2-print_tebahpla.o
-rw-rw-r-- 1 ubuntu ubuntu 166 Mar 25 02:44 3-print_base16.c
-rw-rw-r-- 1 ubuntu ubuntu 1464 Mar 25 02:47 3-print_base16.o
-rw-rw-r-- 1 ubuntu ubuntu 162 Mar 25 02:44 4-positive_or_not.c
-rw-rw-r-- 1 ubuntu ubuntu 1472 Mar 25 02:47 4-positive_or_not.o
-rw-rw-r-- 1 ubuntu ubuntu 636 Mar 25 02:44 5-print_number.c
-rw-rw-r-- 1 ubuntu ubuntu 2048 Mar 25 02:47 5-print_number.o
-rw-rw-r-- 1 ubuntu ubuntu 178 Mar 25 02:47 my_functions.h
-rw-rw-r-- 1 ubuntu ubuntu 76 Mar 25 02:44 print_char.c
-rw-rw-r-- 1 ubuntu ubuntu 1392 Mar 25 02:47 print_char.o
ubuntu@ip-172-31-63-244:~/julien$ ar -rc libschool.a *.o
ubuntu@ip-172-31-63-244:~/julien$ ar -t libschool.a
0-print_z.o
1-print_alphabet.o
2-print_tebahpla.o
3-print_base16.o
4-positive_or_not.o
5-print_number.o
print_char.o
ubuntu@ip-172-31-63-244:~/julien$ ranlib libschool.a
ubuntu@ip-172-31-63-244:~/julien$ cat main.c
void print_alphabet(void);

int main(void)
{
        print_alphabet();
        return (0);
}
ubuntu@ip-172-31-63-244:~/julien$ gcc main.c
/tmp/ccQa2r6L.o: In function `main':
main.c:(.text+0x5): undefined reference to `print_alphabet'
collect2: error: ld returned 1 exit status
ubuntu@ip-172-31-63-244:~/julien$ gcc main.c -L. -lschool -o alpha
ubuntu@ip-172-31-63-244:~/julien$ ./alpha
abcdefghijklmnopqrstuvwxyzubuntu
ubuntu@ip-172-31-63-244:~/julien$
Comment

PREVIOUS NEXT
Code Example
C :: strstr 
C :: vifm preview images 
C :: gitlab ci heroku 
C :: read from command line c 
C :: get boolean from localstorage 
C :: while loop c 
C :: script in c 
C :: oracle trunc 
C :: c function definition 
C :: boolean operators in c 
C :: how to input a string into a char array cpp 
C :: convert python to c 
C :: len of str vbs 
C :: android studio sdkmanager always accept 
C :: program in c to print 1 to 100 without using loop 
C :: print char* address C 
C :: remove language from jupyter notebook 
C :: how to link flexslider 
C :: arrow keys gaming keyboard 
C :: remove every appearance of char without malloc in c 
C :: check if string is number c 
C :: gtk widget change window title 
C :: counting 7s in an integer c 
C :: analog clock c code for turbo 
C :: how to add a number before every line in c language 
C :: opération bit à bit c 
C :: time to apply pmfby 
C :: gcc comand for running hello.c 
C :: hello world in c language 
C :: install zoom on ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =