Posts

Showing posts from April, 2026

Single Program Using All Automatic String Functions

#include <stdio.h> #include <string.h> int main()  {     char str1[50], str2[50], copy[50];     //  1. Reading     printf("Enter first string: ");     scanf("%s", str1);     printf("Enter second string: ");     scanf("%s", str2);     //  2. Writing     printf("\nFirst String: %s", str1);     printf("\nSecond String: %s", str2);     //  3. Length     printf("\nLength of first string: %d", strlen(str1));     //  4. Copy     strcpy(copy, str1);     printf("\nCopied string: %s", copy);     //  5. Comparison     if(strcmp(str1, str2) == 0)         printf("\nStrings are Equal");     else         printf("\nStrings are Not Equal");     //  6. Concatenation     strcat(str1, str2);     printf("\nAfter Concatenation...

Single Program (All Manual String Operations)

#include <stdio.h> int main()  {     char str1[50], str2[50], copy[50], concat[100], rev[50];     int i, j, len = 0, flag = 0;     //  1. Reading     printf("Enter first string: ");     scanf("%s", str1);     printf("Enter second string: ");     scanf("%s", str2);     //  2. Writing     printf("\nFirst String: ");     for(i = 0; str1[i] != '\0'; i++)     {         printf("%c", str1[i]);     }     printf("\nSecond String: ");     for(i = 0; str2[i] != '\0'; i++)     {         printf("%c", str2[i]);     }     //  3. Length     for(i = 0; str1[i] != '\0'; i++);     len = i;     printf("\nLength of first string: %d", len);     //  4. Copy     for(i = 0; str1[i] != '\0'; i++)     {...

C program for Lowercase conversion of string (Manual)

#include <stdio.h> int main()  {     char str[50];     int i;     printf("Enter the string : ");     scanf("%s", str);     for(i = 0; str[i] != '\0'; i++)  {         if(str[i] >= 'A' && str[i] <= 'Z')  {             str[i] = str[i] + 32;         }     }     printf("Lower: %s", str); }

C program for Uppercase conversion of string (Manual)

#include <stdio.h> int main()  {     char str[50];     int i;     printf("Enter the string : ");     scanf("%s", str);     for(i = 0; str[i] != '\0'; i++)  {         if(str[i] >= 'a' && str[i] <= 'z')  {             str[i] = str[i] - 32;         }     }     printf("Upper: %s", str); }

C program to Reverse String (Manual)

#include <stdio.h> int main()  {     char str[50], rev[50];     int i, j = 0;     printf("Enter the string : ");     scanf("%s", str);     for(i = 0; str[i] != '\0'; i++);     for(i = i - 1; i >= 0; i--)  {         rev[j++] = str[i];     }     rev[j] = '\0';     printf("Reversed: %s", rev); }

C program for Concatenation of string (Manual)

#include <stdio.h> int main()  {     char s1[50], s2[50];     int i, j;     printf("Enter the string : ");     scanf("%s %s", s1, s2);     for(i = 0; s1[i] != '\0'; i++);     for(j = 0; s2[j] != '\0'; j++)  {         s1[i] = s2[j];         i++;     }     s1[i] = '\0';     printf("Result: %s", s1); }

C program to Compare Strings (Manual)

#include <stdio.h> int main()  {     char s1[50], s2[50];     int i, flag = 0;     printf("Enter the two strings : ");     scanf("%s %s", s1, s2);     for(i = 0; s1[i] != '\0' || s2[i] != '\0'; i++)  {         if(s1[i] != s2[i])  {             flag = 1;             break;         }     }     if(flag == 0)         printf("Equal");     else         printf("Not Equal"); }

C program to Copy String (Manual)

#include <stdio.h> int main()  {     char str1[50], str2[50];     int i;     printf("Enter the string : ");     scanf("%s", str1);     for(i = 0; str1[i] != '\0'; i++)      {         str2[i] = str1[i];     }     str2[i] = '\0';     printf("Copied: %s", str2);     return 0; }

C program to find Length of String (Manual)

#include <stdio.h> int main()  {     char str[50];     int i;     printf("Enter the string : ");     scanf("%s", str);     for(i = 0; str[i] != '\0'; i++);     printf("Length = %d", i); }

C program for Lowercase Conversion of string(Automatic)

