This file contains 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
/* to find ASCII value of a character entered by user */ | |
#include <stdio.h> | |
int main() | |
{ | |
char c; | |
printf("Enter a character: "); | |
scanf("%c",&c); | |
printf("ASCII value of %c = %d\n",c,c); | |
return 0; |
This file contains 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 a; | |
float b; | |
double c; | |
char d; | |
printf("Size of int: %d bytes\n",sizeof(a)); | |
printf("Size of float: %d bytes\n",sizeof(b)); | |
printf("Size of double: %d bytes\n",sizeof(c)); |
This file contains 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 a, b, temp; | |
printf("Enter value of a: "); | |
scanf("%d",&a); | |
printf("Enter value of b: "); | |
scanf("%d",&b); | |
temp = a; /* Value of a is stored in variable temp */ | |
a = b; /* Value of b is stored in variable a */ |
This file contains 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 num; | |
printf("Enter an integer you want to check: "); | |
scanf("%d",&num); | |
if((num%2)==0) /* Checking whether remainder is 0 or not. */ | |
printf("%d is even.",num); | |
else | |
printf("%d is odd.",num); |
This file contains 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); |
This file contains 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 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 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 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 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 |
OlderNewer