Q.3) Write a program to find weekdays name with weekday number. Ans: #include int main() { int day; printf("enter the weekday number: "); scanf("%d",&day); switch(day) { case 1:printf("Monday"); break; case 2:printf("Tuesday"); break; case 3:printf("Wenesday"); break; case 4:printf("Thrusday"); break; case 5:printf("Friday"); break; case 6:printf("Saturday"); break; case 7:printf("Sunday"); break; default:printf("wrong input"); break; } return 0; } Output: enter the weekday number: 5 Friday
@rohitsaha48926 ай бұрын
Q.1) Wap in C to determine the Grade of particular subject according to the given marks of student using switch case. Ans: #include int main() { int m,n; printf("enter the marks of student:"); scanf("%d",&n); m=n/10; switch(m) { case 9:printf("Grade:O,outstanding"); break; case 8:printf("Grade:E,excellent"); break; case 7:printf("Grade:A,very good"); break; case 6:printf("Grade:B,good"); break; case 5:printf("Grade:C,satisfactory"); break; case 4:printf("Grade:D,standard"); break; default:printf("Fail"); break; } return 0; } Output: i.) enter the marks of student:90 Grade:O,outstanding ii) enter the marks of student:95 Grade:O,outstanding iii) enter the marks of student:65 Grade:B,good
@rohitsaha48926 ай бұрын
Q.)Wap in C to determine the Grade of particular subject according to the given marks of student. Ans: #include int main() { int n; printf("enter the marks of student:"); scanf("%d",&n); if(n>=91&&n=81&&n=71&&n=61&&n=51&&n=40&&n
@rohitsaha48926 ай бұрын
Q.1) Wap in C to genearate calculator using if-else statement. Ans: #include int main() { int a,b,i,s; printf("enter a number of a: "); scanf("%d",&a); printf("enter a number of b: "); scanf("%d",&b); printf(" 1 for addition 2 for substarction 3 for multiplication 4 for division enter your choice:"); scanf("%d",&i); if(i==1) { s = a + b; } else if(i==2) { s = a - b; } else if(i==3) { s = a * b; } else if(i==4) { s = a / b; } else { printf("you entered wrong input: "); } printf("the result is:%d",s); return 0; } Output: i.) enter a number of a :10 enter a number of b :10 /n 1 for summation/n 2 for substraction/n 3 for multiplication/n 4 for division/n enter your choice:3 the result is:100 ii.) enter a number of a :10 enter a number of b :10 /n 1 for summation/n 2 for substraction/n 3 for multiplication/n 4 for division/n enter your choice:5 wrong choice:the result is:0
@rohitsaha48926 ай бұрын
Q.2) Wap in C to generate calculator using switch case. Ans: #include int main() { int a,b,s,i; printf("enter a number of a :"); scanf("%d",&a); printf("enter a number of b :"); scanf("%d",&b); printf("/n 1 for summation/n 2 for substraction/n 3 for multiplication/n 4 for division/n enter your choice:"); scanf("%d",&i); switch(i) { case 1:s=a+b; break; case 2:s=a-b; break; case 3:s=a*b; break; case 4:s=a/b; break; default:printf("wrong choice:"); break; } printf("the result is:%d",s); return 0; } Output: i.) enter a number of a :14 enter a number of b :24 /n 1 for summation/n 2 for substraction/n 3 for multiplication/n 4 for division/n enter your choice:1 the result is:38 ii.) enter a number of a :50 enter a number of b :30 /n 1 for summation/n 2 for substraction/n 3 for multiplication/n 4 for division/n enter your choice:3 the result is:1500
@rohitsaha48926 ай бұрын
#include #include int main() { float a,b,c,dis,real,root1,root2,img; //declaration of varible using float datatype printf("enter the value of coeficients a,b,c: "); // print the value of coeficients of a,b,c scanf("%f%f%f",&a,&b,&c); // value of a,b,c given by user dis = b * b - 4 * a * c; //formula of discreminent if(dis>0) //using if else and else if staement { root1 = - b + sqrt(dis) / 2*a; //formula of root1 root2 = - b - sqrt(dis) / 2*a; //formula of root2 printf(" value of root1 = %.2f and value of root2 =%.2f",root1,root2); //print the value of root1 and root2 } else if(dis==0) { root1 = root2 = - b / 2*a; //value of root1 and root2 are same printf(" value of root1 = %.2f and value of root2 =%.2f",root1,root2); //print the value of root1 and root2 } else { real = - b / 2*a; //formula of real part img = sqrt(-dis) / 2*a; //formula of imaginary part printf(" value of root1 = %.2f + %.2fi and value of root2 = %.2f - %.2fi",real,img,real,img); //adding real and imaginary part and get the value of root1 and root2 } return 0; } Output: i) enter the value of coeficient a,b,c: 2 3 2 value of root1 = -3.00 + 2.65i and value of root2 = -3.00 - 2.65i ii) enter the value of coeficient a,b,c: 1 2 1 value of root1 = -1.00 and value of root2 =-1.00