Posts

C Program to open and write to a text file using fprintf.

  C Program to  open and write to a text file using fprintf. # include <stdio.h> #include <conio.h>  # include <string.h>   void  main( ) {    FILE *fptr ;   char data[100] = “Welcome to Code Hub-A Computer Science Portal for Engineering UG and PG students";  fptr = fopen("program.c", "w") ;  if(fptr == NULL )     { printf( "program.c file failed to open." ) ;     }     else     {  printf("The file is now opened\n") ;   i f (strlen(data) > 0 )         {  fputs(data,  fptr ) ;      fputs("\n",  fptr ) ;         }     fclose( fptr ) ; printf("Data successfully written in file \n"); printf("The file is closed.") ;     }      getch();   }

C Program to open and write to a text file using fprintf.

  C Program to  open and write to a text file using fprintf. #include <stdio.h> #include <conio.h>  #include <stdlib.h>   void   main() {    int number;    FILE *fileptr; fileptr = fopen("D:\\program.txt","w");    if( fileptr == NULL)    {       printf("Error in file !");         exit(1);                } printf("Enter number: "); scanf("%d",&number); fprintf( "fileptr %d",number);    fclose( fileptr );      getch();    }  

C Program to open and write a text file.

  C Program to  open and write a text file.   #include <stdio.h> #include <conio.h>    void  main() {    FILE *fptr;  if (fp = fopen("Resume.txt", "wb")) {  printf("File opened successfully and write in binary mode .");    }    else    printf("Error!");    fclose(fptr);    getch();

C Program to shut down or turn off your machine or computer

  C Program to shut down or turn off your machine or computer #include <stdio.h> #include <stdlib.h>   int main() {    system("C:\\WINDOWS\\System32\\shutdown /s");      return 0; }

C Program to print Internet Protocol (IP) address in your machine.

  C Program to print Internet Protocol (IP) address in your machine. #include<stdio.h> #include<stdlib.h> int main() {    system("C:\\Windows\\System32\\ipconfig");        return 0; }  

C Program to print system date in your machine.

  C Program to print system date in your machine. #include <stdio.h> #include <conio.h> #include <dos.h> int main() {    struct date d;    getdate(&d);    printf("Current system date: %d/%d/%d", d.date_day, d.date_mon, d.date_year);    getch();    return 0; }  

C Program to print swap number using third variables

    C Program to print swap number using third variables   #include<stdio.h> #include <conio.h>   void main() {   int a, b, temp;   printf("Enter first number: ");   scanf("%d", &a);   printf("Enter second number: ");   scanf("%d", &b);     temp = a;     a = b;    b = temp;   printf("\nAfter swapping first number = %d\n", a);     printf("After swapping second number = %d", b);   getch(); }   Output: Enter first number: 8 Enter second number: 10 After swapping first number = 10 After swapping second number = 8   C

C Program to print size of variables

  C Program to print size of variables #include<stdio.h> #include <conio.h>   void main() {     int integer;     float float;     double double;     char character;     printf("Size of integer: %zu bytes\n", sizeof(integer));    printf("Size of float: %zu bytes\n", sizeof(float));    printf("Size of double: %zu bytes\n", sizeof(double));    printf("Size of character: %zu byte\n", sizeof(character));       getch(); } Output: Size of integer: 4 bytes Size of float: 4 bytes Size of double: 8 bytes Size of character: 1 byte  

C Program to Print Quotient and Remainder

  C Program to Print Quotient and Remainder   #include <stdio.h> #include <conio.h>   void main()  {     int a, b, quotient, remainder;      printf("Enter dividend number: ");     scanf("%d", &a);      printf("Enter divisor number: ");     scanf("%d", &b);      quotient = a / b;      remainder = a % b;      printf("Quotient is= %d\n", quotient);     printf("Remainder is= %d", remainder);      getch();

C Program to Print ASCII Value

  C Program to Print ASCII Value #include <stdio.h> #include <conio.h>   void main()  {      char a;     printf("Enter a  valid character: ");     scanf ("%c", &a);  printf("ASCII value of  valid character %c = %d", c, c);       getch(); }   Output: Enter a valid character: f ASCII value of valid character f = 102  

C Program to Print to addition, subtraction, multiply and division of two number Or C Program to make a simple or arithmetic calculator

  C Program to Print to addition, subtraction, multiply and division of two number Or C Program to make a simple or arithmetic calculator #include <stdio.h> #include <conio.h>   void main()  {        int a, b, c;      printf("Enter two number: ");     scanf("%d %d", &a, &b);      c = a + b;          c = a -  b;          c = a * b;          c = a / b;      printf("The addition is = %d", c); printf("The subtraction is = %d", c); printf("The multiplication is = %d", c); printf("The division is = %d", c);    getch(); }   Output: Enter two number:12 6 The addition is = 18 The subtraction is = 6 The multiplication is =72 The division is =2  

C Program to Print sum of two number

    #include <stdio.h> #include <conio.h>   void main()  {        int a, b, c;      printf("Enter two number: ");     scanf("%d %d", &a, &b);      c = a + b;           printf("The sum is = %d", c);      getch(); }   Output: Enter two number: 10 12 The sum is = 22

C Program to Print a number or integer

  C Program to Print a number or integer #include <stdio.h> #include <conio.h> void main() {      int n;   printf("Enter a number or integer: ");   scanf("%d", &n);   printf("You entered number or integer is: %d", n);         getch(); }   Output: Enter a number or integer: 20 You entered number or integer: 20  

Basic C Program In C programming Language

  Basic C Program In C programming Language   C Program to Print "Hello World!" #include <stdio.h> #include <conio.h> void main() {    printf ("Hello World!");     getch(); } Output:  Hello World

Latest and Most Popular Coding Section

Image