0% found this document useful (0 votes)
3 views2 pages

C Programming Practical Notes

The document contains practical programming exercises for Class 10 C programming. It includes three practicals: counting males and females from user input, summing numbers greater than 100, and comparing two numbers to find the greater one. Each practical is accompanied by a sample code implementation.

Uploaded by

hakamkhoso0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

C Programming Practical Notes

The document contains practical programming exercises for Class 10 C programming. It includes three practicals: counting males and females from user input, summing numbers greater than 100, and comparing two numbers to find the greater one. Each practical is accompanied by a sample code implementation.

Uploaded by

hakamkhoso0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming Practical Notes (Class 10)

Practical 1: Count Male and Female

Write a program to input 10 names with gender and count total males and females.
#include <stdio.h>

int main() {
char name[20];
char gender;
int i, male = 0, female = 0;

for(i = 1; i <= 10; i++) {


printf("Enter name: ");
scanf("%s", name);

printf("Enter gender (M/F): ");


scanf(" %c", &gender);

if(gender == 'M' || gender == 'm') {


male++;
} else if(gender == 'F' || gender == 'f') {
female++;
}
}

printf("Number of males = %d\n", male);


printf("Number of females = %d\n", female);

return 0;
}

Practical 2: Sum of Numbers Greater than 100

Write a program to input 5 numbers and find sum of numbers greater than 100.
#include <stdio.h>

int main() {
int num, sum = 0, i;

for(i = 1; i <= 5; i++) {


printf("Enter number: ");
scanf("%d", &num);

if(num > 100) {


sum = sum + num;
}
}

printf("Sum = %d", sum);

return 0;
}

Practical 3: Compare Two Numbers

Write a program to input two numbers and display the greater number.
#include <stdio.h>

int main() {
int num1, num2;
printf("Enter first number: ");
scanf("%d", &num1);

printf("Enter second number: ");


scanf("%d", &num2);

if(num1 > num2) {


printf("First number is greater");
} else if(num2 > num1) {
printf("Second number is greater");
} else {
printf("Both numbers are equal");
}

return 0;
}

You might also like