0% found this document useful (0 votes)
32 views11 pages

C Programs

This program contains C code to perform various calculations and character checks: 1. It includes code to calculate a student's grade based on their average marks, check if a character is a vowel or consonant, calculate the sum of digits in a number, and perform basic math operations like addition, subtraction, multiplication and division on user-input numbers. 2. The grade calculation code uses if-else statements to check the average and print the corresponding grade. For character checking, it uses OR operators to check for vowels and prints the result. 3. The digit sum calculation uses a while loop to extract each digit and add it to the running sum. Operations like addition are done using a switch case based on

Uploaded by

Pulast S Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views11 pages

C Programs

This program contains C code to perform various calculations and character checks: 1. It includes code to calculate a student's grade based on their average marks, check if a character is a vowel or consonant, calculate the sum of digits in a number, and perform basic math operations like addition, subtraction, multiplication and division on user-input numbers. 2. The grade calculation code uses if-else statements to check the average and print the corresponding grade. For character checking, it uses OR operators to check for vowels and prints the result. 3. The digit sum calculation uses a while loop to extract each digit and add it to the running sum. Operations like addition are done using a switch case based on

Uploaded by

Pulast S Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

C Programs

Mark Range Grade


91-100 A1
81-90 A2
71-80 B1
61-70 B2
51-60 C1
41-50 C2
33-40 D
21-32 E1
0-20 E2
if(avg>=91 && avg<=100)
#include<stdio.h> printf("A1");
#include<conio.h> else if(avg>=81 && avg<91)
int main() printf("A2");
{ else if(avg>=71 && avg<81)
int i; printf("B1");
float mark, sum=0, avg; else if(avg>=61 && avg<71)
printf("Enter Marks obtained in 5 Subjects: "); printf("B2");
for(i=0; i<5; i++) else if(avg>=51 && avg<61)
{ printf("C1");
scanf("%f", &mark); else if(avg>=41 && avg<51)
sum = sum+mark; printf("C2");
} else if(avg>=33 && avg<41)
avg = sum/5; printf("D");
printf("\nGrade = "); else if(avg>=21 && avg<33)
printf("E1");
else if(avg>=0 && avg<21)
printf("E2");
else
printf("Invalid!");
getch();
return 0; }
Check Vowel or Consonant in C
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
printf("Enter an Alphabet: ");
scanf("%c", &ch);
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
printf("\nIt's a Vowel");
else if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
printf("\nIt's a Vowel");
else
printf("\nIt's a Consonant");
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
printf("Enter an Alphabet: ");
scanf("%c", &ch);
if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
{
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
printf("\nIt's a Vowel");
else if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
printf("\nIt's a Vowel");
else
printf("\nIt's a Consonant");
}
else
printf("\nIt's neither Vowel nor Consonant");
getch();
return 0;
}
Sum of Digits
#include<stdio.h>
#include<conio.h>
int main()
{
int num, sum=0, rem;
printf("Enter any number: ");
scanf("%d", &num);
while(num>0)
{
rem = num%10;
sum = sum + rem;
num = num/10;
}
printf("\nSum of Digit = %d", sum);
getch();
return 0;
}
ADD, Subtract, Multiply, Divide
res = num1+num2;
#include<stdio.h> printf("\nResult = %0.2f", res);
#include<conio.h> break;
int main() case 2:
{ res = num1-num2;
float num1, num2, res; printf("\nResult = %0.2f", res);
int choice; break;
do case 3:
{ res = num1*num2;
printf("\nResult = %0.2f", res);
printf("1. Addition\n");
break;
printf("2. Subtraction\n"); case 4:
printf("3. Multiplication\n"); res = num1/num2;
printf("4. Division\n"); printf("\nResult = %0.2f", res);
printf("5. Exit\n\n"); break;
printf("Enter Your Choice(1-5): "); case 5:
scanf("%d", &choice); return 0;
if(choice>=1 && choice<=4) default:
{ printf("\nWrong Choice!");
printf("\nEnter any two Numbers: "); break;
} printf("\n------------------------\n");
scanf("%f %f", &num1, &num2);
}while(choice!=5);
} getch();
switch(choice) { return 0; }
case 1:

You might also like