C C++ program to print complete ASCII table

C C++ program to print complete ASCII table

विभिन्न प्रकार के Computer Coding Systems जैसे—BCD, ASCII, EBCDIC आदि के बारे में अधिक जानने के लिए देखें—Computer Coding Systems

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C++ Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C++

C program to print complete ASCII table

#include<stdio.h>
int main()
{
    int num=0;
    while(num<=255)
    {
        printf("%d = %c\t",num,num);
        num++;
    }
    return 0;
}

C++ program to print complete ASCII table

#include<iostream>
using namespace std;
int main()
{
    int num=0;
    char ch;
    while(num<=255)
    {
        ch=num;
        cout<<num<<" = "<<ch<<"\t";
        num++;
    }
    return 0;
}

Output of C C++ program to print complete ASCII table

C C++ program to print complete ASCII table

ASCII table related other C C++ programs

  1. Find ASCII values of a character
  2. Convert lowercase to uppercase
  3. Convert uppercase to lowercase
Share it to:

Example program for pointer to function in C C++

Example program for pointer to function in C C++

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

C Language में Array और इसके विभिन्न प्रकारो के बारे में और अधिक जानने के लिए देखें— Arrays in C

Example program for pointer to function in C

#include<stdio.h>
void sum(int x,int y);
int main()
{
    int a=0,b=0;
    void (*ptr) (int,int);
    ptr=sum;
    printf("Enter a b: ");
    scanf("%d%d",&a,&b);
    ptr(a,b);
    return 0;
}
void sum(int x,int y)
{
    printf("a = %d\n",x);
    printf("b = %d\n",y);
    printf("Sum = %d\n",x+y);
}

Example program for pointer to function in C++

#include<iostream>
using namespace std;
void sum(int x,int y);
int main()
{
    int a=0,b=0;
    void (*ptr) (int,int);
    ptr=sum;
    cout<<"Enter a b: ";
    cin>>a>>b;
    ptr(a,b);
    return 0;
}
void sum(int x,int y)
{
    cout<<"a = "<<x<<endl;
    cout<<"b = "<<y<<endl;
    cout<<"Sum = "<<x+y<<endl;
}

Output of Example program for pointer to function in C C++

Example program for pointer to function in C C++

Other important function based programs in C C++

  1. Sum of two numbers using function
  2. Average of three numbers using function
  3. Swapping using function call by value
  4. Swapping using function call by reference
  5. Passing array as function argument
  6. Passing structure as function argument
Share it to:

Example program for string and pointer in C C++

Example program for string and pointer in C C++

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C में Pointer और String एक दूसरे से कैसे संबंधित होते है और एक साथ कैसे प्रयोग में लाए जाते है जानने के लिए देखें—  Pointer and String

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

Example program for string and pointer in C

#include<stdio.h>
int main()
{
    char s1[20]="icomputernotes";
    char s2[20];
    char *p1="icomputernotes";
    char *p2;
    puts(s1);
    puts(p1);
    p2=p1;
    //s2=s1 will generate error
    puts(p2);
    p2="icomputernotes";
    //p2="icomputernotes" will generate error
    puts(p2);
    return 0;
}

Example program for string and pointer in C++

#include<iostream>
using namespace std;
int main()
{
    char s1[20]="icomputernotes";
    char s2[20];
    char *p1="icomputernotes";
    char *p2;
    cout<<s1<<endl;
    cout<<p1<<endl;
    p2=p1;
    //s2=s1 will generate error
    cout<<p2<<endl;
    p2="icomputernotes";
    //p2="icomputernotes" will generate error
    cout<<p2<<endl;
    return 0;
}

Output of Example program for string and pointer in C C++

Example program for string and pointer in C C++

Other important string programs in C C++

  1. String input-output without space
  2. String input-output with space
  3. Strlwr() function example program
  4. Strupr() function example program
  5. Strlen() function example program
  6. Strrev() function example program
  7. Strcpy() function example program
  8. Strcat() function example program
  9. Strcmp() function example program