#include <stdio.h> #include <string.h> int main()  {     char str[50];     printf("Enter the string :  ");     scanf("%s", str);     printf("Lower: %s", strlwr(str)); }

C program for Uppercase Conversion of string(Automatic)

#include <stdio.h> #include <string.h> int main()  {     char str[50];      printf("Enter the string:  ");     scanf("%s", str);     printf("Upper: %s", strupr(str)); }

C program for Reverse String (Automatic)

#include <stdio.h> #include <string.h> int main()  {     char str[50];     printf("Enter the string :  ");     scanf("%s", str);     strrev(str);     printf("Reversed: %s", str); }

C program for Concatenation of strings (Automatic)

#include <stdio.h> #include <string.h> int main()  {     char s1[50], s2[50];     printf("Enter two strings :  ");     scanf("%s %s", s1, s2);     strcat(s1, s2);     printf("Result: %s", s1); }

C program to Compare Strings (Automatic)

#include <stdio.h> #include <string.h> int main()  {     char s1[50], s2[50];     printf("Enter two strings :  ");     scanf("%s %s", s1, s2);     if(strcmp(s1, s2) == 0)         printf("Equal");     else         printf("Not Equal"); }

C program to Copy String (Automatic)

#include <stdio.h> #include <string.h> int main()  {     char str1[50], str2[50];     scanf("%s", str1);     strcpy(str2, str1);     printf("Copied: %s", str2); }

C program for finding Length of String (Automatic)

#include <stdio.h> #include <string.h> int main()  {     char str[50];     scanf("%s", str);     printf("Length = %d", strlen(str)); }

C program for Reading & Writing String (Manual)(character by character)

#include <stdio.h> int main()  {     char str[50];     int i;     printf("Enter string: ");     for(i = 0; (str[i] = getchar()) != '\n'; i++);     str[i] = '\0';     printf("String is: ");     for(i = 0; str[i] != '\0'; i++) {         putchar(str[i]);     } }

C program for Reading & Writing String(Automatic)

#include <stdio.h> int main()  {     char str[50];     printf("Enter string: ");     scanf("%s", str);     printf("String is: %s", str); }

C program for conversition of Lowercase To Uppercase

 #include<stdio.h> #include<stdlib.h> #include<string.h> int main() {     char name[30], name1[30];     int i;     printf("\n Enter your name :  ");     scanf("%s", name);     for(i = 0; name[i] != '\0'; i++)         name1[i] = name[i] - 32;          name1[i] = '\0';     printf("\n Your name is %s", name1); }

C program for copying one String With other String

 #include<stdio.h> #include<string.h> int main() {     char name[30],name1[30];     int i;     printf("\n Enter your name :  ");     scanf("%s",name);      for (i=0;name[i]!='\0';i++)         name1[i]=name[i];     name1[i]='\0';     printf("\n Your name is   %s",name1); }

C program to print character by character vertically

 #include<stdio.h> int main() {     char name[30];     int i;     printf("\n Enter your name :  ");     scanf("%s",name);     for (i=0;name[i]!='\0';i++)         printf("\n%c",name[i]); }

C program for Read and Display a String

#include<stdio.h>  #include<conio.h>   int main() {  char str1[30],str2[30];  printf("\nenter two strings");   scanf("%s %s",str1,str2);    printf("\n%s %s",str1,str2); }

C program for Bubble Sort

#include<stdio.h> int main() {     int a[50], n, i, j, temp;     printf("Enter number of elements: ");     scanf("%d", &n);     printf("Enter %d elements:\n", n);     for(i = 0; i < n; i++)     {         scanf("%d", &a[i]);     }     /* Bubble Sort */     for(i = 0; i < n-1; i++)     {         for(j = 0; j < n-i-1; j++)         {             if(a[j] > a[j+1])             {                 temp = a[j];                 a[j] = a[j+1];                 a[j+1] = temp;             }         }     }     printf("\nSorted elements are:\n");     for(i = 0; i ...

C program for Multiplication of Two matrices

