What is a c programming language.... | full tutorial c programming language

What is a c programming language.... 

c programming full tutorial, c programming full tutorial in pdf,  c programming full tutorial pdf, c programming tutorial pointk,  c programming tutorial for beginners, c programming beginner






C programming language is a middle-level language. It was developed at Bell's research lab in 1972 by Dennis Ritchie. C programming language combines the features of a low-level and high-level language. Moreover, it is a high-level programming language that lets you create moveable applications and computer code.

How to  Writing a Simple Programming Language....

(1) c hello world 
[2] c data types

(3) C constants

(4) c math operators

(5)C IF Else
(6)c for loop
(7) c while loop
(8) c function
(9) c integer array
(10)c character array
(11) c pointers
(12) c structures
(13) c input output 
(14) c type casting
(15) c recursion 
(16) C flbonacci number 


(1) c hello world 


#include<iostream.h>
#include<stdio.h>
 
int main()
{
printf("Hello World.")
}
 
 
 
Output :
Hello World






[2] c data types



#include<iostream.h>
#include <stdio.h>
int main()
{
int num=15;
printf("%d" , num);
printf("\n");
float f1= 12.5;
printf("%f" , f1);
printf("\n");
 
char ch= 'z';
printf("%s" , ch);
printf("\n");
 
char name[] = "John";
printf("%s" , name);
printf("\n");
}
 
 
Output :
15
12.5000
z
John



(3) C constants


#include<iostream.h>
#include <stdio.h>
#define QUANTITY 10
#define PRICE 5
int main()
{
int Amount = QUANTITY * PRICE;
printf("Amount : %d" , Amount);
}
 
 
Output :
Amount : 50





(4) c math operators



#include<iostream.h>
#include <stdio.h>
 
int main()
{
 int num1 = 15;
int num2 = 7;
 
int sum = num1 + num2;
int difference = num1 - num2;
int product = num1 * num2;
int quotient = num1 / num2;
int remainder = 15 % 7;
 
printf("Sum : %d\n" , sum);
printf("Product : %d\n" , product);
printf("Difference : %d\n " , difference);
printf("Quotient : %d\n" , quotient);
printf("Remainder : %d\n" , remainder);
}
 
 
 
Output:
Sum : 22
Product  : 105
Difference : 8
Quotient : 2
Remainder : 1
 
 
}


(5)C IF Else


#include<iostream.h>
#include <stdio.h>
 
int main()
{
 int x = 15;
if ( x==15)
{
printf("X is equal to 15");
}
else if (x==10)
{
printf("X is equal to 10");
}
else
{
printf("X : %d", x);
}
}
 
 
 
Output:
X is equal to 15
 
 



(6)c for loop


#include<iostream.h>
#include <stdio.h>
 
int main()
{
int i;
for ( i=1; i<=6; i++)
{
printf("%d \n" , i);
}
}
 
 
 
Output :
1
2
3
4
5
6



(7) c while loop


#include<iostream.h>
#include <stdio.h>
 
int main()
{
int i = 1;
while ( i<=6)
{
printf("%d \n" , i);
i++;
}
}
 
 
 
Output :
1
2
3
4
5
6


(8) c function


#include<iostream.h>
#include <stdio.h>
 
int sumValue(int a, int b)
{
int sum = a + b;
return sum;
}
void printName(char name[])
{
printf("Name : %s", name);
}
 
int main()
{
int sum = sumValue(10, 8);
printf("Sum : %d", sum);
printf("\n");
 
char name[50] = "xyz ABC";
printName(name);
}
 
 
 
Output :
Sum : 18
Name : xyz ABC


(9) c integer array

#include<iostream.h>
#include <stdio.h>
 
int main()
{
int arr[4] = {11, 12, 13, 14};
int i = 0;
for (i = 0); i<=4; i++)
{
printf("%d \n", arr[i]);
}
 
 }
 
 
 
Output :
 
11
12
13
14



(10)c character array

#include<iostream.h>
#include <stdio.h>
 
int main()
{
char char_array[] = {'W' , 'e' , 'l' , 'c' , 'o' , 'm' , 'e' };
int i;
for(i = 0; i < 7; i++)
{
printf("%c" , char_array[i]);
}
printf("\n");
 
char name[50] = "ABC BCD";
printf("%s" , name);
printf("\n");
 }
 
 
 
Output :
Welcome
ABC BCD




(11) c pointers


#include<iostream.h>
#include <stdio.h>
 
int main()
{
// integer variable declaration.
int num = 12;
// pointer variable declaration.
int* p= &num;
//value of num
printf("Value : %d", *p);
printf("\n");
//memory address of num
printf("Memory Address : %d", p);
 }
 
 
 
Output :
Value : 12
Memory Address : 2686728
 




(12) c structures


#include<iostream.h>
#include <stdio.h>
 
struct Person {
int id:
int age;
char name[50];
} ;
 
int main()
{
struct Person person;
person.id = 10;
person.age = 30;
strcpy(person.name, "John");
 
printf("ID : % \n", person.id);
printf("Age : %d \n", person.age);
printf("Name : %s \n", person.name);
}
 
 
 
Output :
ID : 10
Age : 30
Name : John
 




(13) c input output 


#include<iostream.h>
#include <stdio.h>
 
struct Person {
int id:
int age;
char name[50];
} ;
int main()
{
struct Person person;
person.id = 10;
person.age = 30;
strcpy(person.name, "John");
 
printf("ID : % \n", person.id);
printf("Age : %d \n", person.age);
printf("Name : %s \n", person.name);
}
 
 
 
Output :
ID : 10
Age : 30
Name : John



(14) c type casting


#include<iostream.h>
#include <stdio.h>
 
int main()
{
int num1 = 10;
int num2 = 7;
int res_integer = num1/num2;
float res_float = (float) num1/num2;
 
printf("res_integer : %d \n", res_integer);
printf("res_float : %f \n", res_float);
 
int charValu = 'a';
//ASCII value of 'a'
printf("charValue  : %d", charValue);
}
 
 
 
Output :
res_integer : 1
res_float : 1.714286
charValue : 97
 




(15) c recursion 


#include<iostream.h>
#include <stdio.h>
 
int main()
{
int num1 = 10;
int num2 = 7;
int res_integer = num1/num2;
float res_float = (float) num1/num2;
 
printf("res_integer : %d \n", res_integer);
printf("res_float : %f \n", res_float);
 
int charValu = 'a';
//ASCII value of 'a'
printf("charValue  : %d", charValue);
}
 
 
 
Output :
res_integer : 1
res_float : 1.714286
charValue : 97
 


(16) C flbonacci number 


#include<iostream.h>
#include <stdio.h>
 
int fibonacci_Number(int n)
{
if (n==0)
{
return 0 ;
}
if ( n==1 )
{
return 1;
}
return fibonacci_number( n - 1 ) + fibonacci_number ( n-2 );
}
 
int main()
{
int i;
for ( i = 1; i <=10; i++)
{
printf("%d \n", fibonacci_number(i));
}
 }
 
 
 
Output :
 1
1
2
3
5
8
13
21
34
55


Post a Comment

0 Comments