#include<stdio.h> int main() { char ch; while(1) { scanf("%c",&ch); if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||ch=='o'||ch=='O'||ch=='u'||ch=='U') break; } return 0; }
Archive for the ‘MECH Sem1’ Category
1. WAP to get a character from the user until he enters vowel.
Posted: September 23, 2012 in CSE Sem1, Lab 10, Lab 10, MECH Sem10
11. WAP to change the CAPS of characters i.e. if input character is in small the output will be in capital.
Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { char ch; printf("Enter a character"); scanf("%c",&ch); if((ch>=65)&&(ch<=122)) { ch=ch-32; printf("The upper case character corresponding is=%c\n",ch); } else printf("Enter Invalid"); return 0; }
11. WAP to change the CAPS of characters i.e. if input character is in capital the output will be in small
Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { char ch; printf("Enter a character"); scanf("%c",&ch); if((ch>=65)&&(ch<=122)) { ch=ch+32; printf("The lower case character corresponding is %c\n",ch); } else printf("Enter Invalid"); return 0; }
10. Consider the choice is input through keyboard. If choice is 1 then find area of triangle. If choice is 3 then find area of rectangle. If choice is 7 then find area of Square. Otherwise find area of circle
Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { int i; float base,height,area,width,length,area1,side,area2,radius,area3; scanf("%d",&i); switch(i) { case 1: printf("Enter Base:"); scanf("%f",&base); printf("Enter Height"); scanf("%f",&height); area=0.5*base*height; printf("Area of Triangle=%f\n",area); break; case 3: printf("Enter Width:"); scanf("%f",&width); printf("Enter Length:"); scanf("%f",&length); area1=width*length; printf("Area of rectangle=%f\n",area1); break; case 7: printf("Enter Side:"); scanf("%f",&side); area2=side*side; printf("Area of Square=%f\n",area2); break; default: printf("Enter radius:"); scanf("%f",&radius); area3=3.14*radius*radius; printf("Area of Circle=%f\n",area3); } return 0; }
9. Consider area of triangle and base are input through keyboard. Find the height of triangle. Now consider this height is as height of rectangle and then ask width from user. WAP for the same.
Posted: September 23, 2012 in CSE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { float area,base,height,area_rec,width; printf("Area:"); scanf("%f",&area); printf("Base:"); scanf("%f",&base); height=((2*area)/base); printf("Height=%f\n",height); printf("Area Of Rectangle:"); scanf("%f",&area_rec); width=area_rec/height; printf("Width=%f",width); return 0; }
8. WAP to find the absolute value of a number entered through the keyboard without absolute function using Conditional Operator.
Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { int a,b; printf("enter the value of a"); scanf("%d",&a); if(a<0) { b=a*-1; printf("\nabsolute value of %d is %d",a,b); } else { printf("\nabsolute value=%d",a); } return 0; }
8. WAP to find the absolute value of a number entered through the keyboard with absolute function using Conditional Operator.
Posted: September 23, 2012 in CSE Sem1, Lab 10, Lab 10, MECH Sem1#include<stdio.h> int main() { int m; printf("enter the value of m:"); scanf("%d",&m); (m>=0?printf("%d",m):printf("%d",-(-m))); return 0; }
6. Any year is input through the keyboard. WAP to determine whether the year is a leap year or not.
Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1#include<stdio.h> int main() { int year; scanf("%d",&year); if(((year%4==0)&&(year%100!=0))||(year%400==0)) { printf("%d is leap year",year); } else printf("%d is not leap year",year); return 0; }