#include<stdio.h> #include<stdlib.h> int main() {     int a[10][10], b[10][10], c[10][10];     int r1, c1, r2, c2, i, j, k;     printf("\nEnter rows and cols of Matrix A: ");     scanf("%d %d", &r1, &c1);     printf("\nEnter rows and cols of Matrix B: ");     scanf("%d %d", &r2, &c2);     if(c1 != r2)     {         printf("\nMatrix multiplication not possible");         exit(0);     }     printf("\nEnter elements of Matrix A:\n");     for(i = 0; i < r1; i++)     {         for(j = 0; j < c1; j++)         {             scanf("%d", &a[i][j]);         }     }     printf("\nEnter elements of Matrix B:\n");     for(i = 0; i < r2; i++)     {        ...

C program for subtraction of two matrices (2D Arrays)

 #include <stdio.h> #include <stdlib.h> int main() {     int a[10][10], b[10][10], c[10][10];     int ar, ac, br, bc, i, j;     printf("\nEnter how many rows and cols of Matrix A: ");     scanf("%d %d", &ar, &ac);          printf("\nEnter how many rows and cols of Matrix B: ");     scanf("%d %d", &br, &bc);     if (ar != br || ac != bc) {         printf("\nInvalid Subtraction (Matrices must have the same dimensions)\n");         exit(0);     }     printf("\nEnter the elements of Matrix A:\n");     for (i = 0; i < ar; i++) {         for (j = 0; j < ac; j++) {             scanf("%d", &a[i][j]);         }     }     printf("\nEnter the elements of Matrix B:\n");     for (i = 0; i < br; i++) { ...

C program for Addition of two matrices (2D Arrays)

 #include <stdio.h> #include <stdlib.h> int main() {     int a[10][10], b[10][10], c[10][10];     int ar, ac, br, bc, i, j;     printf("\nEnter how many rows and cols of Matrix A: ");     scanf("%d %d", &ar, &ac);          printf("\nEnter how many rows and cols of Matrix B: ");     scanf("%d %d", &br, &bc);     if (ar != br || ac != bc) {         printf("\nInvalid Addition\n");         exit(0);     }     printf("\nEnter the elements of Matrix A:\n");     for (i = 0; i < ar; i++) {         for (j = 0; j < ac; j++) {             scanf("%d", &a[i][j]);         }     }     printf("\nEnter the elements of Matrix B:\n");     for (i = 0; i < br; i++) {         for (j = 0; j <...

7 days 3 vegetables (2D Arrays)

 #include <stdio.h> int main()  {     float veg[7][3];     int d, v;     printf("Enter prices of 3 vegetables for 7 days:\n");     for(d = 0; d < 7; d++)          for(v = 0; v < 3; v++)              scanf("%f", &veg[d][v]);     printf("\nPrices of 3 vegetables for 7 days:\n");     for(d = 0; d < 7; d++) {         printf("Day %d: ", d + 1);         for(v = 0; v < 3; v++) {             printf("%.2f ", veg[d][v]);         }         printf("\n");     } }

C Program to Classify Students by Gender Using Array

 #include<stdio.h> int main() {     int i, mcount=0, fcount=0, tcount=0;     char a[75];     printf("Enter the gender of 6 students (m/f/t): ");     for(i=0;i<6;i++)     {         scanf(" %c",&a[i]);   // space before %c avoids input issue     }     for(i=0;i<6;i++)     {         if(a[i]=='m')             mcount++;         else if(a[i]=='f')             fcount++;         else             tcount++;     }     printf("\nMale count = %d",mcount);     printf("\nFemale count = %d",fcount);     printf("\nTrans count = %d",tcount); }

C Program to Find Minor Students Using an Array

 #include<stdio.h> int main() {     int a[75], i;     printf("Enter the age of 3 students: ");     for(i=0;i<3;i++)     {         scanf("%d",&a[i]);     }     for(i=0;i<3;i++)     {         if(a[i] < 18)         {             printf("\nStudent no: %d is minor with age %d", i+1, a[i]);         }     } }

C Program: Highest Tomato Price in 7 Days Using Array

 #include<stdio.h> void main() {     int price[7], i, max, day;     printf("Enter tomato prices for 7 days:\n");     for(i=0;i<7;i++)     {         printf("Day %d price: ", i+1);         scanf("%d",&price[i]);     }     max = price[0];     day = 1;     for(i=1;i<7;i++)     {         if(price[i] > max)         {             max = price[i];             day = i + 1;         }     }     printf("\nHighest tomato price is %d on Day %d", max, day); }

