Chapter # 5, Loop Control Structure, Lab Activities
Chapter # 5, Loop Control Structure Lab Activities Q7. A class of 20 students takes an examination in which marks range from 1 to 100. Write a program to print the number of students passed and failed. Passing marks are 33. Program: #include<stdio.h> #include<conio.h> int main(int) { int n, m, pcount=0, fcount=0; printf(“\nEnter marks of 20 students: “); for(n=1; n<=20; n++) { printf(“\nstudents%d=”,m); scanf(“%d”, &sum); if(m>=33) pcount=pcount + 1; else fcount =fcount +1; } printf(“\nNumber of passed students%d”, pcount); printf(“\nNumber of fail students%d”, fcount); getch(); } Q8. Write a program that prints a line of 60 asterisks (*) using do while loop. Program: #include<stdio.h> #include<conio.h> int main(int) { int n; n=1 do { printf(“ * ”); n=n+1; for(n=1; n<=20; n++) { While(n<=60); getch(); } Output: *************************************** ...