-->
Showing posts with label C program. Show all posts
Showing posts with label C program. Show all posts

Friday, July 11, 2025

c program to initialize a string with examples

 

 string programs in C

 // program to initialize a string in C


#include <stdio.h>

#include<string.h>

void main ()

{

char string[] = {'c', 'o', 'm', 'p', 'u', 't', 'e', 'r'};

printf("%s", string);

getch();

}


output:-




Friday, July 4, 2025

c program to reverse a string using function and pointer | pointer examples in c | program with pointer to character function

 

Pointer and string programs in C

 // program to reverse a string using function where we use pointer to character


//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse

#include <stdio.h>

#include<string.h>

#include<conio.h>

char *stringrev(char string[]);

/* function named stringrev() that accepts a string and returns

a char(i.e. pointer to character/string)

int main()

{

    char name[100];//string declaration

    printf("enter string\n");

    scanf("%[^\n]",name); 

    printf("reverse=%s\n",stringrev(name));//prints the name

    getch();

    return 0;

}

char *stringrev(char string[])

{

    strrev(string);

    return string;

}

Sunday, May 18, 2025

C Program – 1D Array Input and Output with Simple Examples

array input in C program 


// 1Dimensional (1D) array input


#include<stdio.h>
int main()
{
int a[5];//array declaration of size 5
int i;
for(i=0;i<=4;i++)//loop
{
printf(" enter value for location=%d\n",i+1);//message display
scanf("%d",&a[i]);//input
}
for(i=0;i<=4;i++)
{
printf("%d\t",a[i]);//printing the values
}
return 0;
}


Output:-




Sunday, July 18, 2021

Learning C program step by step


Table of Contents

1. Introduction to C


2. Basic Concepts

   2.3 Constants and literals
   2.4 Operators and expressions
   2.5 Control flow statements
   2.6 Functions and recursion

3. Arrays and Pointers

   3.1 Arrays and their declaration
   3.2 Accessing array elements
   3.3 Multidimensional arrays
   3.4 Pointers and their importance
   3.5 Pointer arithmetic
   3.6 Arrays vs. Pointers

4. Input and Output

   4.1 Standard Input and Output
   4.2 Formatted Input and Output
   4.3 File Input and Output
   4.4 Error handling and file operations

5. Structures and Unions

   5.1 Structure declaration and initialization
   5.2 Accessing structure members
   5.3 Nested structures
   5.4 Unions and their usage

6. Dynamic Memory Allocation

   6.1 Memory management in C
   6.2 Dynamic memory allocation functions
   6.3 Memory deallocation

7. File Handling

   7.1 File handling concepts
   7.2 Opening and closing files
   7.3 Reading and writing files
   7.4 File positioning and error handling

8. Advanced Concepts

   8.1 Preprocessor directives
   8.2 Bitwise operators and manipulation
   8.3 Enumerations
   8.4 Typedef and type casting
   8.5 Function pointers
   8.6 Recursion and its applications

9. C Standard Library

   9.1 Standard Library functions
   9.2 String manipulation functions
   9.3 Mathematical functions
   9.4 Input and output functions
   9.5 Memory management functions

10. Debugging and Troubleshooting

    10.1 Debugging techniques
    10.2 Common errors and their solutions
    10.3 Compiler warnings and debugging tools

11. Advanced Topics

    11.1 Data structures in C
    11.2 File handling with binary data
    11.3 Interfacing with other languages
    11.4 Multithreading and concurrency

12. Best Practices and Coding Guidelines

    12.1 Writing clean and maintainable code
    12.2 Code documentation and commenting
    12.3 Testing and debugging strategies
    12.4 Performance optimization techniques