C Program for Matrix Addition Using 2-D Arrays

 #include<stdio.h> void main() {     int matA[10][10], matB[10][10], matC[10][10], rows, cols, r, c;     printf("\nEnter no. of rows & cols: ");     scanf("%d%d",&rows,&cols);     printf("\nEnter matrix 1 of %d x %d: ",rows,cols);     for(r=0;r<rows;r++)         for(c=0;c<cols;c++)             scanf("%d",&matA[r][c]);     printf("\nEnter matrix 2 of %d x %d: ",rows,cols);     for(r=0;r<rows;r++)         for(c=0;c<cols;c++)             scanf("%d",&matB[r][c]);     for(r=0;r<rows;r++)         for(c=0;c<cols;c++)             matC[r][c] = matA[r][c] + matB[r][c];     printf("\nMatrix C (Result of Addition) is : ");     for(r=0;r<rows;r++)     {         printf("\n")...

C Program to Input and Print a 2-D Array (Matrix)

 #include<stdio.h> void main() {     int a[10][10],rows,cols,r,c;     printf("\nEnter no. of rows & cols: ");     scanf("%d%d",&rows,&cols);     printf("\nEnter matric of %d x %d: ",rows,cols);     for(r=0;r<rows;r++)         for(c=0;c<cols;c++)             scanf("%d",&a[r][c]);     printf("\n Matrix is : ");     for(r=0;r<rows;r++)     {         printf("\n");         for(c=0;c<cols;c++)             printf("%d ",a[r][c]);     } }

C Program to Search an Element in an Array Using Binary Search

 #include<stdio.h> void main() {     int a[50],n,i,l=0,h,m,ele;     do     {         printf("\nEnter no. of elements in between 1 and 50: ");         scanf("%d",&n);     }while(n<1 || n>50);     printf("\nEnter the elements (in sorted order): ");     for(i=0;i<n;i++)         scanf("%d",&a[i]);     h=n-1;     printf("\nEnter an element for search: ");     scanf("%d",&ele);     while(l<=h)     {         m=(l+h)/2;         if(ele==a[m])         {             printf("\nFound at a[%d]",m);             break;         }         if(ele>a[m])             l=m+1;         else   ...

C Program to Search an Element in an Array (Linear Search)

 #include<stdio.h> #include<stdlib.h> void main() {     int a[50],n,i,ele;     do     {         printf("\nEnter no. of elements in between 1 and 50: ");         scanf("%d",&n);     }while(n<1 || n>50);     printf("\nEnter the elements: ");     for(i=0;i<n;i++)         scanf("%d",&a[i]);     printf("\nEnter an element for search: ");     scanf("%d",&ele);     for(i=0;i<n;i++)     {         if(a[i]==ele)         {             printf("\n%d is found.",ele);             exit(0);         }     }     printf("\n%d is NOT found.",ele); }

Program to find min and max of elements in array

 #include<stdio.h> void main() {     int a[50],n,i,max,min;     do     {         printf("\nEnter no. of elements in between 1 and 50: ");         scanf("%d",&n);     }while(n<1 || n>50);     printf("\nEnter the elements: ");     for(i=0;i<n;i++)         scanf("%d",&a[i]);     max=a[0];     min=a[0];     for(i=1;i<n;i++)     {         if(a[i]>max)             max=a[i];         if(a[i]<min)             min=a[i];     }     printf("\nMax = %d and Min = %d",max,min); }

Program to find sum of the elements in the array

 #include<stdio.h> void main() {     int a[50],n,i,sum=0;     do     {         printf("\nEnter no. of elements in between 1 and 50: ");         scanf("%d",&n);     }while(n<1 || n>50);     printf("\nEnter the elements: ");     for(i=0;i<n;i++)         scanf("%d",&a[i]);     printf("\nElements are: ");     for(i=0;i<n;i++)         printf("%d ",a[i]);     for(i=0;i<n;i++)         sum=sum+a[i];     printf("\nSum = %d",sum); }

Program to read and display array elements

#include<stdio.h> void main() {     int a[50];     int n,i;     do     {         printf("\nEnter no. of elements in between 1 and 50: ");         scanf("%d",&n);     }while(n<1 || n>50);     printf("\nEnter the elements: ");     for(i=0;i<n;i++)         scanf("%d",&a[i]);     printf("\nElements are: ");     for(i=0;i<n;i++)         printf("%d ",a[i]); }

