C Program to Find Roots of Quadratic Equation

Here you will get C program to find roots of quadratic equation ax2+bx+c=0 #include<stdio.h> #include<math.h> int main() { float root1,root2,a,b,c,d,imaginaryPart,realPart; printf(“Quadratic Equation is ax^2+bx+c=0”); printf(“\nEnter values of a,b and c:”); scanf(“%f%f%f”,&a,&b,&c); d=(b*b)-(4*a*c); if(d>0) { printf(“\nTwo real and distinct roots”); root1=(-b+sqrt(d))/(2*a); root2=(-b-sqrt(d))/(2*a); printf(“\nRoots are %f and %f”,root1,root2); } else if(d==0) { printf(“\nTwo real and equal roots”); root1=root2=-b/(2*a); …

C Program to Find Roots of Quadratic Equation Read More »

C program to check given alphabate is vowel or not using switch case

#include<stdio.h> #include<conio.h> void main() { char ch; clrscr(); printf(“Enter an alphabate:”); scanf(“%c”,&ch); switch(ch) { case ‘a’: case ‘A’: case ‘e’: case ‘E’: case ‘i’: case ‘I’: case ‘o’: case ‘O’: case ‘u’: case ‘U’: printf(“The alphabate is vowel”); break; default: printf(“The alphabate is not vowel”); } getch(); }

C program to print size of different data types

#include<stdio.h> #include<conio.h> void main() { clrscr(); printf(“TypettttSize (bytes)”); printf(“nCharacterttt    %d”,sizeof(char)); printf(“nIntegertttt    %d”,sizeof(int)); printf(“nLong intttt    %d”,sizeof(long int)); printf(“nFloattttt    %d”,sizeof(float)); printf(“nDoubletttt    %d”,sizeof(double)); printf(“nLong doublettt    %d”,sizeof(long double)); getch(); }

C program to perform arithmetic operations using switch case

#include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int ch; float a,b,res; clrscr(); printf(“Enter two numbers:”); scanf(“%f%f”,&a,&b); printf(“nMenun1.Additionn2.Subtractionn3.Multiplicationn4.Division”); printf(“nEnter your choice:”); scanf(“%d”,&ch); switch(ch) { case 1: res=a+b; break; case 2: res=a-b; break; case 3: res=a*b; break; case 4: res=a/b; break; default: printf(“Wrong choice!!nPress any key…”); getch(); exit(0); } printf(“nResult=%f”,res); getch(); }

C program to swap two numbers using pointers

#include<stdio.h> #include<conio.h> void main() { int *a,*b,*temp; clrscr(); printf(“Enter two mumbers:”); scanf(“%d%d”,a,b); printf(“Before Swaping:na=%d b=%d”,*a,*b); temp=a; a=b; b=temp; printf(“nAfter Swaping:na=%d b=%d”,*a,*b); getch(); }