Responsive Homepage design with Bootstrap 4 and Animate css

C "Hello, World!" Program

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
    printf("Hello, World!");
    return 0;
    }
    

C Program Add Two Integers

 
 #include<stdio.h>
#include<conio.h>
int  main() 
    { 
        int number1, number2, sum;
    printf("Enter two integers: ");
    scanf("%d %d", &number1, &number2);
    // calculating sum
    sum = number1 + number2;     
    printf("%d + %d = %d", number1, number2, sum);
    return 0;

}

C Program to Compute Quotient and Remainder

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 int dividnd, divisor, quotient, remainder;
    printf("Enter dividend: ");
    scanf("%d",&dividnd);
    printf("Enter divisor: ");
    scanf("%d",&divisor);
    quotient = dividnd / divisor;
    remainder = dividnd % divisor;
    printf("Quotient = %d\n", quotient);
    printf("Remainder = %d", remainder);
    return 0;
}

C Program for volume of Cylinder

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 int radius, height;                                                         
    float volume=0, pi=3.14;                                                                   
    printf("\nEnter radius: ");                                                 
    scanf("%d", &radius);                                                                                                                           
    printf("\nEnter height: ");                                                 
    scanf("%d", &height);                                                                                                                           
    volume = pi*(radius*radius*height);                                                                                                     
    printf("Volume of a cylinder is: %.2f", volume);      
    return 0;
}

C Program for volume of Cylinder

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 int radius, height;                                                         
    float volume=0, pi=3.14;                                                                   
    printf("\nEnter radius: ");                                                 
    scanf("%d", &radius);                                                                                                                           
    printf("\nEnter height: ");                                                 
    scanf("%d", &height);                                                                                                                           
    volume = pi*(radius*radius*height);                                                                                                     
    printf("Volume of a cylinder is: %.2f", volume);      
    return 0;
}

C Program Input the marks of Three Different Subjects and find out the total & percentage.

 
#include<stdio.h>
#include<conio.h>
void  main() 
{ 
        int M1,M2,M3,Total;

           float Per;

           clrscr();

           printf("\n\n\t\t Enter the Marks of First Subject: ");

           scanf("%d",&M1);

           printf("\n Enter the Marks of Second Subject: ");

           scanf("%d",&M2);

           printf("\n\n\t\t Enter the Marks of Third Subject: ");

           scanf("%d",&M3);

           Total=M1+M2+M3;

          Per=Total/3;

 

           printf("\n\n\t\t Total Marks of Three Subject is: %d",Total);

           printf("\n\n\t\t Percentage is: %f",Per);
           getch();
} 
 

C Program to Calculate Square of a Number

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
    int number, Square;
 
  printf(" \n Please Enter any integer Value : ");
  scanf("%d", &number);
  
  Square = number * number;
  
  printf("\n Square of a given number %d is  =  %d", number, Square);
   return 0;
    }
    

C Program to Find ASCII Value of a Character

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
     char c;
    printf("Enter a character: ");
    scanf("%c", &c);  
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    
    return 0;
    }
    

C PROGRAM to Find the Size of int, float, double and char

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
    int integerType;
    char charType;
    float floatType;
    double doubleType;
    printf("Size of int is: %ld\n",sizeof(integerType));
    printf("Size of char is: %ld\n", sizeof(charType));
    printf("Size of float is: %ld\n",sizeof(floatType));
    printf("Size of double is: %ld\n",sizeof(doubleType));
    return 0;
    }
    

C PROGRAM to find the simple interest, inputs are amount, period in years and rate of interest.

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
    float principal_amt, rate, simple_interest;
    int time;
 
    printf("Enter the values of principal_amt, rate and time \n");
    scanf("%f %f %d", &principal_amt, &rate, &time);
    simple_interest = (principal_amt * rate * time) / 100.0;
    printf("Amount = Rs. %f\n", principal_amt);
    printf("Rate = Rs. %f%\n", rate);
    printf("Time = %d years\n", time);
    printf("Simple interest = %f\n", simple_interest);
    return 0;
    }
    

C Program to display a number if it is positive

 
#include<stdio.h>
#include<conio.h>
int  main() 
    { 
    clrscr();
   int number;
    printf("Enter an integer: ");
    scanf("%d", &number);
    if (number>0) 
    printf("The value is negative");
    return 0;
    }
    

