Posts

Showing posts from June, 2017

Code for week according to number

Image
Code for week according to number #include<stdio.h> #include<conio.h> void main() { int d; printf("Enter any number from 1 to 7"); scanf("%d",&d); if(d==1) { printf("Sunday"); } else if(d==2) { printf("Monday"); } else if(d==3) { printf("Tuesday"); } else if(d==4) { printf("Wednesday"); } else if(d==5) { printf("Thursday"); } else if(d==6) { printf("Friday"); } else if(d==7) { printf("Saturday"); } else { printf("Enter a valid number"); } getch(); } Output

Code for marks grade

Image
Code for marks grade #include<stdio.h> #include<conio.h> void main() { int m; printf("Enter marks scored"); scanf("%d",&m); if(m>=90) { printf("Merit"); } else if((m>=80)&&(m<90)) { printf("First"); } else if((m>=70)&&(m<80)) { printf("Second"); } else if((m>=60)&&(m<70)) { printf("Third"); } else { printf("Fail"); } getch(); } Output

Code to check alphabet is vowel or consonant

Image
Code to check alphabet is vowel or consonant #include<stdio.h> #include<conio.h> void main() { char a; printf("Enter any alphabet"); scanf("%C",&a); if((a=='a')||(a=='e')||(a=='i')||(a=='o')||(a=='u')) { printf("It is a vowel"); } else { printf("It is a consonant"); } getch(); } Output

Code to find greatest number

Image
Code to find greatest number #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("Enter a,b and c"); scanf("%d%d%d",&a,&b,&c); if((a>b)&&(a>c)) { printf("greatest number=%d",a); } else if((b>c)&&(b>a)) { printf("greatest number=%d",b); } else { printf("greatest number=%d",c); } getch(); } Output

Code to check number is even or odd

Image
Code to check number is even or odd #include<stdio.h> #include<conio.h> void main() { int a; printf("Enter any number"); scanf("%d",&a); if(a%2==0) { printf("It is an even number"); } else { printf("It is an odd number"); } getch(); } Output

Code to check leap year

Image
Code to check leap year #include<stdio.h> #include<conio.h> void main() { int a; printf("Enter year"); scanf("%d",&a); if(a%4==0) { printf("It is a leap year"); } else { printf("It is not a leap year"); } getch(); } OUTPUT

Code to check number divisible by 3 and 5

Image
Code to check number is divisible by 3 and 5 (If number is divisible by both 3&5 then it will print Hi, otherwise it will print bye) #include<stdio.h> #include<conio.h> void main() { int a; printf("Enter any number"); scanf("%d",&a); if((a%3==0)&&(a%5==0)) { printf("Hi"); } else { printf("Bye"); } getch(); } Output

Area of circle

Image
Code for area of circle #include<stdio.h> #include<conio.h> void main() { int r; float a; printf("Enter radius of circle"); scanf("%d",&r); a=3.15*r*r; printf("Area=%f",a); getch(); } Output

Area of Square

Image
Code for area of square #include<stdio.h> #include<conio.h> void main() { int a,s; printf("Enter side of square"); scanf("%d",&s); a=s*s; printf("Area=%d",a); getch(); } Output

Area of rectangle

Image
Code for area of rectangle                                                #include<stdio.h> #include<conio.h> void main() { int a,l,b; printf("Enter length and breadth"); scanf("%d%d",&l,&b); a=l*b; printf("Area=%d",a); getch(); } Output