Since there was a C language lecture in the second half of the year, I will summarize the code I wrote there. This is the teaching material used. Basic programming in C language
MacBook Pro(Retina, 13-inch, Late 2013) Xcode Version 10.2.1 When I asked the professor in charge by e-mail, I started using it because I was told that it was okay.
I was thinking of displaying Hello World! At first, but I didn't. Omitted because of that. The task is basically that the outline of the program has already been created and each person thinks about the ??? part and completes it.
Omitted because it was only environment construction and operation check Windows people are TeraPad? It seems that he is using something like that.
Enter your student ID number appropriately.
#include <stdio.h>
int main()
{
int a, b, c;
a = 1;
b = 2;
c = a + b;
printf( "My student ID number%d,Student ID number of a friend%d,total%d\n", a, b, c );
return 0;
}
Execution result
My student ID number 1,Student ID number 2 of a friend,3 in total
Program ended with exit code: 0
Suddenly, I have faced a tough task for those who have no friends. Is it Akahara? I endured.
It was a lecture about operators.
python
#include <stdio.h>
int main()
{
int a = 2 ;
a += 10 ; // a = a + 10
a += 1 ; // a = a + 1
a %= 5 ; // a = a % 5
printf("%d\n", a) ;
return 0;
}
Execution result
3
Program ended with exit code: 0
python
#include <stdio.h>
#include <float.h>
int main()
{
double r = 2.0; //r is the radius
double pi = 3.14; //pi is pi
double l = 2*r*pi; //l is the circumference
printf("The circumference is%g\n", l);
return 0;
}
Execution result
The circumference is 12.56
Program ended with exit code: 0
This article is up to this point for the time being. ~~ It's not that it's a hassle to put together. ~~ I think there will be more lectures using C language in the future, so I will summarize them so that I will not forget them.
Recommended Posts