Share it to:

Example program passing structure as function argument C C++

Example program passing structure as function argument C C++

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

C Language में उपलब्ध विभिन्न प्रकार के Pointers और उनके उपयोग को जानने के लिए देखें—Types of Pointer in C

C के विभिन्न control statements को जानने के लिए देखें— Control statements in C

Example program passing structure as function argument C

#include<stdio.h>
struct student
{
    char grade;
    int marks;
    float per;
};
void display(struct student);
int main()
{
    struct student s;
    printf("Enter grade  : ");
    scanf("%c",&s.grade);
    printf("Enter marks  : ");
    scanf("%d",&s.marks);
    printf("Enter Percent: ");
    scanf("%f",&s.per);
    display(s);
    return 0;
}
void display(struct student s)
{
    printf("Grade  = %c\n",s.grade);
    printf("Marks  = %d\n",s.marks);
    printf("Percent= %f\n",s.per);
}

Example program passing structure as function argument C++

#include<iostream>
using namespace std;
struct student
{
    char grade;
    int marks;
    float per;
};
void display(struct student);
int main()
{
    struct student s;
    cout<<"Enter grade  :  ";
    cin>>s.grade;
    cout<<"Enter marks  :  ";
    cin>>s.marks;
    cout<<"Enter percent:  ";
    cin>>s.per;
    display(s);
    return 0;
}
void display(struct student s)
{
    cout<<"Grade    = "<<s.grade<<endl;
    cout<<"Marks    = "<<s.marks<<endl;
    cout<<"Percent  = "<<s.per<<endl;
}

Output of Example program passing structure as function argument C C++

Similar C C++ function example programs

  1. Sum of two numbers using function
  2. Average of three numbers using function
  3. Swapping using function call by value
  4. Swapping using function call by reference
  5. Passing array as function argument
  6. Pointer to Function
Share it to:

Example program passing array as function argument in C C++

Example program passing array as function argument in C C++

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

C में फाईल क्या होता है इसे क्यो बनाया जाता है यह कितने प्रकार का होता है जानने के लिए देखें—Introduction to File

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

Example program passing array as function argument in C

#include<stdio.h>
void display(int[],int);
int main()
{
    int a[5],i=0;
    printf("Enter values: ");
    for(i=0;i<5;i++)
    scanf("%d",&a[i]);
    display(a,5);
    return 0;
}
void display(int a[], int n)
{
    int i=0,sum=0;
    for(i=0;i<n;i++)
    {
        printf("Element = %d\n",a[i]);
        sum=sum+a[i];
    }
    printf("Sum = %d",sum);
}

Example program passing array as function argument in C++

#include<iostream>
using namespace std;
void display(int[],int);
int main()
{
    int a[5],i=0;
    cout<<"Enter values: ";
    for(i=0;i<5;i++)
    cin>>a[i];
    display(a,5);
    return 0;
}
void display(int a[], int n)
{
    int i=0,sum=0;
    for(i=0;i<n;i++)
    {
        cout<<"Element = "<<a[i]<<endl;
        sum=sum+a[i];
    }
    cout<<"Sum = "<<sum;
}

Output of Example program passing array as function argument in C C++

Example program for passing array as function argument in C

Other function based example programs in C C++

  1. Sum of two numbers using function
  2. Average of three numbers using function
  3. Swapping using function call by value
  4. Swapping using function call by reference
  5. Passing structure as function argument
  6. Pointer to Function
Share it to:

C C++ program to differentiate between structure and union

C C++ program to differentiate between structure and union

Function क्या है इसका प्रयोग क्यो किया जाता है यह कितने प्रकार का होता है जानने के लिए देखें—Functions in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C Language में Union क्या होता है और यह Structure से किस तरह भिन्न है जानने के लिए देखें—Unions in C

C program to differentiate between structure and union

#include<stdio.h>