C PROGRAM to find the larger of two numbers

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
int num1, num2;
printf("Enter Two Numbers");
scanf(“%d %d”,&num1,&num2);
if(num1 > num2)
{ 
printf(“%d is greater”,num1);
}
else
{
printf(“%d is greater”,num2);
}
    return 0;
    }
    

C PROGRAM to find whether the given number is even or odd

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
int num;
    printf("Enter an integer: ");
    scanf("%d", &num);
    if(num % 2 == 0)
        printf("%d is even.", num);
    else
        printf("%d is odd.", num);
    return 0;
    }
    

C PROGRAM to find greater of three numbers using Nested If-else

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
int num1, num2,num3;
printf("Enter Three Numbers");
scanf(“%d %d %d”,&num1,&num2,&num3);
if(num1 > num2)
{ 
if(num1>num3)
printf(“num1 is greater %d”,num1);
}
else
{
if(num2>num3)
printf(“num2 is greater %d”,num2);
else
printf(“num3 is greater %d”,num3);
}
    return 0;
    }
    

Program to Check no. is +ve ,-ve & zero.

 
#include<stdio.h>
#include<conio.h>
void main() 
 { 
     int no; 
     clrscr(); 
     printf("Enter the  no :"); 
     scanf("%d",&a); 
     if(no>0) 
      { 
            printf("no is Positive"); 
      } 
    else if(no==0) 
     { 
            printf("no is Zero"); 
     } 
    else 
    { 
           printf("no is Nagative"); 
    } 
           getch(); 
 } 
							
								
								

C PROGRAM to Make a Simple Calculator Using switch...case

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
 int num1,num2;
    float result;
    char ch; 
     
    printf("Enter first number: ");
    scanf("%d",&num1);
    printf("Enter second number: ");
    scanf("%d",&num2);
     
    printf("Choose operation to perform (+,-,*,/,%): ");
    scanf(" %c",&ch);
     
    result=0;
    switch(ch)    
    {
        case '+':
            result=num1+num2;
            break;
             
        case '-':
            result=num1-num2;
            break;
         
        case '*':
            result=num1*num2;
            break;
             
        case '/':
            result=(float)num1/(float)num2;
            break;
             
        case '%':
            result=num1%num2;
            break;
        default:
            printf("Invalid operation.\n");
    }
 
    printf("Result is: %d %c %d = %f\n",num1,ch,num2,result);
    return 0;
    }
    

C Program Print numbers from 1 to 5 using while loop

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
int i = 1;
    
  while (i <= 5) {
    printf("%d\n", i);
    ++i;
  }
    return 0;
    }
    

WRITE A PROGRAM to Generate Multiplication Table Using while loop

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
clrscr();
int n, i;
 
    printf("Enter a Number ");
    scanf("%d",&n);
    i=1;
    while(i<=10){
                
        printf("%d * %d = %d \n", n, i, n*i);
        ++i;
    }
    return 0;
    }
    

WRITE A C PROGRAM to display the first 10 natural numbers using for loop

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
int i;
	printf("The first 10 natural numbers are:\n");
	for (i=1;i<=10;i++)
	{      
		printf("\n%d ",i);
	}
    return 0;
    }
    

C PROGRAM to Generate Multiplication Table Using for loop

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 clrscr();
int no,i;
	printf("Enter the Number");
	scanf("%d",&no);
	for (i=1;i<=10;i++)
	{      
		printf("\n%d*%d=%d ",no,i,no*i);
	}
    return 0;
    }
    

C Program Print numbers from 1 to 5 using do-while loop

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 clrscr();
int i = 1;
    
do {
    printf("%d\n", i);
    i++;
  }  while (i <= 5)
    return 0;
    }
    

C Program Print series from 1 to 10 and break on 5

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 clrscr();
int i;
for(i=1;i<=10;i++)
   {
   if(i==5)
   break;
    printf("%d\n",i);
   }
    return 0;
    }
    

C Program Print series from 1 to 10 and skip only 5 and 7

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 clrscr();
int i;
for(i=1;i<=10;i++)
   {
   if(a==5 || a==7)
   continue;
   printf("%d\n",i);
   }
   
    return 0;
    }
    

C Program To print numbers from 1 to 10 using goto statement

 
#include<stdio.h>
#include<conio.h>
int  main() 
 { 
 clrscr();
int number;
    number=1;
 
repeat:
    printf("%d\n",number);
    number++;
 
    if(number<=10)
        goto repeat;
   
    return 0;
    }
    

