This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int num1, num2, max; | |
printf("Enter two positive integers: "); | |
scanf("%d %d", &num1, &num2); | |
max=(num1>num2) ? num1 : num2; /* maximum value is stored in variable max */ | |
while(1) /* Always true. */ | |
{ | |
if(max%num1==0 && max%num2==0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int num1, num2, i, hcf; | |
printf("Enter two integers: "); | |
scanf("%d %d", &num1, &num2); | |
for(i=1; i<=num1 || i<=num2; ++i) | |
{ | |
if(num1%i==0 && num2%i==0) /* Checking whether i is a factor of both number */ | |
hcf=i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int count, n, t1=0, t2=1, display=0; | |
printf("Enter number of terms: "); | |
scanf("%d",&n); | |
printf("Fibonacci Series: %d %d ", t1, t2); /* Displaying first two terms */ | |
count=2; /* count=2 because first two terms are already displayed. */ | |
while (count<n) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int n, i; | |
printf("Enter an integer to find multiplication table: "); | |
scanf("%d",&n); | |
for(i=1;i<=10;++i) | |
{ | |
printf("%d * %d = %d\n", n, i, n*i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int n, count; | |
int factorial=1; | |
printf("Enter an integer: "); | |
scanf("%d",&n); | |
if ( n< 0) | |
printf("Error!!! Factorial of negative number doesn't exist."); | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
char c; | |
printf("Enter a character: "); | |
scanf("%c",&c); | |
if( (c>=65 && c<=90) || (c>=97 && c<=122)) | |
printf("%c is an alphabet.",c); | |
else | |
printf("%c is not an alphabet.",c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
float num; | |
printf("Enter a number: "); | |
scanf("%f",&num); | |
if (num<0) /* Checking whether num is less than 0*/ | |
printf("%.2f is negative.",num); | |
else if (num>0) /* Checking whether num is greater than zero*/ | |
printf("%.2f is positive.",num); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int year; | |
printf("Enter a year: "); | |
scanf("%d",&year); | |
if(year%4 == 0) | |
{ | |
if( year%100 == 0) /* Checking for a century year */ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
float a, b, c; | |
printf("Enter three numbers: "); | |
scanf("%f %f %f", &a, &b, &c); | |
if(a>=b && a>=c) | |
printf("Largest number = %.2f", a); | |
else if(b>=a && b>=c) | |
printf("Largest number = %.2f", b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
char c; | |
printf("Enter an alphabet: "); | |
scanf("%c",&c); | |
if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U') | |
printf("%c is a vowel.",c); | |
else | |
printf("%c is a consonant.",c); |