The document contains 4 C programs that perform different comparison or calculation tasks on integers. The first program checks if two integers are equal or not. The second program checks if a single integer is positive or negative. The third program calculates profit or loss from a transaction of two integers. The fourth program checks if three integers representing angles can form a triangle. Each program includes the necessary header files, a function to perform the task, and a main function to input values and call the function.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
30 views
Programming - 1
The document contains 4 C programs that perform different comparison or calculation tasks on integers. The first program checks if two integers are equal or not. The second program checks if a single integer is positive or negative. The third program calculates profit or loss from a transaction of two integers. The fourth program checks if three integers representing angles can form a triangle. Each program includes the necessary header files, a function to perform the task, and a main function to input values and call the function.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Write a C program to accept two integers and check whether
they are equal or not.
Input : 15 15 Output : Number1 and Number2 are equal #include <stdio.h> #include <stdlib.h>
int grade(int a, int b){
if(a==b) printf("Two number are equal: \n"); else printf("Two number are unequal: \n"); return 0; } int main(){ int x,y; printf("Enter two number: "); scanf("%d%d", &x, &y); grade(x,y); return 0; }
Write a C program to check whether a given number is positive or negative
#include <stdio.h> #include <stdlib.h>
int grade(int a){
if(a>0) printf("The number is positive: \n"); else printf("The number is negative: \n"); return 0; } int main(){ int x; printf("Enter two number: "); scanf("%d", &x); grade(x); return 0; }
Write a C program to calculate profit and loss on a transaction
int grade(int a, int b){ if(a>b) printf("profit: %d", a-b); else if(b>a) printf("loss: %d", b-a); else printf(" no profit and no loss: ", a==b); return 0; } int main(){ int x,y; printf("Enter two number: "); scanf("%d%d", &x, &y); grade(x,y); return 0; } Write a C program to check whether a triangle can be formed by the given value for the angles
#include <stdio.h> #include <stdlib.h>
int grade(int a, int b, int c){
if(a+b+c==180) printf("The triangle can be formed: \n"); else printf("The triangle cant be formed: \n"); return 0; } int main(){ int x, y, z; printf("Enter three values: "); scanf("%d%d%d", &x, &y, &z); grade(x,y,z); return 0; }