WRITE A PROGRAM using function to find the largest of three numbers.

 
#include<stdio.h>
#include<conio.h>
int large(int a, int b, int c)
{
   if(a>=b && a>=c) 
   return a;
   else if(b>=a && b>=c) 
   return b;
   else 
   return c;
}

int main()
{
  clrscr();
   int num1, num2, num3, largest;

   printf("Enter three numbers: ");
   scanf("%d %d %d", &num1, &num2, &num3);

   largest = large(num1, num2, num3);
   printf("Largest number = %.d",largest);
   return 0;
}
    

C Program for Function without argument and return value.

 
#include<stdio.h>
#include<conio.h>
void main()
   {
   void printname(); //Function Declaration
   printf("Hello ");  
   printname();      //Invoking Function
   getch();
   }
   void printname()   //Function Defination
   {
   printf("jpwebdevelopers");
   }
   
   
    

C Program for Function without argument and with return value.

 
#include<stdio.h>
#include<conio.h> 
void main()
   {
   int total;
   int sum();
   total=sum();  //calling function having no arguments
   printf("%d",total);
   getc();
   }
   int sum()
   {
     int a,b;   
    printf("\nEnter two numbers");  
    scanf("%d %d",&a,&b);  
    return a+b;  
   }
    

C Program for Function with argument and without return value.

 
#include<stdio.h>
#include<conio.h>
int main()
   {
   int sum(int,int);
   int a,b,total;
   printf("\nEnter two numbers");  
    scanf("%d %d",&a,&b); 
    sum(a,b);
   }
   int sum(int x, int y)
   {
   int total;
   total=a+b;
   printf("\n%d",total);
   }
    

C Program for Function with argument and with return value.

 
#include<stdio.h>
#include<conio.h>
void main()  
{  
    int a,b,result;   
    int sum(a,b);  
    printf("\nEnter two numbers:");  
    scanf("%d %d",&a,&b);  
    result = sum(a,b);  //calling function having arguments
    printf("\nThe sum is : %d",result);  
    getch();
}  
int sum(int a, int b)  //called function
{  
   int total;
   total=a+b;
    return total;  
}  
    

C Program passing arguments using call by value method. (Swap two number).

 
#include<stdio.h>
#include<conio.h>
void main()
{
void swap (int a, int b); //function declaration
int a,b;
clrscr();
printf ("Enter two numbers ");
scanf (“%d%d",&a,&b) swap (a,b);
swap(a,b);
printf(“a=%d b=%d”,a,b);
getch();
}
void swap (int a, int b) // function definition
{
int temp;
temp=a;
a=b;
b=temp;
printf(“a=%d b=%d\n”,a,b);
} 
    

C Program passing arguments using Call by Reference (swap two Number) .

 
#include<stdio.h>
#include<conio.h>
void main()
{
void swap (int *, int *);
int a, b;
clrscr();
printf ("enter two number");
scanf ("%d%d",&a,&b);
printf (" \n before swapping a=%d b=%d", a,b);
swap (&a, &b);
printf ("\n After swapping a=%d b=%d",a,b);
getch();
}
void swap (int *a, int *b)
{
int temp;
temp=*a;
*a = *b;
*b= temp;
}
    

WRITE A PROGRAM to find the factorial of a given number using Recursion.

 
#include<stdio.h>
#include<conio.h>
void main()
{
int fact (int num);
int num;
clrscr();
printf ("enter number");
scanf ("%d" &num);
printf ("\n factorial is = %d", fact (num));
getch();
}
int fact (int n)
{
if (n==1)
return (1);
else
return (n* fact (n-1));
} 
    

Program of One Dimensional Array in C.

 
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int arr[5];
int i;
for(i=0;i<5;i++)
{
printf(“Enter the array elements”);
scanf(“%d”,&arr[i]);
}
printf(“\n Printing elements of array”);
for(i=0;i<5;i++)
{
printf(“%d\t”,arr[i]);
}
getch();
} 
    

Program of 2-Dimensional Array in C.

 
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int arr[2][2];
int i,j;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“Enter the array elements”);
scanf(“%d”,&arr[i][j]);
}
printf(“\n”);
}
printf(“\n Printing elements of array”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“%d\t”,arr[i][j]);
}
printf(“\n”);
}
getch();
}
 

WRITE A PROGRAM to print the sum of two matrices.

 
#include<stdio.h>
#include<conio.h>
void main()
{
 intat2] [2], b[2] [2], i, j;
 printf(“Enter the elements of A matrix \n”);
