Learn #C With Hamza
C Instructional exercise - Learn C Programming with models
By Mahar Hamza
Learning C writing computer programs is simple assuming you follow the instructional exercises in the provided request and practice C projects en route. This C instructional exercise is intended for amateurs so you won't confront any trouble regardless of whether you have no earlier information in C language.
C is a broadly useful PC programming language. A broadly useful language is a language that is generally utilized in different spaces and not well defined for a specific space. C programming language was made in 1972 by Dennis Ritchie at AT&T ringer research facilities in U.S.A.
Prologue to C
C is an exceptionally well known programming language in view of the highlights it offers. Here are a portion of the highlights of C programming language.
1. Basic
C language is basic and simple to learn.
2. Compact
C is a machine free language, and that implies a C program thought of one machine can run on one more machine without requiring a code change.
3. Quick
C is a compiler based language and it upholds just valuable highlights which makes the gathering of C document quick.
4. Extensible
C program upholds code alterations and expansion of new code to the generally existing projects, this makes C language extensible. It becomes simpler to add new functionalities to the current C projects.
5. Mid level programming language
C language gives the advantages of significant level and low-level dialects both. C permits control of equipment very much like low level language and permits high client end functionalities like significant level dialects.
6. Download mingwCompiler From Here
A basic C Program 01
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
Out Put Of This Program =>>
Hello World!
Program #02 (If Else Conditions In #C)
#include <stdio.h>
int main() {
int myNum = 10;
if (myNum > 0)
printf("The value is a positive number.");
else if (myNum < 0)
printf("The value is a negative number.");
else
printf("The value is 0.");
return 0;
}
Program #03 (Switch Statement In #C)
#include <stdio.h>
int main() {
int day = 4;
switch (day) {
case 6:
printf("Today is Saturday");
break;
case 7:
printf("Today is Sunday");
break;
default:
printf("Looking forward to the Weekend");
}
return 0;
}
Program #04 (While Loop In #C)
#include <stdio.h>
int main() {
int i = 0;
do {
printf("%d\n", i);
i++;
}
while (i < 5);
return 0;
}
Program #05 (For Loop In #C)
#include <stdio.h>
int main() {
int i;
for (i = 0; i <= 10; i = i + 2) {
printf("%d\n", i);
}
return 0;
}
Program #06 (Break & Continue In #C)
#include <stdio.h>
int main() {
int i = 0;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
printf("%d\n", i);
i++;
}
return 0;
}
Program #07 (Operators In #C)
#include <stdio.h>
int main() {
int myInt;
float myFloat;
double myDouble;
char myChar;
printf("%lu\n", sizeof(myInt));
printf("%lu\n", sizeof(myFloat));
printf("%lu\n", sizeof(myDouble));
printf("%lu\n", sizeof(myChar));
return 0;
}
Program #08 (Memory Address In #C)
#include <stdio.h>
int main() {
int myAge = 43;
printf("%p", &myAge);
return 0;
}
Program #09 (Math functions() In #C)
SqRoot In #C
#include <stdio.h>
#include <math.h>
int main() {
printf("%f", sqrt(16));
return 0;
}
Round A Number In #C
#include <stdio.h>
#include <math.h>
int main() {
printf("%f\n", ceil(1.4));
printf("%f\n", floor(1.4));
return 0;
}
Power function() In #C
#include <stdio.h>
#include <math.h>
int main() {
printf("%f", pow(4, 3));
return 0;
}
Other Math Functions() In #C
Function Description
abs(x) Returns the absolute value of x
acos(x) Returns the arccosine of x
asin(x) Returns the arcsine of x
atan(x) Returns the arctangent of x
cbrt(x) Returns the cube root of x
cos(x) Returns the cosine of x
exp(x) Returns the value of Ex
sin(x) Returns the sine of x (x is in radians)
tan(x) Returns the tangent of an angle
Download Source-Codes Here
Build Your Website