One C Program to Generate 5 Different Number Patterns

 #include<stdio.h> int main() {  int cols=5,rows=5,colno,rowno,sp;     for (rowno=1;rowno<=rows;rowno++)       {         printf("\nRow No %d-  ",rowno);    // for(colno=1;colno<=cols;colno++) //for 5/5 matirx       //printf("%d",colno);       //for(colno=1;colno<=rowno;colno++)//for left upper triangle         //printf("%d",colno);        //for(colno=1;colno<=rows+1-rowno;colno++)//for right upper triangle         //printf("%d",colno);       // for(sp=0;sp<cols-rowno;sp++)      //  printf(" ");          // for(colno=1;colno<=rowno;colno++)//for right lower triangle         //printf("%d",colno);            //    for(sp=0;sp<rowno-1;sp++)        //printf(" ");   ...

Right upper Triangle

 #include<stdio.h> int main() {     int rows=5,rowno,colno,sp;     for(rowno=1;rowno<=rows;rowno++)     {         printf("\nRow No %d-  ",rowno);         for(sp=0;sp<rowno-1;sp++)         {             printf(" ");         }         for(colno=1;colno<=rows+1-rowno;colno++)         {             printf("%d",colno);         }     } }

Right Lower Triangle

 #include<stdio.h> int main() {     int rows=5,rowno,colno,sp;     for(rowno=1;rowno<=rows;rowno++)     {         printf("\nRow No %d-  ",rowno);         for(sp=0;sp<rows-rowno;sp++)         {             printf(" ");         }         for(colno=1;colno<=rowno;colno++)         {             printf("%d",colno);         }     } }

left Upper Triangle

 #include<stdio.h> int main() {     int rows=5,rowno,colno;     for(rowno=1;rowno<=rows;rowno++)     {         printf("\nRow No %d-  ",rowno);         for(colno=1;colno<=rows+1-rowno;colno++)         {             printf("%d",colno);         }     } }

Left Lower Triangle

 #include<stdio.h> int main() {     int rows=5,rowno,colno;     for(rowno=1;rowno<=rows;rowno++)     {         printf("\nRow No %d-  ",rowno);         for(colno=1;colno<=rowno;colno++)         {             printf("%d",colno);         }     } }

5 × 5 Number Matrix

 #include<stdio.h> int main() {     int rows=5, cols=5, rowno, colno;     for(rowno=1; rowno<=rows; rowno++)     {           printf("\nRow No %d-  ",rowno);         for(colno=1; colno<=cols; colno++)         {             printf("%d",colno);         }     } }

All Basic Loop Programs in One C Program

#include<stdio.h> int main() { int i,n,m,sum1=0,sum2=0,sum3=0,a,ogl,rem,rev=0,b,sum4=0,c,r1,r2; long int fact=1; printf("enter n value: "); scanf("%d",&n); printf("Enter m value for table: "); scanf("%d",&m); printf("Enter a value to get reverse of it : "); scanf("%d",&a); printf("Enter b value to get sum of it's digits : "); scanf("%d",&b); do {        printf("Enter c value to get sum of it's 1st & last digit : ");        scanf("%d",&c);        if (c<9) printf("Enter minimum 2 digit number.\n");       }while (c<9); printf("\nNatural numbers upto %d: ",n);     for (i=1;i<=n;i++) {printf("\n%d",i);}     printf("\nOdd numbers upto %d: ",n); for (i=1;i<=n;i=i+2) {printf("\n%d",i);}     printf("\nEven numbers upto %d: ",n); for (i=2;i...

Sum of Even Numbers(For loop)

 #include<stdio.h> int main() {     int n,i,sum=0;     printf("Enter n: ");     scanf("%d",&n);     for(i=1;i<=n;i++)     {         if(i%2==0)             sum=sum+i;     }     printf("Sum of even numbers = %d",sum); }

Fibonacci Series

 #include<stdio.h> int main() {     int n,a=0,b=1,c,i;     printf("Enter terms: ");     scanf("%d",&n);     for(i=1;i<=n;i++)     {         printf("%d ",a);         c=a+b;         a=b;         b=c;     } }

Factorial of a Number(For Loop)

 #include<stdio.h> int main() {     int n,i;     long fact=1;     printf("Enter number: ");     scanf("%d",&n);     for(i=1;i<=n;i++)         fact=fact*i;     printf("Factorial = %ld",fact); }

Print Numbers from 1 to N(For Loop)

 #include<stdio.h> int main() {     int n,i;     printf("Enter n: ");     scanf("%d",&n);     for(i=1;i<=n;i++)         printf("%d ",i); }

Count Digits of a Number (while loop)

 #include<stdio.h> int main() {     int n,count=0;     printf("Enter number: ");     scanf("%d",&n);     while(n!=0)     {         n=n/10;         count++;     }     printf("Total digits = %d",count); }

Reverse a Number (While Loop)

 #include<stdio.h> int main() {     int n,rev=0,rem;     printf("Enter number: ");     scanf("%d",&n);     while(n!=0)     {         rem=n%10;         rev=rev*10+rem;         n=n/10;     }     printf("Reverse = %d",rev); }

Print Numbers from 1 to 10(While Loop)

 #include<stdio.h> int main() {     int i=1;     while(i<=10)     {         printf("%d ",i);         i++;     } }

Multiplication Table(Do–While Loop)

 #include<stdio.h> int main() {     int n,i=1;     printf("Enter number: ");     scanf("%d",&n);     do     {         printf("%d x %d = %d\n",n,i,n*i);         i++;     }while(i<=10); }

Sum of First N Natural Numbers (Do–While Loop)

 #include<stdio.h> int main() {     int n,i=1,sum=0;     printf("Enter n: ");     scanf("%d",&n);     do     {         sum=sum+i;         i++;     }while(i<=n);     printf("Sum = %d",sum); }

Print Numbers from 1 to 10 (Do–While Loop)

 #include<stdio.h> int main() {     int i=1;     do     {         printf("%d ",i);         i++;     }while(i<=10); }

C program using switch-case

 #include <stdio.h> int main()  {     int a, b, choice;     printf("Enter two numbers: ");     scanf("%d %d", &a, &b);     printf("\n1. Addition");     printf("\n2. Subtraction");     printf("\n3. Multiplication");     printf("\n4. Division");     printf("\nEnter your choice: ");     scanf("%d", &choice);     switch(choice)     {         case 1:             printf("Sum = %d", a + b);             break;         case 2:             printf("Difference = %d", a - b);             break;         case 3:             printf("Product = %d", a * b);             break;         case 4:       ...

C Program to Demonstrate Increment and Decrement

 #include<stdio.h> void main() {     int a=5;     printf("Post Increment = %d\n",a++);     printf("After = %d\n",a);     printf("Pre Increment = %d",++a); }

C Program for Classroom Selection

 #include<stdio.h> void main() {     int students;     printf("Enter number of students: ");     scanf("%d",&students);     if( students<=30 )     printf("Room A");     else     printf("Room B"); }

C Program to Check Positive Negative Neutral

 #include<stdio.h> void main() {     int n;     printf("Enter number: ");     scanf("%d",&n);     if(n>0)          printf("Positive");               else if(n<0)                    printf("Negative");                         else                             printf("Neutral"); }

C Program to Calculate Income Tax

 #include<stdio.h> void main() { float income,totaltax; printf("\nEnter the income(in Lakhs) : ");  scanf("%f",&income); if (income<=3)  totaltax = 0; else if (income<=6) totaltax = 0+(income-3)*0.05;  else if (income<= 9) totaltax = 0.15+(income-6)*0.1;  else if (income <= 12) totaltax = 0.45+(income-9)*0.15; else totaltax =0.9+(income-12)*0.2; printf(" Total Tax( in Lakhs)= %0.2f",totaltax); } OR #include<stdio.h>  void main() { int income; float tax; printf("Enter the income: ");  scanf("%d", &income); if (income<=300000)  tax=income*0; else if(income<=600000) tax=(300000*0)+(income-300000)*0.05; else if(income<=900000) tax=(300000*0)+(300000*0.05)+(income-600000)*0.1; else if (income<=1200000) tax=(300000*0)+(300000*0.05)+(300000*0.1)+(income- 900000)*0.15; else if(income<=1500000) tax=(300000*0)+(300000*0.05)+(300000*0.1)+(300000*0.15)+(income- 1200000)*0.2; else if(income<=2000000)...

C Program to Calculate Electricity Power Bill

 #include<stdio.h> void main() {     int units;     int unitcost;     int bill;     printf("Enter the number of units: ");     scanf("%d",&units);     if(units <= 30)         unitcost = 1;     else if(units <= 50)         unitcost = 2;     else if(units <= 100)         unitcost = 3;     else         unitcost = 10;     bill = units * unitcost ;     printf("Total Power Bill = %d",bill); }

C Program for Room Numbers

#include <stdio.h> void main() {     int number;     do     {         printf("Enter room number : ");         scanf("%d",&number);         if (number >= 3211 || number <= 3200)             printf("Entered room number doesn't exist.\n");     } while (number >= 3211 || number <= 3200);     if (number == 3201)         printf("Seminar Hall");     else if (number == 3202)         printf("1st Year Class");     else if (number == 3203)         printf("2nd Year Class");     else if (number == 3204)         printf("3rd Year Class");     else if (number == 3205)         printf("Staff Room");     else if (number == 3206)         printf("HOD Room");     else if (...

C Program to Find Grade from Marks

 #include<stdio.h> void main() { int marks; printf("Enter the marks: ");  scanf("%d",&marks); if(marks >= 90)       printf("Grade:S");           else if(marks >= 80)                printf("Grade: B");                     else if(marks >= 70)                          printf("Grade: C");                               else if(marks >= 60)                                    printf("Grade: D");                                     ...

C Program to Check Two Numbers Equal

 #include<stdio.h> void main() {     int a,b;     printf("Enter two numbers: ");     scanf("%d %d",&a,&b);     if( a==b )     printf("True");     else     printf("False"); }

C Program to Convert Digit to Word

      #include<stdio.h> void main() { int n; printf("Enter a digit (0-9): "); scanf("%d",&n); if(n==0) printf("Zero");      else if(n==1)           printf("One");           else if(n==2)                printf("Two");                else if(n==3)                     printf("Three");                     else if(n==4)                               printf("Four");                               else if(n==5)                         ...

C Program to Check Even or Odd

 #include<stdio.h> void main() {     int n;     printf("Enter number: ");     scanf("%d",&n);     if( n%2 == 0 )     printf("Even");     else     printf("Odd"); }

C Program to Convert Negative to Positive

 #include<stdio.h> void main() {     int n;     printf("Enter number: ");     scanf("%d",&n);     if( n<0 )     n= -n;     printf("Number = %d",n); }

C Program to Check Positive or Negative

 #include<stdio.h> void main() {     int n;     printf("Enter number: ");     scanf("%d",&n);     if( n>0 )     printf("Positive");     else     printf("Negative"); }

C Program to Check Voting Eligibility

 #include<stdio.h> void main() {     int age;     printf("Enter age: ");     scanf("%d",&age);     if( age>=18 )     printf("Eligible to vote");     else     printf("Not eligible"); }

C Program to Check Sign

 #include<stdio.h> void main() {     int n;     printf("Enter number: ");     scanf("%d",&n);     if(n>0)     printf("Positive");     else if(n<0)     printf("Negative");     else     printf("Zero"); }

C Program For Number Chart

#include<stdio.h> void main() {     int i;     for(i=1;i<=10;i++)     printf("%d\n",i); } 

Cinema Ticket Price(Discount Calcluation)

 #include<stdio.h> void main() { int adults, kids, seniors; float ticket = 200; float adult_total, kids_total, senior_total, total; printf("Enter number of adults: ");  scanf("%d",&adults); printf("Enter number of kids: ");  scanf("%d",&kids); printf("Enter number of senior citizens: ");  scanf("%d",&seniors); adult_total = adults * ticket; kids_total = kids * (ticket * 0.25); senior_total = seniors * (ticket * 0.75); total = adult_total + kids_total + senior_total; printf("\nAdult Ticket Cost = %.2f", adult_total); printf("\nKids Ticket Cost = %.2f", kids_total); printf("\nSenior Citizen Ticket Cost = %.2f", senior_total); printf("\nTotal Amount = %.2f", total); }

C Program to Calculate Area and Perimeter of a Triangle

 #include<stdio.h> void main() {     float base, height;     int a, b, c;     float area, perimeter;     printf("Enter base and height of triangle: ");     scanf("%f %f",&base,&height);     area = 0.5 * base * height ;     printf("Enter three sides of triangle: ");     scanf("%d %d %d",&a,&b,&c);     perimeter = a + b + c ;     printf("Area of triangle = %f\n",area);     printf("Perimeter of triangle = %f",perimeter); }

C Program for Area and Perimeter of Square

 #include<stdio.h> void main() {     int a;     printf("Enter side: ");     scanf("%d",&a);     printf("Area = %d\n", a*a );     printf("Perimeter = %d", 4*a ); }

C Program for Area and Perimeter of Rectangle

 #include<stdio.h> void main() {     int l,b;     printf("Enter length and breadth: ");     scanf("%d %d",&l,&b);     printf("Area = %d\n", l*b );     printf("Perimeter = %d", 2*(l+b) ); }

C Program for Area and Perimeter of Circle

 #include<stdio.h> void main() {     float r;     printf("Enter radius: ");     scanf("%f",&r);     printf("Area = %f\n", 3.14*r*r );     printf("Perimeter = %f", 2*3.14*r ); }

C Program to Find Perimeter of Triangle

 #include<stdio.h> void main() {     int a,b,c;     printf("Enter three sides: ");     scanf("%d %d %d",&a,&b,&c);     printf("Perimeter = %d", a+b+c ); }

C Program to Find Perimeter of Square

 #include<stdio.h> void main() {     int a;     printf("Enter side: ");     scanf("%d",&a);     printf("Perimeter = %d", 4*a ); }

C Program to Find Perimeter of Rectangle

 #include<stdio.h> void main() {     int l,b;     printf("Enter length and breadth: ");     scanf("%d %d",&l,&b);     printf("Perimeter = %d", 2*(l+b) ); }

C Program to Find Perimeter of Circle

 #include<stdio.h> void main() {     float r;     printf("Enter radius: ");     scanf("%f",&r);     printf("Perimeter = %f", 2*3.14*r ); }

C Program to Find Area of Triangle

 #include<stdio.h> void main() {     float b,h;     printf("Enter base and height: ");     scanf("%f %f",&b,&h);     printf("Area = %f", 0.5*b*h ); }

C Program to Find Area of Square

 #include<stdio.h> void main() {     int a;     printf("Enter side: ");     scanf("%d",&a);     printf("Area = %d", a*a ); }

C Program to Find Area of Rectangle

 #include<stdio.h> void main() {     int l,b;     printf("Enter length and breadth: ");     scanf("%d %d",&l,&b);     printf("Area = %d", l*b ); }

C Program to Find Area of Circle

 #include<stdio.h> void main() {     float r;     printf("Enter radius: ");     scanf("%f",&r);     printf("Area = %f", 3.14*r*r ); }

C Program to Perform All Arithmetic Operations

 #include<stdio.h> void main() {     int a,b;     printf("Enter two numbers: ");     scanf("%d %d",&a,&b);     printf("Addition = %d\n",a+b);     printf("Subtraction = %d\n",a-b);     printf("Multiplication = %d\n",a*b);     printf("Division = %d\n",a/b);     printf("Remainder = %d\n",a%b); }

C Program to Find Remainder Using Modulus Operator

 #include<stdio.h> void main() {      int a,b;     printf("Enter two numbers: ");     scanf("%d %d",&a,&b);     printf(" Remainder = %d ",a%b); }

C Program to Divide Two Numbers

 #include<stdio.h> void main() {float a,b;     printf("Enter two numbers: ");     scanf("%f %f",&a,&b);       printf(" Division = %f ",a/b); }

C Program to Multiply Two Numbers

 #include<stdio.h> void main() {  int a,b;     printf("Enter two numbers: ");     scanf("%d %d",&a,&b);     printf(" Product = %d ",a*b); }

C Program to Subtract Two Numbers

 #include<stdio.h> void main() {      int a,b;     printf("Enter two numbers: ");     scanf("%d %d",&a,&b);     printf(" Difference = %d ",a-b); }

C Program to Add Two Numbers

 #include<stdio.h>   void main() { int a,b;        printf("Enter two numbers: ");       scanf("%d %d",&a,&b);                 printf(" Sum = %d ",a+b); }

C Program To Print "Hello World"

 #include<stdio.h> void main() {    printf("Hello World"); }