0% found this document useful (0 votes)
50 views3 pages

Programming - 1

The C program takes in an integer value, evaluates if it is greater than, equal to, or less than 0, and prints the corresponding value of n as 1, 0, or -1. It defines a function called grade that takes the integer as a parameter, uses if/else if statements to check the value, and prints the output. It then has a main function that gets user input, calls the grade function, and returns 0.

Uploaded by

F J
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
50 views3 pages

Programming - 1

The C program takes in an integer value, evaluates if it is greater than, equal to, or less than 0, and prints the corresponding value of n as 1, 0, or -1. It defines a function called grade that takes the integer as a parameter, uses if/else if statements to check the value, and prints the output. It then has a main function that gets user input, calls the grade function, and returns 0.

Uploaded by

F J
Copyright
© © All Rights Reserved
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/ 3

Write a C program to read the value of an integer m and display the

value of n is 1 when m is larger than 0, 0 when m is 0 and -1 when m is


less than 0.
int grade(int m){
if(m>0)
printf("The value of n=1\n");
else if (m==0)
printf("The value of n=0\n");
else if(m<0)
printf("The value of n=-1\n");
return 0;
}
int main(){
int x;
printf("Enter number: ");
scanf("%d", &x);
grade(x);
return 0;
}

C to read any day number in integer and display day name in the word.
#include <stdio.h>
#include <stdlib.h>
int grade(int x){
if(x==1)
printf("Saturday");
else if(x==2)
printf("Sunday");
else if(x==3)
printf("Monday");
else if(x==4)
printf("Tuesday");
else if(x==5)
printf("wednesday");
else if(x==6)
printf("Thursday");
else if(x==7)
printf("Friday");
else
printf("invalid");
return 0;
}
int main(){
int y;
printf("Enter number: ");
scanf("%d", &y);
grade(y);
return 0;
}

to read any digit, display in the word.


Input : 4 Output : Four
#include <stdio.h>
#include <stdlib.h>
int grade(int a){
if(a==0)
printf("Zero");
else if(a==1)
printf("One");
else if(a==2)
printf("Two");
else if(a==3)
printf("Three");
else if(a==4)
printf("Four");
else if(a==5)
printf("Five");
else if (a==6)
printf("six");
else if(a==7)
printf("Seven");
else if(a==8)
printf("Eight");
else if(a==9)
printf("Nine");
else
printf("Invalid");
return 0;
}
int main(){
int y;
printf("Enter number: ");
scanf("%d", &y);
grade(y);
return 0;
}

You might also like