0% found this document useful (0 votes)
10 views

Basic C Program

The document contains code for a C program that takes user input for a math operation choice (sum, subtraction, multiplication, division) and two numbers, then performs the chosen operation and prints the result. It uses if/else statements to check the user's choice and call the appropriate operation.

Uploaded by

cgtnss4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Basic C Program

The document contains code for a C program that takes user input for a math operation choice (sum, subtraction, multiplication, division) and two numbers, then performs the chosen operation and prints the result. It uses if/else statements to check the user's choice and call the appropriate operation.

Uploaded by

cgtnss4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Q1

OUTPUT
Q2

OUTPUT
#include <stdio.h>

int main() {
char input;
int a, b;
printf("Enter the choice (s-sum, a-sub, m-mul, d-div):");
scanf(" %c", &input);

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

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

int sum = a + b;
int sub = a - b;
int multi = a * b;
int divi = (float)a / b;

if (input == 's') {
printf("Addition of two numbers: %d\n", sum);
} else if (input == 'S') {
printf("Subtraction of two numbers: %d\n", sub);
} else if (input == 'm') {
printf("Multiplication of two numbers: %d\n", multi);
} else if (input == 'd') {
printf("Division of two numbers: %d\n", divi);
} else {
printf("Invalid choice\n");
}

return 0;
}
#include<stdio.h>

int main(){

int math_m, phy_m, chem_m;

printf(" marks in mathematics:");

scanf("%d", &math_m);

printf(" marks in physics:");

scanf("%d", &phy_m);

printf(" marks in chemistry:");

scanf("%d", &chem_m);

int total3=math_m+phy_m+chem_m;

int total_ma_ph=math_m+phy_m;

if (math_m>=60 && phy_m>=50 && chem_m>=40 && total3>=200 && total_ma_ph>=150){

printf("Eligible");

}else if(total3<=200 && total_ma_ph<=150){

printf("Not Eligible");

}else{

printf("invalid marks");

return 0;

}
8:48 PM (2
hours ago)

#include <stdio.h>

int main() {

int reg_no;

printf("enter reg_no");

scanf("%d", &reg_no);

int register_no=reg_no%10;

if(register_no==5){
int square= register_no*register_no;

printf("square of %d is %d \n", register_no,square);

}else{

printf("Unit digit is not 5");

return 0;

You might also like