for (i=0; i< 2; i++)
{
for (j = 0; j <2; j++)
{
 printf ("Enter the number");
scanf ("%d",&a[i][j]);
}
}
printf(“ Enter the elements of B matrix \n”);
for (i=0; i< 2; i++)
{
for (j = 0; j <2; j++)
{
printf("Enter the number");
scanf("%d",&b[i][j]);
}
}
printf ("Addition of A and B Matrix \n”);
for (i=0; 1<2; i++)
{
 for(j=0; j <2; j++)
{
printf ("%d", a[i][j] + b[i][j]);
}
printf ("\n");
}
 getch();
}

 

WRITE A PROGRAM to pass the values of array elements to the function using call by value.

 
#include<stdio.h>
#include<conio.h>
void show (int a)
{
printf("%d\t", a);
}
void main()
{
clrscr();
 int a[]={ 10,20,30,40 60};
printf ("The elements of Array : \n");
for (int i = 0; i < 5; i++)
{
show (a[i]);
}
getch();
}


 

WRITE A PROGRAM to pass the values of array elements to the function using call by reference.

 
#include<stdio.h>
#include<conio.h>
void show (int *a)
{
printf("%d\t", a);
} 
void main()
{
clrscr();
 int a[]={ 10,20,30,40 60};
printf ("The elements of Array : \n");
for (int i = 0; i < 5; i++)
{
show (&a[i]);
}
getch();
} 


 

WRITE A PROGRAM to Find the Length of a String.

 
#include<stdio.h>
#include<conio.h>
#include<string.h>  
int main()
{
    char Str[1000];
    int i;
  
    printf("Enter the String: ");
    scanf("%s", Str);
  
    printf("Length of Str is %ld", strlen(Str));
  
    return 0;
}


 

WRITE A PROGRAM to Find the Length of a String

 
#include<stdio.h>
#include<conio.h>
#include<string.h>  
void main()
{
    char str1[100],str2[50];
    printf("Enter string str1\n");
    gets(str1);
    strcpy(str2,str1);
    printf("Copied String(str2) is %s",str2);
    getch();
}

 

WRITE A PROGRAM to Copy String using strcpy().

 
#include<stdio.h>
#include<conio.h>
#include<string.h>  
int main()  
{  
   char str1[20];  // declaration of char array  
   char str2[20];  // declaration of char array    
   printf("Enter the first string : ");  
   scanf("%s",str1);  
   printf("Enter the second string : ");  
   scanf("%s",str2);  
   if(strcmp(str1,str2)==0)  
   printf("strings are same");  
   else  
   printf("strings are not same");  
   return 0;  
} 

 

WRITE A PROGRAM to compare a string.

 
#include<stdio.h>
#include<conio.h>
#include<string.h>  
int main()  
{  
   char str1[20];  // declaration of char array  
   char str2[20];  // declaration of char array    
   printf("Enter the first string : ");  
   scanf("%s",str1);  
   printf("Enter the second string : ");  
   scanf("%s",str2);  
   if(strcmp(str1,str2)==0)  
   printf("strings are same");  
   else  
   printf("strings are not same");  
   return 0;  
} 

 

WRITE A PROGRAM to reverse a string. .

 
#include<stdio.h>
#include<conio.h>
#include<string.h  
int main()  
{  
   char s[100];
   printf("Enter a string to reverse\n");
   gets(s);
   strrev(s);
   printf("Reverse of the string: %s\n", s); 
   return 0;  
} 

 

WRITE A Pointer PROGRAM to swap two numbers without using the 3rd variable. .

 
#include<stdio.h>
#include<conio.h>
int main()  
{
int a=10,b=20,*p1=&a,*p2=&b;   
printf("Before swap: *p1=%d *p2=%d",*p1,*p2);  
*p1=*p1+*p2;  
*p2=*p1-*p2;  
*p1=*p1-*p2;  
printf("\nAfter swap: *p1=%d *p2=%d",*p1,*p2);   
return 0; 
}
 

WRITE A Pointer PROGRAM to show the relation between array and pointer. .

 
#include<stdio.h>
#include<conio.h>
void main()
{ 
int ar[5]={10,20,30,40,50};
int *p,i;
p=ar;
for (i=0;i< 5; i++)
{
printf("\n The value stored at the location %d is %d", i,p[i]); 
}
getch();
}
 

WRITE A PROGRAM to show 2-D Array with Pointer. .

 
#include<stdio.h>
#include<conio.h>
void main()
{
int ar[3][4]={
{10,20,30,40}, {5,6,7,8}, {9,10,11,12},
};
int i,j;
clrscr();
for (i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
printf("\n The value stored at the location[%d][%d]is %d", i, j, *(*(ar+i) +j));
}
}
getch();
}
 

WRITE A PROGRAM to display address of variable using pointers.

#include<stdio.h>
#include<conio.h>
void main()
{
int var=100;
clrscr();
printf(“the address of var is %u”,&var);
getch();
} 
 

WRITE A PROGRAM to create Student I-Card using a Structure. .

 
#include<stdio.h>
#include<conio.h>
struct student
{
   char id_num[6];
    char name[50];
    char fname[50];
    char gender;
    int roll;
int age;
};
int main()
{
    struct student s;
    
 printf("Enter The Information of Students :\n\n");
    printf("Enter Id Number : ");
    scanf("%s",s.id_num);
    printf("/n Enter Name : ");
    scanf("%s",s.name);
    printf("Enter Father Name : ");
    scanf("%s",s.fname);
     printf("Enter Gender : ");
    scanf("%s",s.gender);
     printf("Enter Roll No. : ");
    scanf("%d",&s.roll);
    printf("Enter Age : ");
    scanf("%d",&s.age);
    
    
    printf("\nDisplaying Information\n");
    printf("Name: %s\n",s.id_num);
    printf("Name: %s\n",s.name);
    printf("Name: %s\n",s.fname);
    printf("Name: %s\n",s.gender);
    printf("Roll: %d\n",s.roll);
    printf("Marks: %.d\n",s.age);
    return 0;
}
 

WRITE A PROGRAM to display structures and pointers.

 
#include<stdio.h>
#include<conio.h>
struct student
{
   char name[20];
int rollno;
};
void main()
{
struct student stu;
struct student *p;
p=&stu;
printf(“\n Enter Student Name:”);
scanf(“%s”,p->name);
printf(“\n Enter Student Roll No:”);
scanf(“%d”,&p->rollno);
printf(“\n******OUTPUT******);
printf(“\n Student Name is :%s”,(*p).name);
printf(“\n Student Rollno is :%d”,(*p).rollno); 
getch();
}
 

WRITE A PROGRAM to Passing Structure to a Function By Value

 
#include<stdio.h>
#include<conio.h>
void disp(struct student s1);
struct student
{
char name[20];
int rollno;
};
void main()
{
struct student stu;
printf(“Enter the Name”);
scanf(“%s”,stu.name);
printf(“Enter the RollNo”);
scanf(“%d”,&stu.rollno);
disp(stu);
getch();
}
void disp(struct student s1)
{
printf(“\n****output****”);
printf(“\nStudent Name is %s”,s1.name);
printf(“\nStudent Rollno is %d”,s1.rollno);
} 
 

WRITE A PROGRAM to Passing Structure to a Function By Reference.

 
#include<stdio.h>
#include<conio.h>
void disp(struct student * s1); 
struct student
{
char name[20];
int rollno;
};
void main()
{
struct student stu;
printf(“Enter the Name”);
scanf(“%s”,stu.name);
printf(“Enter the RollNo”);
scanf(“%d”,&stu.rollno);
disp(&stu);
getch();
}
void disp(struct student *s1) 
{
printf(“\n****output****”);
printf(“\nStudent Name is %s”,s1->name);
printf(“\nStudent Rollno is %d”,s1->rollno); 
} 
 

WRITE A PROGRAM to show the memory occupied by Structure.

 
#include<stdio.h>
#include<conio.h>
struct student 
{
       int id;
       char a;
       char b;
       float percentage;
};
 
int main() 
{
    int i;
    struct student s1 = {1,'A', 'B', 90.5};
 
    printf("size of structure in bytes : %d\n", 
                           sizeof(s1));
 
    printf("\nAddress of id1        = %u", &s1.id );
    printf("\nAddress of a          = %u", &s1.a );
    printf("\nAddress of b          = %u", &s1.b );
    printf("\nAddress of percentage = %u",&s1.percentage);
 
    return 0;
}
 

WRITE A PROGRAM to demonstrate the difference between unions and structures.

 
#include<stdio.h>
#include<conio.h>
union unionJob
{
   //defining a union
   char name[32];
   float salary;
   int workerNo;
} uJob;

struct structJob
{
   char name[32];
   float salary;
   int workerNo;
} sJob;

int main()
{
   printf("size of union = %d bytes", sizeof(uJob));
   printf("\nsize of structure = %d bytes", sizeof(sJob));
   return 0;
}
 
index