top of page

c Programming In Lab-Model Multiple College-Rupesh Das-Class XI

  • Writer: ss bo
    ss bo
  • Apr 7, 2022
  • 3 min read

Updated: Apr 10, 2022


// 1. Write a C program to check whether an alphabet is a vowel or consonant.
 
#include <stdio.h>
int main() {
    char c;
    int lowercase_vowel, uppercase_vowel;
    printf("Enter an alphabet: ");
    scanf("%c", &c);

    // evaluates to 1 if variable c is a lowercase vowel
    lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

    // evaluates to 1 if variable c is a uppercase vowel
    uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

    // evaluates to 1 (true) if c is a vowel
    if (lowercase_vowel || uppercase_vowel)
        printf("%c is a vowel.", c);
    else
        printf("%c is a consonant.", c);
    return 0;
}


// 2. Integer num or not

#include <stdio.h>
#include <conio.h>
int main(){
    int int1, int2;
 
    printf("Enter the  a and b : ");
    scanf("%d %d", &int1, &int2);
    if (int1 == int2)
        printf("a and b are equal\n");
    else
        printf("a and b are not equal\n");
}


/* 3. Write a program in C to calculate and print the Electricity bill of a given customer. The customer id., name and unit consumed by the user should be taken from the keyboard and display the total amount to pay to the customer. The charge are as follow :*/

#include <stdio.h>
#include <string.h>  
int main()
{  
   int custid, conu;
   float chg, surchg=0, gramt,netamt;
   char connm[25];

   printf("Input Customer ID :");
   scanf("%d",&custid);
   printf("Input the name of the customer :");
   scanf("%s",connm);
   printf("Input the unit consumed by the customer : ");
   scanf("%d",&conu);
   if (conu <200 )
    chg = 1.20;
   else if (conu>=200 && conu<400)
        chg = 1.50;
    else if (conu>=400 && conu<600)
            chg = 1.80;
        else
            chg = 2.00;
   gramt = conu*chg;
   if (gramt>300)
    surchg = gramt*15/100.0;
   netamt = gramt+surchg;
   if (netamt  < 100)
    netamt =100;
   printf("\nElectricity Bill\n");
   printf("Customer IDNO                       :%d\n",custid);
   printf("Customer Name                       :%s\n",connm);
   printf("unit Consumed                       :%d\n",conu);
   printf("Amount Charges @Rs. %4.2f  per unit :%8.2f\n",chg,gramt);
   printf("Surchage Amount                     :%8.2f\n",surchg);
   printf("Net Amount Paid By the Customer     :%8.2f\n",netamt);

} 

// 4. Simple Calculator
#include <stdio.h>
int main() {
  int num1,num2,opt;
  printf("Enter the first number :");
  scanf("%d",&num1);
  printf("Enter the second number :");
  scanf("%d",&num2);
  
    printf("\nInput your option :\n");
    printf("1-Addition.\n2-Substraction.\n3-Multiplication.\n4-Division.\n5-Exit.\n");
    scanf("%d",&opt);
    switch(opt) {
      case 1:
        printf("The Addition of  %d and %d is: %d\n",num1,num2,num1+num2);
        break;
        
      case 2:
        printf("The Substraction of %d  and %d is: %d\n",num1,num2,num1-num2);
        break;
        
      case 3:
   printf("The Multiplication of %d  and %d is: %d\n",num1,num2,num1*num2);
        break;  
      
      case 4:
        if(num2==0) {
          printf("The second integer is zero. Devide by zero.\n");
        } else {
        printf("The Division of %d  and %d is : %d\n",num1,num2,num1/num2);
        }  
        break;
        
      case 5: 
        break; 
        
      default:
        printf("Input correct option\n");
        break; 
    }
}


/* 5. Write a C program to read roll no, name and marks of three subjects and calculate the total, percentage and division*/
#include <stdio.h>
#include <string.h>

int main()
{
    int rl,phy,che,ca,total;
    float per;
    char nm[20],div[10];
    printf("Enter the Roll Number of the student :");
    scanf("%d",&rl);
    printf("Input the Name of the Student :");
    scanf("%s",nm);
    printf("Enter  the marks of Physics, Chemistry and Computer Application : ");
    scanf("%d%d%d",&phy,&che,&ca);
    total = phy+che+ca;
    per = total/3.0;
    if (per>=60)
     strcpy(div,"First");
    else
    if (per<60&&per>=48)
        strcpy(div,"Second");
    else
        if (per<48&&per>=36)
        strcpy(div,"Pass");
         else
        strcpy(div,"Fail");

       printf("\nRoll No : %d\nName of Student : %s\n",rl,nm);
       printf("Marks in Physics : %d\nMarks in Chemistry : %d\nMarks in Computer Application : %d\n",phy,che,ca);
       printf("Total Marks = %d\nPercentage = %5.2f\nDivision = %s\n",total,per,div);
}
/* output
Input the Roll Number of the student :784                                                                     
Input the Name of the Student :James                                                                          
Input  the marks of Physics, Chemistry and Computer Application : 70 80 90                                    
                                                                                                              
Roll No : 784                                                                                                 
Name of Student : James                                                                                       
Marks in Physics : 70                                                                                         
Marks in Chemistry : 80                                                                                       
Marks in Computer Application : 90                                                                            
Total Marks = 240                                                                                             
Percentage = 80.00                                                                                            
Division = First */













 
 
 

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2020 by SSBO. Proudly created with Wix.com

bottom of page