struct s
{
    char c;
    int i;
    float f;
}sv;

union u
{
    char c;
    int i;
    float f;
}uv;

int main()
{
    printf("Size of sv = %d\n",sizeof(sv));
    printf("Size of uv = %d\n",sizeof(uv));
    printf("Addresses of sv = %u %u %u\n",&sv.c,&sv.i,&sv.f);
    printf("Addresses of uv = %u %u %u\n",&uv.c,&uv.i,&uv.f);
    return 0;
}

C++ program to differentiate between structure and union

#include<iostream>
using namespace std;

struct s
{
    char c;
    int i;
    float f;
}sv;

union u
{
    char c;
    int i;
    float f;
}uv;

int main()
{
    cout<<"Size of sv = "<<sizeof(sv)<<endl;
    cout<<"Size of uv = "<<sizeof(uv)<<endl;
    cout<<"Addresses of sv = "<<&sv.c<<" "<<&sv.i<<" "<<&sv.f<<endl;
    cout<<"Addresses of uv = "<<&uv.c<<" "<<&uv.i<<" "<<&uv.f<<endl;
    return 0;
}

Output of C C++ program to differentiate between structure and union

C C++ program to differentiate between structure and union

Other union programs in C C++

  1. Declaration and initialization of union
  2. Declaration and initialization of structure
  3. Array of structure
  4. Pointer to structure
Share it to:

Pointer to structure example program in C C++

Pointer to structure example program in C C++

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C Language में Structure क्या होता है और इसका प्रयोग क्यो किया जाता है जानने के लिए देखें—Structures in C

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

Pointer to structure example program in C

#include<stdio.h>

struct student
{
    char grade;
    int marks;
    float percent;
};

int main()
{
    struct student std;
    struct student *ptr;
    ptr=&std;
    printf("Enter Grade   : ");
    scanf("%c",&std.grade);
    printf("Enter Marks   : ");
    scanf("%d",&std.marks);
    printf("Enter Percent : ");
    scanf("%f",&std.percent);
    printf("The Grade is  : %c",ptr->grade);
    printf("\nThe Marks is  : %d",ptr->marks);
    printf("\nThe Percent is: %f",ptr->percent);
    return 0;
}

Pointer to structure example program in C++

#include<iostream>
using namespace std;

struct student
{
    char grade;
    int marks;
    float percent;
};

int main()
{
    struct student std;
    struct student *ptr;
    ptr=&std;
    cout<<"Enter Grade    : ";
    cin>>std.grade;
    cout<<"Enter Marks    : ";
    cin>>std.marks;
    cout<<"Enter Percent  : ";
    cin>>std.percent;
    cout<<"The Grade is   : "<<ptr->grade<<endl;
    cout<<"The Marks is   : "<<ptr->marks<<endl;
    cout<<"The Percent is : "<<ptr->percent<<endl;
    return 0;
}

Output of Pointer to structure example program in C C++

Pointer to structure example program in C C++

Related structure example programs in C C++

  1. Declaration and initialization of structure
  2. Array of structure
Share it to:

Pointer to array example program in C C++

Pointer to array example program in C C++

C Language में Array और इसके विभिन्न प्रकारो के बारे में और अधिक जानने के लिए देखें— Arrays in C

Pointer to array क्या होता है जानने के लिए देखें—Pointer to array in C

C Language में Pointer to Pointer क्या होता है जानने के लिए देखें— Pointer to pointer in C

Pointer to array example program in C

#include<stdio.h>
int main()
{
    int arr[5]={3,9,1,4,8},i;
    int *ptr;
    ptr=&arr[0];
    for(i=0;i<5;i++)
    {
        printf("Element = %d Address = %u\n",*ptr,ptr);
        ptr++;
    }
    return 0;
}

Pointer to array example program in C++

#include<iostream>
using namespace std;
int main()
{
    int arr[5]={3,9,1,4,8},i;
    int *ptr;
    ptr=&arr[0];
    for(i=0;i<5;i++)
    {
        cout<<"Element = "<<*ptr<<"Address = "<<ptr<<endl;
        ptr++;
    }
    return 0;
}

Output of Pointer to array example program in C C++

Pointer to array example program in C C++

More example programs of array in C C++

  1. Declaration and initialization of array
  2. Input-output in array
  3. Sum and average of array elements
  4. Largest Element in Array
  5. Smallest element in Array
  6. Reverse Elements of Array
  7. Merging two arrays
  8. Searching in array (Linear search)
  9. Sorting in array (Selection sort)
Share it to:

Pointer arithmetic example programs in C C++

Pointer arithmetic example programs in C C++

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

C Language में Pointer to Pointer क्या होता है जानने के लिए देखें— Pointer to pointer in C

C Language में उपलब्ध विभिन्न प्रकार के Pointers और उनके उपयोग को जानने के लिए देखें—Types of Pointer in C

Incrementing pointer in C example program

#include<stdio.h>
int main()
{
    int num, *ptr;
    ptr=#
    printf("value of ptr = %u\n",ptr);
    ptr=ptr+1;
    printf("value of ptr = %u\n",ptr);
    ptr=ptr+1;
    printf("value of ptr = %u\n",ptr);
    return 0;
}

Incrementing pointer in C++ example program

#include<iostream>
using namespace std;
int main()
{
    int num, *ptr;
    ptr=#
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr+1;
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr+1;
    cout<<"value of ptr = "<<ptr<<endl;
    return 0;
}

Output of incrementing pointer in C C++ example program

Pointer Arithmetic Incrementing Programs in C C++

Decrementing pointer in C example program

#include<stdio.h>
int main()
{
    int num, *ptr;
    ptr=#
    printf("value of ptr = %u\n",ptr);
    ptr=ptr-1;
    printf("value of ptr = %u\n",ptr);
    ptr=ptr-1;
    printf("value of ptr = %u\n",ptr);
    return 0;
}

Decrementing pointer in C++ example program

#include<iostream>
using namespace std;
int main()
{
    int num, *ptr;
    ptr=#
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr-1;
    cout<<"value of ptr = "<<ptr<<endl;
    ptr=ptr-1;
    cout<<"value of ptr = "<<ptr<<endl;
    return 0;
}

Output of decrementing pointer in C C++ example program

Pointer Arithmetic Decrementing Programs in C C++

Related pointer programs in C C++

  1. Declaration and assignment of pointer
  2. Pointer to pointer
  3. Sum of two numbers using pointer
  4. Average of three numbers using pointer
  5. Swapping two variables using pointer
Share it to:

C C++ program to generate fibonacci series using recursion

C C++ program to generate fibonacci series using recursion

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

C में फाईल क्या होता है इसे क्यो बनाया जाता है यह कितने प्रकार का होता है जानने के लिए देखें—Introduction to File

C program to generate fibonacci series using recursion

#include<stdio.h>
int fab(int);
int main()
{
    int n, i;
    printf("Enter n: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    printf("%d\n",fab(i));
    return 0;
}
int fab(int x)
{
    if(x==1)
        return 0;
    else if(x==2)
        return 1;
    else
        return fab(x-1)+fab(x-2);
}

C++ program to generate fibonacci series using recursion

#include<iostream>
using namespace std;
int fab(int);
int main()
{
    int n, i;
    cout<<"Enter n: ";
    cin>>n;
    for(i=1;i<=n;i++)
    cout<<fab(i)<<endl;
    return 0;
}
int fab(int x)
{
    if(x==1)
        return 0;
    else if(x==2)
        return 1;
    else
        return fab(x-1)+fab(x-2);
}

Output of C C++ program to generate fibonacci series using recursion

C C++ program to generate fibonacci series using recursion

Other programs on recursion in C C++

  1. Series of natural numbers
  2. Table of number
  3. Factorial of number
  4. Power of number
Share it to: